Rebase webrtc/base 6129:6163 (svn diff -r 6129:6163 http://webrtc.googlecode.com/svn/trunk/talk/base apply diff manually)

BUG=N/A
R=andrew@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/15519004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@6175 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
henrike@webrtc.org 2014-05-15 16:33:04 +00:00
parent 6bfd6196ff
commit cfdf420e21
4 changed files with 32 additions and 33 deletions

View File

@ -31,6 +31,7 @@
#if defined(WEBRTC_MAC)
#include <mach/mach_host.h>
#include <mach/mach_init.h>
#include <mach/mach_port.h>
#include <mach/host_info.h>
#include <mach/task.h>
#endif // defined(WEBRTC_MAC)
@ -224,11 +225,14 @@ float CpuSampler::GetSystemLoad() {
#endif // WEBRTC_WIN
#if defined(WEBRTC_MAC)
mach_port_t mach_host = mach_host_self();
host_cpu_load_info_data_t cpu_info;
mach_msg_type_number_t info_count = HOST_CPU_LOAD_INFO_COUNT;
if (KERN_SUCCESS != host_statistics(mach_host_self(), HOST_CPU_LOAD_INFO,
reinterpret_cast<host_info_t>(&cpu_info),
&info_count)) {
kern_return_t kr = host_statistics(mach_host, HOST_CPU_LOAD_INFO,
reinterpret_cast<host_info_t>(&cpu_info),
&info_count);
mach_port_deallocate(mach_task_self(), mach_host);
if (KERN_SUCCESS != kr) {
LOG(LS_ERROR) << "::host_statistics() failed";
return 0.f;
}

View File

@ -19,11 +19,6 @@
#include "testing/base/public/gunit.h"
#endif
// forward declarations
namespace rtc {
class Pathname;
}
// Wait until "ex" is true, or "timeout" expires.
#define WAIT(ex, timeout) \
for (uint32 start = rtc::Time(); \
@ -90,6 +85,4 @@ class Pathname;
} \
} while (0);
rtc::Pathname GetTalkDirectory();
#endif // WEBRTC_BASE_GUNIT_H_

View File

@ -28,6 +28,7 @@
#include "webrtc/base/common.h"
#include "webrtc/base/gunit.h"
#include "webrtc/base/nethelpers.h"
#include "webrtc/base/pathutils.h"
#include "webrtc/base/stream.h"
#include "webrtc/base/stringencode.h"
#include "webrtc/base/stringutils.h"
@ -434,6 +435,30 @@ inline bool ReadFile(const char* filename, std::string* contents) {
return success;
}
// Look in parent dir for parallel directory.
inline rtc::Pathname GetSiblingDirectory(
const std::string& parallel_dir) {
rtc::Pathname path = rtc::Filesystem::GetCurrentDirectory();
while (!path.empty()) {
rtc::Pathname potential_parallel_dir = path;
potential_parallel_dir.AppendFolder(parallel_dir);
if (rtc::Filesystem::IsFolder(potential_parallel_dir)) {
return potential_parallel_dir;
}
path.SetFolder(path.parent_folder());
}
return path;
}
inline rtc::Pathname GetGoogle3Directory() {
return GetSiblingDirectory("google3");
}
inline rtc::Pathname GetTalkDirectory() {
return GetSiblingDirectory("talk");
}
///////////////////////////////////////////////////////////////////////////////
// Unittest predicates which are similar to STREQ, but for raw memory
///////////////////////////////////////////////////////////////////////////////

View File

@ -18,7 +18,6 @@
#include "webrtc/base/fileutils.h"
#include "webrtc/base/gunit.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/pathutils.h"
DEFINE_bool(help, false, "prints this message");
DEFINE_string(log, "", "logging options to use");
@ -53,28 +52,6 @@ int TestCrtReportHandler(int report_type, char* msg, int* retval) {
}
#endif // WEBRTC_WIN
rtc::Pathname GetTalkDirectory() {
// Locate talk directory.
rtc::Pathname path = rtc::Filesystem::GetCurrentDirectory();
std::string talk_folder_name("talk");
talk_folder_name += path.folder_delimiter();
while (path.folder_name() != talk_folder_name && !path.empty()) {
path.SetFolder(path.parent_folder());
}
// If not running inside "talk" folder, then assume running in its parent
// folder.
if (path.empty()) {
path = rtc::Filesystem::GetCurrentDirectory();
path.AppendFolder("talk");
// Make sure the folder exist.
if (!rtc::Filesystem::IsFolder(path)) {
path.clear();
}
}
return path;
}
int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, false);