diff options
Diffstat (limited to 'webrtc/system_wrappers/include')
36 files changed, 276 insertions, 427 deletions
diff --git a/webrtc/system_wrappers/include/aligned_array.h b/webrtc/system_wrappers/include/aligned_array.h index a3a5911e36..a2ffe99c14 100644 --- a/webrtc/system_wrappers/include/aligned_array.h +++ b/webrtc/system_wrappers/include/aligned_array.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_ALIGNED_ARRAY_ -#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_ALIGNED_ARRAY_ +#ifndef WEBRTC_SYSTEM_WRAPPERS_INCLUDE_ALIGNED_ARRAY_ +#define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_ALIGNED_ARRAY_ #include "webrtc/base/checks.h" #include "webrtc/system_wrappers/include/aligned_malloc.h" @@ -20,21 +20,20 @@ namespace webrtc { // aligned to the given byte alignment. template<typename T> class AlignedArray { public: - AlignedArray(int rows, size_t cols, int alignment) + AlignedArray(size_t rows, size_t cols, size_t alignment) : rows_(rows), - cols_(cols), - alignment_(alignment) { - RTC_CHECK_GT(alignment_, 0); + cols_(cols) { + RTC_CHECK_GT(alignment, 0u); head_row_ = static_cast<T**>(AlignedMalloc(rows_ * sizeof(*head_row_), - alignment_)); - for (int i = 0; i < rows_; ++i) { + alignment)); + for (size_t i = 0; i < rows_; ++i) { head_row_[i] = static_cast<T*>(AlignedMalloc(cols_ * sizeof(**head_row_), - alignment_)); + alignment)); } } ~AlignedArray() { - for (int i = 0; i < rows_; ++i) { + for (size_t i = 0; i < rows_; ++i) { AlignedFree(head_row_[i]); } AlignedFree(head_row_); @@ -48,27 +47,27 @@ template<typename T> class AlignedArray { return head_row_; } - T* Row(int row) { + T* Row(size_t row) { RTC_CHECK_LE(row, rows_); return head_row_[row]; } - const T* Row(int row) const { + const T* Row(size_t row) const { RTC_CHECK_LE(row, rows_); return head_row_[row]; } - T& At(int row, size_t col) { + T& At(size_t row, size_t col) { RTC_CHECK_LE(col, cols_); return Row(row)[col]; } - const T& At(int row, size_t col) const { + const T& At(size_t row, size_t col) const { RTC_CHECK_LE(col, cols_); return Row(row)[col]; } - int rows() const { + size_t rows() const { return rows_; } @@ -77,12 +76,11 @@ template<typename T> class AlignedArray { } private: - int rows_; + size_t rows_; size_t cols_; - int alignment_; T** head_row_; }; } // namespace webrtc -#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_ALIGNED_ARRAY_ +#endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_ALIGNED_ARRAY_ diff --git a/webrtc/system_wrappers/include/aligned_malloc.h b/webrtc/system_wrappers/include/aligned_malloc.h index 5d343cde7c..277abec020 100644 --- a/webrtc/system_wrappers/include/aligned_malloc.h +++ b/webrtc/system_wrappers/include/aligned_malloc.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_ALIGNED_MALLOC_H_ -#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_ALIGNED_MALLOC_H_ +#ifndef WEBRTC_SYSTEM_WRAPPERS_INCLUDE_ALIGNED_MALLOC_H_ +#define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_ALIGNED_MALLOC_H_ // The functions declared here // 1) Allocates block of aligned memory. @@ -56,4 +56,4 @@ struct AlignedFreeDeleter { } // namespace webrtc -#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_ALIGNED_MALLOC_H_ +#endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_ALIGNED_MALLOC_H_ diff --git a/webrtc/system_wrappers/include/asm_defines.h b/webrtc/system_wrappers/include/asm_defines.h index c2a688f00a..fe4c05effc 100644 --- a/webrtc/system_wrappers/include/asm_defines.h +++ b/webrtc/system_wrappers/include/asm_defines.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_ASM_DEFINES_H_ -#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_ASM_DEFINES_H_ +#ifndef WEBRTC_SYSTEM_WRAPPERS_INCLUDE_ASM_DEFINES_H_ +#define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_ASM_DEFINES_H_ #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits @@ -63,4 +63,4 @@ strheq \reg1, \reg2, \num .text -#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_ASM_DEFINES_H_ +#endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_ASM_DEFINES_H_ diff --git a/webrtc/system_wrappers/include/atomic32.h b/webrtc/system_wrappers/include/atomic32.h index 36ca144bda..78e649d8b6 100644 --- a/webrtc/system_wrappers/include/atomic32.h +++ b/webrtc/system_wrappers/include/atomic32.h @@ -12,8 +12,8 @@ // doing, use locks instead! :-) // // Note: assumes 32-bit (or higher) system -#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_ATOMIC32_H_ -#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_ATOMIC32_H_ +#ifndef WEBRTC_SYSTEM_WRAPPERS_INCLUDE_ATOMIC32_H_ +#define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_ATOMIC32_H_ #include <stddef.h> @@ -63,4 +63,4 @@ class Atomic32 { } // namespace webrtc -#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_ATOMIC32_H_ +#endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_ATOMIC32_H_ diff --git a/webrtc/system_wrappers/include/clock.h b/webrtc/system_wrappers/include/clock.h index 14253ba560..f443057bea 100644 --- a/webrtc/system_wrappers/include/clock.h +++ b/webrtc/system_wrappers/include/clock.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CLOCK_H_ -#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CLOCK_H_ +#ifndef WEBRTC_SYSTEM_WRAPPERS_INCLUDE_CLOCK_H_ +#define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_CLOCK_H_ #include "webrtc/base/scoped_ptr.h" #include "webrtc/system_wrappers/include/rw_lock_wrapper.h" @@ -81,4 +81,4 @@ class SimulatedClock : public Clock { }; // namespace webrtc -#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CLOCK_H_ +#endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_CLOCK_H_ diff --git a/webrtc/system_wrappers/include/compile_assert_c.h b/webrtc/system_wrappers/include/compile_assert_c.h index dbb5292d97..b402d7192d 100644 --- a/webrtc/system_wrappers/include/compile_assert_c.h +++ b/webrtc/system_wrappers/include/compile_assert_c.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_COMPILE_ASSERT_H_ -#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_COMPILE_ASSERT_H_ +#ifndef WEBRTC_SYSTEM_WRAPPERS_INCLUDE_COMPILE_ASSERT_H_ +#define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_COMPILE_ASSERT_H_ #ifdef __cplusplus #error "Only use this for C files. For C++, use static_assert." @@ -21,4 +21,4 @@ // COMPILE_ASSERT(sizeof(foo) < 128); #define COMPILE_ASSERT(expression) switch (0) {case 0: case expression:;} -#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_COMPILE_ASSERT_H_ +#endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_COMPILE_ASSERT_H_ diff --git a/webrtc/system_wrappers/include/condition_variable_wrapper.h b/webrtc/system_wrappers/include/condition_variable_wrapper.h index 151f00ece1..37ca30f036 100644 --- a/webrtc/system_wrappers/include/condition_variable_wrapper.h +++ b/webrtc/system_wrappers/include/condition_variable_wrapper.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CONDITION_VARIABLE_WRAPPER_H_ -#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CONDITION_VARIABLE_WRAPPER_H_ +#ifndef WEBRTC_SYSTEM_WRAPPERS_INCLUDE_CONDITION_VARIABLE_WRAPPER_H_ +#define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_CONDITION_VARIABLE_WRAPPER_H_ namespace webrtc { @@ -39,4 +39,4 @@ class ConditionVariableWrapper { } // namespace webrtc -#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CONDITION_VARIABLE_WRAPPER_H_ +#endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_CONDITION_VARIABLE_WRAPPER_H_ diff --git a/webrtc/system_wrappers/include/cpu_features_wrapper.h b/webrtc/system_wrappers/include/cpu_features_wrapper.h index 5697c49164..9838d94e58 100644 --- a/webrtc/system_wrappers/include/cpu_features_wrapper.h +++ b/webrtc/system_wrappers/include/cpu_features_wrapper.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CPU_FEATURES_WRAPPER_H_ -#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CPU_FEATURES_WRAPPER_H_ +#ifndef WEBRTC_SYSTEM_WRAPPERS_INCLUDE_CPU_FEATURES_WRAPPER_H_ +#define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_CPU_FEATURES_WRAPPER_H_ #if defined(__cplusplus) || defined(c_plusplus) extern "C" { @@ -48,4 +48,4 @@ extern uint64_t WebRtc_GetCPUFeaturesARM(void); } // extern "C" #endif -#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CPU_FEATURES_WRAPPER_H_ +#endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_CPU_FEATURES_WRAPPER_H_ diff --git a/webrtc/system_wrappers/include/cpu_info.h b/webrtc/system_wrappers/include/cpu_info.h index 65888b8d32..3c00d33ed3 100644 --- a/webrtc/system_wrappers/include/cpu_info.h +++ b/webrtc/system_wrappers/include/cpu_info.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CPU_INFO_H_ -#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CPU_INFO_H_ +#ifndef WEBRTC_SYSTEM_WRAPPERS_INCLUDE_CPU_INFO_H_ +#define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_CPU_INFO_H_ #include "webrtc/typedefs.h" @@ -25,4 +25,4 @@ class CpuInfo { } // namespace webrtc -#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CPU_INFO_H_ +#endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_CPU_INFO_H_ diff --git a/webrtc/system_wrappers/include/critical_section_wrapper.h b/webrtc/system_wrappers/include/critical_section_wrapper.h index e93a249e25..7dd217e40d 100644 --- a/webrtc/system_wrappers/include/critical_section_wrapper.h +++ b/webrtc/system_wrappers/include/critical_section_wrapper.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CRITICAL_SECTION_WRAPPER_H_ -#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CRITICAL_SECTION_WRAPPER_H_ +#ifndef WEBRTC_SYSTEM_WRAPPERS_INCLUDE_CRITICAL_SECTION_WRAPPER_H_ +#define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_CRITICAL_SECTION_WRAPPER_H_ // If the critical section is heavily contended it may be beneficial to use // read/write locks instead. @@ -51,4 +51,4 @@ class SCOPED_LOCKABLE CriticalSectionScoped { } // namespace webrtc -#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CRITICAL_SECTION_WRAPPER_H_ +#endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_CRITICAL_SECTION_WRAPPER_H_ diff --git a/webrtc/system_wrappers/include/data_log.h b/webrtc/system_wrappers/include/data_log.h index cf095674a3..f6cad88e96 100644 --- a/webrtc/system_wrappers/include/data_log.h +++ b/webrtc/system_wrappers/include/data_log.h @@ -28,8 +28,8 @@ // // Table names and column names are case sensitive. -#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_DATA_LOG_H_ -#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_DATA_LOG_H_ +#ifndef WEBRTC_SYSTEM_WRAPPERS_INCLUDE_DATA_LOG_H_ +#define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_DATA_LOG_H_ #include <string> @@ -116,4 +116,4 @@ class DataLog { } // namespace webrtc -#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_DATA_LOG_H_ +#endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_DATA_LOG_H_ diff --git a/webrtc/system_wrappers/include/data_log_c.h b/webrtc/system_wrappers/include/data_log_c.h index 4ff8329c85..d31e4d972e 100644 --- a/webrtc/system_wrappers/include/data_log_c.h +++ b/webrtc/system_wrappers/include/data_log_c.h @@ -12,8 +12,8 @@ // mapped here except for InsertCell as C does not support templates. // See data_log.h for a description of the functions. -#ifndef SRC_SYSTEM_WRAPPERS_INTERFACE_DATA_LOG_C_H_ -#define SRC_SYSTEM_WRAPPERS_INTERFACE_DATA_LOG_C_H_ +#ifndef SRC_SYSTEM_WRAPPERS_INCLUDE_DATA_LOG_C_H_ +#define SRC_SYSTEM_WRAPPERS_INCLUDE_DATA_LOG_C_H_ #include <stddef.h> // size_t @@ -82,4 +82,4 @@ int WebRtcDataLog_NextRow(const char* table_name); } // end of extern "C" #endif -#endif // SRC_SYSTEM_WRAPPERS_INTERFACE_DATA_LOG_C_H_ // NOLINT +#endif // SRC_SYSTEM_WRAPPERS_INCLUDE_DATA_LOG_C_H_ // NOLINT diff --git a/webrtc/system_wrappers/include/data_log_impl.h b/webrtc/system_wrappers/include/data_log_impl.h index 56d98f891e..35519609b9 100644 --- a/webrtc/system_wrappers/include/data_log_impl.h +++ b/webrtc/system_wrappers/include/data_log_impl.h @@ -14,16 +14,16 @@ // These classes are helper classes used for logging data for offline // processing. Data logged with these classes can conveniently be parsed and // processed with e.g. Matlab. -#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_DATA_LOG_IMPL_H_ -#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_DATA_LOG_IMPL_H_ +#ifndef WEBRTC_SYSTEM_WRAPPERS_INCLUDE_DATA_LOG_IMPL_H_ +#define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_DATA_LOG_IMPL_H_ #include <map> #include <sstream> #include <string> #include <vector> +#include "webrtc/base/platform_thread.h" #include "webrtc/base/scoped_ptr.h" -#include "webrtc/system_wrappers/include/thread_wrapper.h" #include "webrtc/typedefs.h" namespace webrtc { @@ -146,10 +146,12 @@ class DataLogImpl { int counter_; TableMap tables_; EventWrapper* flush_event_; - rtc::scoped_ptr<ThreadWrapper> file_writer_thread_; + // This is a scoped_ptr so that we don't have to create threads in the no-op + // impl. + rtc::scoped_ptr<rtc::PlatformThread> file_writer_thread_; RWLockWrapper* tables_lock_; }; } // namespace webrtc -#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_DATA_LOG_IMPL_H_ +#endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_DATA_LOG_IMPL_H_ diff --git a/webrtc/system_wrappers/include/event_tracer.h b/webrtc/system_wrappers/include/event_tracer.h deleted file mode 100644 index 9b1eb1eb92..0000000000 --- a/webrtc/system_wrappers/include/event_tracer.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -// This file defines the interface for event tracing in WebRTC. -// -// Event log handlers are set through SetupEventTracer(). User of this API will -// provide two function pointers to handle event tracing calls. -// -// * GetCategoryEnabledPtr -// Event tracing system calls this function to determine if a particular -// event category is enabled. -// -// * AddTraceEventPtr -// Adds a tracing event. It is the user's responsibility to log the data -// provided. -// -// Parameters for the above two functions are described in trace_event.h. - -#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_EVENT_TRACER_H_ -#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_EVENT_TRACER_H_ - -// This file has moved. -// TODO(tommi): Delete after removing dependencies and updating Chromium. -#include "webrtc/base/event_tracer.h" - -#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_EVENT_TRACER_H_ diff --git a/webrtc/system_wrappers/include/event_wrapper.h b/webrtc/system_wrappers/include/event_wrapper.h index bd12eef908..cc3722bd6b 100644 --- a/webrtc/system_wrappers/include/event_wrapper.h +++ b/webrtc/system_wrappers/include/event_wrapper.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_EVENT_WRAPPER_H_ -#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_EVENT_WRAPPER_H_ +#ifndef WEBRTC_SYSTEM_WRAPPERS_INCLUDE_EVENT_WRAPPER_H_ +#define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_EVENT_WRAPPER_H_ namespace webrtc { enum EventTypeWrapper { @@ -67,4 +67,4 @@ class EventTimerWrapper : public EventWrapper { } // namespace webrtc -#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_EVENT_WRAPPER_H_ +#endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_EVENT_WRAPPER_H_ diff --git a/webrtc/system_wrappers/include/field_trial.h b/webrtc/system_wrappers/include/field_trial.h index 2af083cdac..62fbfd1a50 100644 --- a/webrtc/system_wrappers/include/field_trial.h +++ b/webrtc/system_wrappers/include/field_trial.h @@ -8,8 +8,8 @@ // be found in the AUTHORS file in the root of the source tree. // -#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_FIELD_TRIAL_H_ -#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_FIELD_TRIAL_H_ +#ifndef WEBRTC_SYSTEM_WRAPPERS_INCLUDE_FIELD_TRIAL_H_ +#define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_FIELD_TRIAL_H_ #include <string> @@ -65,4 +65,4 @@ std::string FindFullName(const std::string& name); } // namespace field_trial } // namespace webrtc -#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_FIELD_TRIAL_H_ +#endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_FIELD_TRIAL_H_ diff --git a/webrtc/system_wrappers/include/field_trial_default.h b/webrtc/system_wrappers/include/field_trial_default.h index fafe550dcc..7417ced39d 100644 --- a/webrtc/system_wrappers/include/field_trial_default.h +++ b/webrtc/system_wrappers/include/field_trial_default.h @@ -8,8 +8,8 @@ // be found in the AUTHORS file in the root of the source tree. // -#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_FIELD_TRIAL_DEFAULT_H_ -#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_FIELD_TRIAL_DEFAULT_H_ +#ifndef WEBRTC_SYSTEM_WRAPPERS_INCLUDE_FIELD_TRIAL_DEFAULT_H_ +#define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_FIELD_TRIAL_DEFAULT_H_ namespace webrtc { namespace field_trial { @@ -20,7 +20,9 @@ namespace field_trial { // Note: trials_string must never be destroyed. void InitFieldTrialsFromString(const char* trials_string); +const char* GetFieldTrialString(); + } // namespace field_trial } // namespace webrtc -#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_FIELD_TRIAL_DEFAULT_H_ +#endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_FIELD_TRIAL_DEFAULT_H_ diff --git a/webrtc/system_wrappers/include/file_wrapper.h b/webrtc/system_wrappers/include/file_wrapper.h index 8f4e09f9c9..b32a62f2f9 100644 --- a/webrtc/system_wrappers/include/file_wrapper.h +++ b/webrtc/system_wrappers/include/file_wrapper.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_FILE_WRAPPER_H_ -#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_FILE_WRAPPER_H_ +#ifndef WEBRTC_SYSTEM_WRAPPERS_INCLUDE_FILE_WRAPPER_H_ +#define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_FILE_WRAPPER_H_ #include <stddef.h> #include <stdio.h> @@ -75,4 +75,4 @@ class FileWrapper : public InStream, public OutStream { } // namespace webrtc -#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_FILE_WRAPPER_H_ +#endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_FILE_WRAPPER_H_ diff --git a/webrtc/system_wrappers/include/logcat_trace_context.h b/webrtc/system_wrappers/include/logcat_trace_context.h index 0b74734043..8bb01d8102 100644 --- a/webrtc/system_wrappers/include/logcat_trace_context.h +++ b/webrtc/system_wrappers/include/logcat_trace_context.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_LOGCAT_TRACE_CONTEXT_H_ -#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_LOGCAT_TRACE_CONTEXT_H_ +#ifndef WEBRTC_SYSTEM_WRAPPERS_INCLUDE_LOGCAT_TRACE_CONTEXT_H_ +#define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_LOGCAT_TRACE_CONTEXT_H_ #include "webrtc/system_wrappers/include/trace.h" @@ -32,4 +32,4 @@ class LogcatTraceContext : public webrtc::TraceCallback { } // namespace webrtc -#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_LOGCAT_TRACE_CONTEXT_H_ +#endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_LOGCAT_TRACE_CONTEXT_H_ diff --git a/webrtc/system_wrappers/include/logging.h b/webrtc/system_wrappers/include/logging.h index 41c436b1f3..0089841d4e 100644 --- a/webrtc/system_wrappers/include/logging.h +++ b/webrtc/system_wrappers/include/logging.h @@ -36,20 +36,8 @@ // type (basically, it just doesn't prepend the namespace). // LOG_F(sev) Like LOG(), but includes the name of the current function. -// Additional helper macros added by WebRTC: -// LOG_API is a shortcut for API call logging. Pass in the input parameters of -// the method. For example: -// Foo(int bar, int baz) { -// LOG_API2(bar, baz); -// } -// -// LOG_FERR is a shortcut for logging a failed function call. For example: -// if (!Foo(bar)) { -// LOG_FERR1(LS_WARNING, Foo, bar); -// } - -#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_LOGGING_H_ -#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_LOGGING_H_ +#ifndef WEBRTC_SYSTEM_WRAPPERS_INCLUDE_LOGGING_H_ +#define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_LOGGING_H_ #include <sstream> @@ -131,31 +119,14 @@ class LogMessageVoidify { webrtc::LogMessage(__FILE__, __LINE__, sev).stream() // The _F version prefixes the message with the current function name. -#if (defined(__GNUC__) && defined(_DEBUG)) || defined(WANT_PRETTY_LOG_F) +#if (defined(__GNUC__) && !defined(NDEBUG)) || defined(WANT_PRETTY_LOG_F) #define LOG_F(sev) LOG(sev) << __PRETTY_FUNCTION__ << ": " #else #define LOG_F(sev) LOG(sev) << __FUNCTION__ << ": " #endif -#define LOG_API0() LOG_F(LS_VERBOSE) -#define LOG_API1(v1) LOG_API0() << #v1 << "=" << v1 -#define LOG_API2(v1, v2) LOG_API1(v1) \ - << ", " << #v2 << "=" << v2 -#define LOG_API3(v1, v2, v3) LOG_API2(v1, v2) \ - << ", " << #v3 << "=" << v3 - -#define LOG_FERR0(sev, func) LOG(sev) << #func << " failed" -#define LOG_FERR1(sev, func, v1) LOG_FERR0(sev, func) \ - << ": " << #v1 << "=" << v1 -#define LOG_FERR2(sev, func, v1, v2) LOG_FERR1(sev, func, v1) \ - << ", " << #v2 << "=" << v2 -#define LOG_FERR3(sev, func, v1, v2, v3) LOG_FERR2(sev, func, v1, v2) \ - << ", " << #v3 << "=" << v3 -#define LOG_FERR4(sev, func, v1, v2, v3, v4) LOG_FERR3(sev, func, v1, v2, v3) \ - << ", " << #v4 << "=" << v4 - #endif // LOG } // namespace webrtc -#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_LOGGING_H_ +#endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_LOGGING_H_ diff --git a/webrtc/system_wrappers/include/metrics.h b/webrtc/system_wrappers/include/metrics.h index 7ebe3bde3d..4cd74c5e84 100644 --- a/webrtc/system_wrappers/include/metrics.h +++ b/webrtc/system_wrappers/include/metrics.h @@ -8,11 +8,13 @@ // be found in the AUTHORS file in the root of the source tree. // -#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_METRICS_H_ -#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_METRICS_H_ +#ifndef WEBRTC_SYSTEM_WRAPPERS_INCLUDE_METRICS_H_ +#define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_METRICS_H_ #include <string> +#include "webrtc/base/atomicops.h" +#include "webrtc/base/checks.h" #include "webrtc/common_types.h" // Macros for allowing WebRTC clients (e.g. Chrome) to gather and aggregate @@ -58,54 +60,98 @@ // Macros for adding samples to a named histogram. -// -// NOTE: this is a temporary solution. -// The aim is to mimic the behaviour in Chromium's src/base/metrics/histograms.h -// However as atomics are not supported in webrtc, this is for now a modified -// and temporary solution. Note that the histogram is constructed/found for -// each call. Therefore, for now only use this implementation for metrics -// that do not need to be updated frequently. -// TODO(asapersson): Change implementation when atomics are supported. -// Also consider changing string to const char* when switching to atomics. -// Histogram for counters. -#define RTC_HISTOGRAM_COUNTS_100(name, sample) RTC_HISTOGRAM_COUNTS( \ - name, sample, 1, 100, 50) +// Histogram for counters (exponentially spaced buckets). +#define RTC_HISTOGRAM_COUNTS_100(name, sample) \ + RTC_HISTOGRAM_COUNTS(name, sample, 1, 100, 50) -#define RTC_HISTOGRAM_COUNTS_200(name, sample) RTC_HISTOGRAM_COUNTS( \ - name, sample, 1, 200, 50) +#define RTC_HISTOGRAM_COUNTS_200(name, sample) \ + RTC_HISTOGRAM_COUNTS(name, sample, 1, 200, 50) -#define RTC_HISTOGRAM_COUNTS_1000(name, sample) RTC_HISTOGRAM_COUNTS( \ - name, sample, 1, 1000, 50) +#define RTC_HISTOGRAM_COUNTS_1000(name, sample) \ + RTC_HISTOGRAM_COUNTS(name, sample, 1, 1000, 50) -#define RTC_HISTOGRAM_COUNTS_10000(name, sample) RTC_HISTOGRAM_COUNTS( \ - name, sample, 1, 10000, 50) +#define RTC_HISTOGRAM_COUNTS_10000(name, sample) \ + RTC_HISTOGRAM_COUNTS(name, sample, 1, 10000, 50) -#define RTC_HISTOGRAM_COUNTS_100000(name, sample) RTC_HISTOGRAM_COUNTS( \ - name, sample, 1, 100000, 50) +#define RTC_HISTOGRAM_COUNTS_100000(name, sample) \ + RTC_HISTOGRAM_COUNTS(name, sample, 1, 100000, 50) #define RTC_HISTOGRAM_COUNTS(name, sample, min, max, bucket_count) \ - RTC_HISTOGRAM_COMMON_BLOCK(name, sample, \ - webrtc::metrics::HistogramFactoryGetCounts( \ - name, min, max, bucket_count)) + RTC_HISTOGRAM_COMMON_BLOCK(name, sample, \ + webrtc::metrics::HistogramFactoryGetCounts(name, min, max, bucket_count)) + +// Deprecated. +// TODO(asapersson): Remove. +#define RTC_HISTOGRAM_COUNTS_SPARSE_100(name, sample) \ + RTC_HISTOGRAM_COUNTS_SPARSE(name, sample, 1, 100, 50) + +#define RTC_HISTOGRAM_COUNTS_SPARSE_200(name, sample) \ + RTC_HISTOGRAM_COUNTS_SPARSE(name, sample, 1, 200, 50) + +#define RTC_HISTOGRAM_COUNTS_SPARSE_1000(name, sample) \ + RTC_HISTOGRAM_COUNTS_SPARSE(name, sample, 1, 1000, 50) + +#define RTC_HISTOGRAM_COUNTS_SPARSE_10000(name, sample) \ + RTC_HISTOGRAM_COUNTS_SPARSE(name, sample, 1, 10000, 50) + +#define RTC_HISTOGRAM_COUNTS_SPARSE_100000(name, sample) \ + RTC_HISTOGRAM_COUNTS_SPARSE(name, sample, 1, 100000, 50) + +#define RTC_HISTOGRAM_COUNTS_SPARSE(name, sample, min, max, bucket_count) \ + RTC_HISTOGRAM_COMMON_BLOCK_SLOW(name, sample, \ + webrtc::metrics::HistogramFactoryGetCounts(name, min, max, bucket_count)) -// Histogram for percentage. +// Histogram for percentage (evenly spaced buckets). #define RTC_HISTOGRAM_PERCENTAGE(name, sample) \ - RTC_HISTOGRAM_ENUMERATION(name, sample, 101) + RTC_HISTOGRAM_ENUMERATION(name, sample, 101) -// Histogram for enumerators. +// Deprecated. +// TODO(asapersson): Remove. +#define RTC_HISTOGRAM_PERCENTAGE_SPARSE(name, sample) \ + RTC_HISTOGRAM_ENUMERATION_SPARSE(name, sample, 101) + +// Histogram for enumerators (evenly spaced buckets). // |boundary| should be above the max enumerator sample. #define RTC_HISTOGRAM_ENUMERATION(name, sample, boundary) \ - RTC_HISTOGRAM_COMMON_BLOCK(name, sample, \ - webrtc::metrics::HistogramFactoryGetEnumeration(name, boundary)) + RTC_HISTOGRAM_COMMON_BLOCK(name, sample, \ + webrtc::metrics::HistogramFactoryGetEnumeration(name, boundary)) +// Deprecated. +// TODO(asapersson): Remove. +#define RTC_HISTOGRAM_ENUMERATION_SPARSE(name, sample, boundary) \ + RTC_HISTOGRAM_COMMON_BLOCK_SLOW(name, sample, \ + webrtc::metrics::HistogramFactoryGetEnumeration(name, boundary)) + +// The name of the histogram should not vary. +// TODO(asapersson): Consider changing string to const char*. #define RTC_HISTOGRAM_COMMON_BLOCK(constant_name, sample, \ factory_get_invocation) \ do { \ - webrtc::metrics::Histogram* histogram_pointer = factory_get_invocation; \ + static webrtc::metrics::Histogram* atomic_histogram_pointer = nullptr; \ + webrtc::metrics::Histogram* histogram_pointer = \ + rtc::AtomicOps::AcquireLoadPtr(&atomic_histogram_pointer); \ + if (!histogram_pointer) { \ + histogram_pointer = factory_get_invocation; \ + webrtc::metrics::Histogram* prev_pointer = \ + rtc::AtomicOps::CompareAndSwapPtr( \ + &atomic_histogram_pointer, \ + static_cast<webrtc::metrics::Histogram*>(nullptr), \ + histogram_pointer); \ + RTC_DCHECK(prev_pointer == nullptr || \ + prev_pointer == histogram_pointer); \ + } \ webrtc::metrics::HistogramAdd(histogram_pointer, constant_name, sample); \ } while (0) +// Deprecated. +// The histogram is constructed/found for each call. +// May be used for histograms with infrequent updates. +#define RTC_HISTOGRAM_COMMON_BLOCK_SLOW(name, sample, factory_get_invocation) \ + do { \ + webrtc::metrics::Histogram* histogram_pointer = factory_get_invocation; \ + webrtc::metrics::HistogramAdd(histogram_pointer, name, sample); \ + } while (0) namespace webrtc { namespace metrics { @@ -135,5 +181,5 @@ void HistogramAdd( } // namespace metrics } // namespace webrtc -#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_METRICS_H_ +#endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_METRICS_H_ diff --git a/webrtc/system_wrappers/include/ntp_time.h b/webrtc/system_wrappers/include/ntp_time.h new file mode 100644 index 0000000000..229666e8dd --- /dev/null +++ b/webrtc/system_wrappers/include/ntp_time.h @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. +* +* Use of this source code is governed by a BSD-style license +* that can be found in the LICENSE file in the root of the source +* tree. An additional intellectual property rights grant can be found +* in the file PATENTS. All contributing project authors may +* be found in the AUTHORS file in the root of the source tree. +*/ +#ifndef WEBRTC_SYSTEM_WRAPPERS_INCLUDE_NTP_TIME_H_ +#define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_NTP_TIME_H_ + +#include "webrtc/base/basictypes.h" +#include "webrtc/system_wrappers/include/clock.h" + +namespace webrtc { + +class NtpTime { + public: + NtpTime() : seconds_(0), fractions_(0) {} + explicit NtpTime(const Clock& clock) { + clock.CurrentNtp(seconds_, fractions_); + } + NtpTime(uint32_t seconds, uint32_t fractions) + : seconds_(seconds), fractions_(fractions) {} + + NtpTime(const NtpTime&) = default; + NtpTime& operator=(const NtpTime&) = default; + + void SetCurrent(const Clock& clock) { + clock.CurrentNtp(seconds_, fractions_); + } + void Set(uint32_t seconds, uint32_t fractions) { + seconds_ = seconds; + fractions_ = fractions; + } + void Reset() { + seconds_ = 0; + fractions_ = 0; + } + + int64_t ToMs() const { return Clock::NtpToMs(seconds_, fractions_); } + + // NTP standard (RFC1305, section 3.1) explicitly state value 0/0 is invalid. + bool Valid() const { return !(seconds_ == 0 && fractions_ == 0); } + + uint32_t seconds() const { return seconds_; } + uint32_t fractions() const { return fractions_; } + + private: + uint32_t seconds_; + uint32_t fractions_; +}; + +inline bool operator==(const NtpTime& n1, const NtpTime& n2) { + return n1.seconds() == n2.seconds() && n1.fractions() == n2.fractions(); +} +inline bool operator!=(const NtpTime& n1, const NtpTime& n2) { + return !(n1 == n2); +} + +} // namespace webrtc +#endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_NTP_TIME_H_ diff --git a/webrtc/system_wrappers/include/ref_count.h b/webrtc/system_wrappers/include/ref_count.h index 8ca06cdf6c..3dd335a8da 100644 --- a/webrtc/system_wrappers/include/ref_count.h +++ b/webrtc/system_wrappers/include/ref_count.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef SYSTEM_WRAPPERS_INTERFACE_REF_COUNT_H_ -#define SYSTEM_WRAPPERS_INTERFACE_REF_COUNT_H_ +#ifndef SYSTEM_WRAPPERS_INCLUDE_REF_COUNT_H_ +#define SYSTEM_WRAPPERS_INCLUDE_REF_COUNT_H_ #include "webrtc/system_wrappers/include/atomic32.h" @@ -79,4 +79,4 @@ class RefCountImpl : public T { } // namespace webrtc -#endif // SYSTEM_WRAPPERS_INTERFACE_REF_COUNT_H_ +#endif // SYSTEM_WRAPPERS_INCLUDE_REF_COUNT_H_ diff --git a/webrtc/system_wrappers/include/rtp_to_ntp.h b/webrtc/system_wrappers/include/rtp_to_ntp.h index dfc25cd9e9..0c91928626 100644 --- a/webrtc/system_wrappers/include/rtp_to_ntp.h +++ b/webrtc/system_wrappers/include/rtp_to_ntp.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef SYSTEM_WRAPPERS_INTERFACE_RTP_TO_NTP_H_ -#define SYSTEM_WRAPPERS_INTERFACE_RTP_TO_NTP_H_ +#ifndef SYSTEM_WRAPPERS_INCLUDE_RTP_TO_NTP_H_ +#define SYSTEM_WRAPPERS_INCLUDE_RTP_TO_NTP_H_ #include <list> @@ -47,4 +47,4 @@ int CheckForWrapArounds(uint32_t rtp_timestamp, uint32_t rtcp_rtp_timestamp); } // namespace webrtc -#endif // SYSTEM_WRAPPERS_INTERFACE_RTP_TO_NTP_H_ +#endif // SYSTEM_WRAPPERS_INCLUDE_RTP_TO_NTP_H_ diff --git a/webrtc/system_wrappers/include/rw_lock_wrapper.h b/webrtc/system_wrappers/include/rw_lock_wrapper.h index dbe6d6c7c0..751b6a1df5 100644 --- a/webrtc/system_wrappers/include/rw_lock_wrapper.h +++ b/webrtc/system_wrappers/include/rw_lock_wrapper.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_RW_LOCK_WRAPPER_H_ -#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_RW_LOCK_WRAPPER_H_ +#ifndef WEBRTC_SYSTEM_WRAPPERS_INCLUDE_RW_LOCK_WRAPPER_H_ +#define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_RW_LOCK_WRAPPER_H_ #include "webrtc/base/thread_annotations.h" @@ -65,4 +65,4 @@ class SCOPED_LOCKABLE WriteLockScoped { } // namespace webrtc -#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_RW_LOCK_WRAPPER_H_ +#endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_RW_LOCK_WRAPPER_H_ diff --git a/webrtc/system_wrappers/include/scoped_vector.h b/webrtc/system_wrappers/include/scoped_vector.h index 1e89a9d245..15c3380c8c 100644 --- a/webrtc/system_wrappers/include/scoped_vector.h +++ b/webrtc/system_wrappers/include/scoped_vector.h @@ -10,12 +10,13 @@ // Borrowed from Chromium's src/base/memory/scoped_vector.h. -#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_SCOPED_VECTOR_H_ -#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_SCOPED_VECTOR_H_ +#ifndef WEBRTC_SYSTEM_WRAPPERS_INCLUDE_SCOPED_VECTOR_H_ +#define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_SCOPED_VECTOR_H_ #include <vector> #include "webrtc/base/checks.h" +#include "webrtc/base/deprecation.h" #include "webrtc/system_wrappers/include/stl_util.h" namespace webrtc { @@ -43,9 +44,7 @@ class ScopedVector { ~ScopedVector() { clear(); } // Move construction and assignment. - ScopedVector(ScopedVector&& other) { - *this = static_cast<ScopedVector&&>(other); - } + ScopedVector(ScopedVector&& other) { *this = std::move(other); } ScopedVector& operator=(ScopedVector&& other) { std::swap(v_, other.v_); // The arguments are std::vectors, so std::swap // is the one that we want. @@ -58,7 +57,11 @@ class ScopedVector { ScopedVector& operator=(const ScopedVector& other) = delete; // Get an rvalue reference. (sv.Pass() does the same thing as std::move(sv).) - ScopedVector&& Pass() { return static_cast<ScopedVector&&>(*this); } + // Deprecated; remove in March 2016 (bug 5373). + RTC_DEPRECATED ScopedVector&& Pass() { return DEPRECATED_Pass(); } + ScopedVector&& DEPRECATED_Pass() { + return std::move(*this); + } reference operator[](size_t index) { return v_[index]; } const_reference operator[](size_t index) const { return v_[index]; } @@ -154,4 +157,4 @@ class ScopedVector { } // namespace webrtc -#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_SCOPED_VECTOR_H_ +#endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_SCOPED_VECTOR_H_ diff --git a/webrtc/system_wrappers/include/sleep.h b/webrtc/system_wrappers/include/sleep.h index c0205bf085..e7ed8b32b8 100644 --- a/webrtc/system_wrappers/include/sleep.h +++ b/webrtc/system_wrappers/include/sleep.h @@ -9,8 +9,8 @@ */ // An OS-independent sleep function. -#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_SLEEP_H_ -#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_SLEEP_H_ +#ifndef WEBRTC_SYSTEM_WRAPPERS_INCLUDE_SLEEP_H_ +#define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_SLEEP_H_ namespace webrtc { @@ -21,4 +21,4 @@ void SleepMs(int msecs); } // namespace webrtc -#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_SLEEP_H_ +#endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_SLEEP_H_ diff --git a/webrtc/system_wrappers/include/sort.h b/webrtc/system_wrappers/include/sort.h index da6ff8d52e..5bf2afa8a5 100644 --- a/webrtc/system_wrappers/include/sort.h +++ b/webrtc/system_wrappers/include/sort.h @@ -10,8 +10,8 @@ // Generic unstable sorting routines. -#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_SORT_H_ -#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_SORT_H_ +#ifndef WEBRTC_SYSTEM_WRAPPERS_INCLUDE_SORT_H_ +#define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_SORT_H_ #include "webrtc/common_types.h" #include "webrtc/typedefs.h" @@ -62,4 +62,4 @@ int32_t KeySort(void* data, void* key, uint32_t num_of_elements, } // namespace webrtc -#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_SORT_H_ +#endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_SORT_H_ diff --git a/webrtc/system_wrappers/include/static_instance.h b/webrtc/system_wrappers/include/static_instance.h index fd986b821d..41946d9230 100644 --- a/webrtc/system_wrappers/include/static_instance.h +++ b/webrtc/system_wrappers/include/static_instance.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_STATIC_INSTANCE_H_ -#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_STATIC_INSTANCE_H_ +#ifndef WEBRTC_SYSTEM_WRAPPERS_INCLUDE_STATIC_INSTANCE_H_ +#define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_STATIC_INSTANCE_H_ #include <assert.h> @@ -150,4 +150,4 @@ static T* GetStaticInstance(CountOperation count_operation) { } // namspace webrtc -#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_STATIC_INSTANCE_H_ +#endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_STATIC_INSTANCE_H_ diff --git a/webrtc/system_wrappers/include/stl_util.h b/webrtc/system_wrappers/include/stl_util.h index ebe855fb10..b7a702113f 100644 --- a/webrtc/system_wrappers/include/stl_util.h +++ b/webrtc/system_wrappers/include/stl_util.h @@ -10,8 +10,8 @@ // Borrowed from Chromium's src/base/stl_util.h. -#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_STL_UTIL_H_ -#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_STL_UTIL_H_ +#ifndef WEBRTC_SYSTEM_WRAPPERS_INCLUDE_STL_UTIL_H_ +#define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_STL_UTIL_H_ #include <assert.h> #include <algorithm> @@ -262,4 +262,4 @@ bool STLIncludes(const Arg1& a1, const Arg2& a2) { } // namespace webrtc -#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_STL_UTIL_H_ +#endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_STL_UTIL_H_ diff --git a/webrtc/system_wrappers/include/stringize_macros.h b/webrtc/system_wrappers/include/stringize_macros.h index ab8c43d4e2..9c8e7e9120 100644 --- a/webrtc/system_wrappers/include/stringize_macros.h +++ b/webrtc/system_wrappers/include/stringize_macros.h @@ -15,8 +15,8 @@ // symbols (or their output) and manipulating preprocessor symbols // that define strings. -#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_STRINGIZE_MACROS_H_ -#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_STRINGIZE_MACROS_H_ +#ifndef WEBRTC_SYSTEM_WRAPPERS_INCLUDE_STRINGIZE_MACROS_H_ +#define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_STRINGIZE_MACROS_H_ // This is not very useful as it does not expand defined symbols if // called directly. Use its counterpart without the _NO_EXPANSION @@ -35,4 +35,4 @@ // STRINGIZE(B(y)) produces "myobj->FunctionCall(y)" #define STRINGIZE(x) STRINGIZE_NO_EXPANSION(x) -#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_STRINGIZE_MACROS_H_ +#endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_STRINGIZE_MACROS_H_ diff --git a/webrtc/system_wrappers/include/thread_wrapper.h b/webrtc/system_wrappers/include/thread_wrapper.h deleted file mode 100644 index 742056198a..0000000000 --- a/webrtc/system_wrappers/include/thread_wrapper.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -// System independant wrapper for spawning threads -// Note: the spawned thread will loop over the callback function until stopped. -// Note: The callback function is expected to return every 2 seconds or more -// often. - -#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_THREAD_WRAPPER_H_ -#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_THREAD_WRAPPER_H_ - -#if defined(WEBRTC_WIN) -#include <windows.h> -#endif - -#include "webrtc/base/scoped_ptr.h" -#include "webrtc/common_types.h" -#include "webrtc/typedefs.h" - -namespace webrtc { - -// Callback function that the spawned thread will enter once spawned. -// A return value of false is interpreted as that the function has no -// more work to do and that the thread can be released. -typedef bool(*ThreadRunFunction)(void*); - -enum ThreadPriority { -#ifdef WEBRTC_WIN - kLowPriority = THREAD_PRIORITY_BELOW_NORMAL, - kNormalPriority = THREAD_PRIORITY_NORMAL, - kHighPriority = THREAD_PRIORITY_ABOVE_NORMAL, - kHighestPriority = THREAD_PRIORITY_HIGHEST, - kRealtimePriority = THREAD_PRIORITY_TIME_CRITICAL -#else - kLowPriority = 1, - kNormalPriority = 2, - kHighPriority = 3, - kHighestPriority = 4, - kRealtimePriority = 5 -#endif -}; - -// Represents a simple worker thread. The implementation must be assumed -// to be single threaded, meaning that all methods of the class, must be -// called from the same thread, including instantiation. -// TODO(tommi): There's no need for this to be a virtual interface since there's -// only ever a single implementation of it. -class ThreadWrapper { - public: - virtual ~ThreadWrapper() {} - - // Factory method. Constructor disabled. - // - // func Pointer to a, by user, specified callback function. - // obj Object associated with the thread. Passed in the callback - // function. - // prio Thread priority. May require root/admin rights. - // thread_name NULL terminated thread name, will be visable in the Windows - // debugger. - static rtc::scoped_ptr<ThreadWrapper> CreateThread(ThreadRunFunction func, - void* obj, const char* thread_name); - - // Get the current thread's thread ID. - // NOTE: This is a static method. It returns the id of the calling thread, - // *not* the id of the worker thread that a ThreadWrapper instance represents. - // TODO(tommi): Move outside of the ThreadWrapper class to avoid confusion. - static uint32_t GetThreadId(); - - // Tries to spawns a thread and returns true if that was successful. - // Additionally, it tries to set thread priority according to the priority - // from when CreateThread was called. However, failure to set priority will - // not result in a false return value. - virtual bool Start() = 0; - - // Stops the spawned thread and waits for it to be reclaimed with a timeout - // of two seconds. Will return false if the thread was not reclaimed. - // Multiple tries to Stop are allowed (e.g. to wait longer than 2 seconds). - // It's ok to call Stop() even if the spawned thread has been reclaimed. - virtual bool Stop() = 0; - - // Set the priority of the worker thread. Must be called when thread - // is running. - virtual bool SetPriority(ThreadPriority priority) = 0; -}; - -} // namespace webrtc - -#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_THREAD_WRAPPER_H_ diff --git a/webrtc/system_wrappers/include/tick_util.h b/webrtc/system_wrappers/include/tick_util.h index 0b7890e7c8..52f9b4ae4d 100644 --- a/webrtc/system_wrappers/include/tick_util.h +++ b/webrtc/system_wrappers/include/tick_util.h @@ -11,8 +11,8 @@ // System independant wrapper for polling elapsed time in ms and us. // The implementation works in the tick domain which can be mapped over to the // time domain. -#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_TICK_UTIL_H_ -#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_TICK_UTIL_H_ +#ifndef WEBRTC_SYSTEM_WRAPPERS_INCLUDE_TICK_UTIL_H_ +#define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_TICK_UTIL_H_ #if _WIN32 // Note: The Windows header must always be included before mmsystem.h @@ -56,6 +56,8 @@ class TickTime { static int64_t TicksToMilliseconds(const int64_t ticks); + static int64_t TicksToMicroseconds(const int64_t ticks); + // Returns a TickTime that is ticks later than the passed TickTime. friend TickTime operator+(const TickTime lhs, const int64_t ticks); TickTime& operator+=(const int64_t& ticks); @@ -63,19 +65,9 @@ class TickTime { // Returns a TickInterval that is the difference in ticks beween rhs and lhs. friend TickInterval operator-(const TickTime& lhs, const TickTime& rhs); - // Call to engage the fake clock. This is useful for tests since relying on - // a real clock often makes the test flaky. - static void UseFakeClock(int64_t start_millisecond); - - // Advance the fake clock. Must be called after UseFakeClock. - static void AdvanceFakeClock(int64_t milliseconds); - private: static int64_t QueryOsForTicks(); - static bool use_fake_clock_; - static int64_t fake_ticks_; - int64_t ticks_; }; @@ -83,6 +75,7 @@ class TickTime { class TickInterval { public: TickInterval(); + explicit TickInterval(int64_t interval); int64_t Milliseconds() const; int64_t Microseconds() const; @@ -103,8 +96,6 @@ class TickInterval { friend bool operator>=(const TickInterval& lhs, const TickInterval& rhs); private: - explicit TickInterval(int64_t interval); - friend class TickTime; friend TickInterval operator-(const TickTime& lhs, const TickTime& rhs); @@ -112,6 +103,14 @@ class TickInterval { int64_t interval_; }; +inline int64_t TickInterval::Milliseconds() const { + return TickTime::TicksToMilliseconds(interval_); +} + +inline int64_t TickInterval::Microseconds() const { + return TickTime::TicksToMicroseconds(interval_); +} + inline TickInterval operator+(const TickInterval& lhs, const TickInterval& rhs) { return TickInterval(lhs.interval_ + rhs.interval_); @@ -157,82 +156,13 @@ inline TickTime::TickTime(int64_t ticks) } inline TickTime TickTime::Now() { - if (use_fake_clock_) - return TickTime(fake_ticks_); - else - return TickTime(QueryOsForTicks()); -} - -inline int64_t TickTime::MillisecondTimestamp() { - int64_t ticks = TickTime::Now().Ticks(); -#if _WIN32 -#ifdef USE_QUERY_PERFORMANCE_COUNTER - LARGE_INTEGER qpfreq; - QueryPerformanceFrequency(&qpfreq); - return (ticks * 1000) / qpfreq.QuadPart; -#else - return ticks; -#endif -#elif defined(WEBRTC_LINUX) || defined(WEBRTC_MAC) - return ticks / 1000000LL; -#else - return ticks / 1000LL; -#endif -} - -inline int64_t TickTime::MicrosecondTimestamp() { - int64_t ticks = TickTime::Now().Ticks(); -#if _WIN32 -#ifdef USE_QUERY_PERFORMANCE_COUNTER - LARGE_INTEGER qpfreq; - QueryPerformanceFrequency(&qpfreq); - return (ticks * 1000) / (qpfreq.QuadPart / 1000); -#else - return ticks * 1000LL; -#endif -#elif defined(WEBRTC_LINUX) || defined(WEBRTC_MAC) - return ticks / 1000LL; -#else - return ticks; -#endif + return TickTime(QueryOsForTicks()); } inline int64_t TickTime::Ticks() const { return ticks_; } -inline int64_t TickTime::MillisecondsToTicks(const int64_t ms) { -#if _WIN32 -#ifdef USE_QUERY_PERFORMANCE_COUNTER - LARGE_INTEGER qpfreq; - QueryPerformanceFrequency(&qpfreq); - return (qpfreq.QuadPart * ms) / 1000; -#else - return ms; -#endif -#elif defined(WEBRTC_LINUX) || defined(WEBRTC_MAC) - return ms * 1000000LL; -#else - return ms * 1000LL; -#endif -} - -inline int64_t TickTime::TicksToMilliseconds(const int64_t ticks) { -#if _WIN32 -#ifdef USE_QUERY_PERFORMANCE_COUNTER - LARGE_INTEGER qpfreq; - QueryPerformanceFrequency(&qpfreq); - return (ticks * 1000) / qpfreq.QuadPart; -#else - return ticks; -#endif -#elif defined(WEBRTC_LINUX) || defined(WEBRTC_MAC) - return ticks / 1000000LL; -#else - return ticks / 1000LL; -#endif -} - inline TickTime& TickTime::operator+=(const int64_t& ticks) { ticks_ += ticks; return *this; @@ -245,44 +175,6 @@ inline TickInterval::TickInterval(const int64_t interval) : interval_(interval) { } -inline int64_t TickInterval::Milliseconds() const { -#if _WIN32 -#ifdef USE_QUERY_PERFORMANCE_COUNTER - LARGE_INTEGER qpfreq; - QueryPerformanceFrequency(&qpfreq); - return (interval_ * 1000) / qpfreq.QuadPart; -#else - // interval_ is in ms - return interval_; -#endif -#elif defined(WEBRTC_LINUX) || defined(WEBRTC_MAC) - // interval_ is in ns - return interval_ / 1000000; -#else - // interval_ is usecs - return interval_ / 1000; -#endif -} - -inline int64_t TickInterval::Microseconds() const { -#if _WIN32 -#ifdef USE_QUERY_PERFORMANCE_COUNTER - LARGE_INTEGER qpfreq; - QueryPerformanceFrequency(&qpfreq); - return (interval_ * 1000000) / qpfreq.QuadPart; -#else - // interval_ is in ms - return interval_ * 1000LL; -#endif -#elif defined(WEBRTC_LINUX) || defined(WEBRTC_MAC) - // interval_ is in ns - return interval_ / 1000; -#else - // interval_ is usecs - return interval_; -#endif -} - inline TickInterval& TickInterval::operator+=(const TickInterval& rhs) { interval_ += rhs.interval_; return *this; @@ -295,4 +187,4 @@ inline TickInterval& TickInterval::operator-=(const TickInterval& rhs) { } // namespace webrtc -#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_TICK_UTIL_H_ +#endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_TICK_UTIL_H_ diff --git a/webrtc/system_wrappers/include/timestamp_extrapolator.h b/webrtc/system_wrappers/include/timestamp_extrapolator.h index b8a8b05d97..d9c5c6fb37 100644 --- a/webrtc/system_wrappers/include/timestamp_extrapolator.h +++ b/webrtc/system_wrappers/include/timestamp_extrapolator.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef SYSTEM_WRAPPERS_INTERFACE_TIMESTAMP_EXTRAPOLATOR_H_ -#define SYSTEM_WRAPPERS_INTERFACE_TIMESTAMP_EXTRAPOLATOR_H_ +#ifndef SYSTEM_WRAPPERS_INCLUDE_TIMESTAMP_EXTRAPOLATOR_H_ +#define SYSTEM_WRAPPERS_INCLUDE_TIMESTAMP_EXTRAPOLATOR_H_ #include "webrtc/system_wrappers/include/rw_lock_wrapper.h" #include "webrtc/typedefs.h" @@ -53,4 +53,4 @@ private: } // namespace webrtc -#endif // SYSTEM_WRAPPERS_INTERFACE_TIMESTAMP_EXTRAPOLATOR_H_ +#endif // SYSTEM_WRAPPERS_INCLUDE_TIMESTAMP_EXTRAPOLATOR_H_ diff --git a/webrtc/system_wrappers/include/trace.h b/webrtc/system_wrappers/include/trace.h index e63b603d1b..25a3d746c4 100644 --- a/webrtc/system_wrappers/include/trace.h +++ b/webrtc/system_wrappers/include/trace.h @@ -13,8 +13,8 @@ * messages. Apply filtering to avoid that. */ -#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_TRACE_H_ -#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_TRACE_H_ +#ifndef WEBRTC_SYSTEM_WRAPPERS_INCLUDE_TRACE_H_ +#define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_TRACE_H_ #include "webrtc/common_types.h" #include "webrtc/typedefs.h" @@ -89,4 +89,4 @@ class Trace { } // namespace webrtc -#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_TRACE_H_ +#endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_TRACE_H_ diff --git a/webrtc/system_wrappers/include/utf_util_win.h b/webrtc/system_wrappers/include/utf_util_win.h index cc48fd254d..0e3f2d01c6 100644 --- a/webrtc/system_wrappers/include/utf_util_win.h +++ b/webrtc/system_wrappers/include/utf_util_win.h @@ -10,8 +10,8 @@ // Conversion functions for UTF-8 and UTF-16 strings on Windows. // Duplicated from talk/base/win32.h. -#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_UTF_UTIL_H_ -#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_UTF_UTIL_H_ +#ifndef WEBRTC_SYSTEM_WRAPPERS_INCLUDE_UTF_UTIL_H_ +#define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_UTF_UTIL_H_ #ifdef WIN32 #include <windows.h> @@ -54,4 +54,4 @@ inline std::string ToUtf8(const std::wstring& wstr) { } // namespace webrtc #endif // WIN32 -#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_UTF_UTIL_H_ +#endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_UTF_UTIL_H_ |