summaryrefslogtreecommitdiff
path: root/overrides/webrtc
diff options
context:
space:
mode:
authorhenrike@webrtc.org <henrike@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d>2014-05-12 18:03:09 +0000
committerhenrike@webrtc.org <henrike@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d>2014-05-12 18:03:09 +0000
commit04e6703292802f1f2dffe5f1486fd4a78b0abc5f (patch)
treeaf0acfd5cebfb60e88de0d05b9193a610500683b /overrides/webrtc
parent7f5e2973967c6ef5859334eb4ccac2c7c0020565 (diff)
downloadwebrtc-04e6703292802f1f2dffe5f1486fd4a78b0abc5f.tar.gz
Adds a modified copy of talk/base to webrtc/base. It is the first step in migrating talk/base to webrtc/base.
BUG=N/A R=andrew@webrtc.org, wu@webrtc.org Review URL: https://webrtc-codereview.appspot.com/12199004 git-svn-id: http://webrtc.googlecode.com/svn/trunk/webrtc@6107 4adac7df-926f-26a2-2b94-8c16560cd09d
Diffstat (limited to 'overrides/webrtc')
-rw-r--r--overrides/webrtc/base/basictypes.h108
-rw-r--r--overrides/webrtc/base/constructormagic.h20
-rw-r--r--overrides/webrtc/base/logging.cc317
-rw-r--r--overrides/webrtc/base/logging.h221
-rw-r--r--overrides/webrtc/base/win32socketinit.cc28
5 files changed, 694 insertions, 0 deletions
diff --git a/overrides/webrtc/base/basictypes.h b/overrides/webrtc/base/basictypes.h
new file mode 100644
index 00000000..cd93d06e
--- /dev/null
+++ b/overrides/webrtc/base/basictypes.h
@@ -0,0 +1,108 @@
+/*
+ * Copyright 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 overrides the inclusion of webrtc/base/basictypes.h to remove
+// collisions with Chromium's base/basictypes.h. We then add back a few
+// items that Chromium's version doesn't provide, but libjingle expects.
+
+#ifndef OVERRIDES_WEBRTC_BASE_BASICTYPES_H__
+#define OVERRIDES_WEBRTC_BASE_BASICTYPES_H__
+
+#include "base/basictypes.h"
+#include "build/build_config.h"
+
+#ifndef INT_TYPES_DEFINED
+#define INT_TYPES_DEFINED
+
+#ifdef COMPILER_MSVC
+#if _MSC_VER >= 1600
+#include <stdint.h>
+#else
+typedef unsigned __int64 uint64;
+typedef __int64 int64;
+#endif
+#ifndef INT64_C
+#define INT64_C(x) x ## I64
+#endif
+#ifndef UINT64_C
+#define UINT64_C(x) x ## UI64
+#endif
+#define INT64_F "I64"
+#else // COMPILER_MSVC
+#ifndef INT64_C
+#define INT64_C(x) x ## LL
+#endif
+#ifndef UINT64_C
+#define UINT64_C(x) x ## ULL
+#endif
+#ifndef INT64_F
+#define INT64_F "ll"
+#endif
+#endif // COMPILER_MSVC
+#endif // INT_TYPES_DEFINED
+
+// Detect compiler is for x86 or x64.
+#if defined(__x86_64__) || defined(_M_X64) || \
+ defined(__i386__) || defined(_M_IX86)
+#define CPU_X86 1
+#endif
+// Detect compiler is for arm.
+#if defined(__arm__) || defined(_M_ARM)
+#define CPU_ARM 1
+#endif
+#if defined(CPU_X86) && defined(CPU_ARM)
+#error CPU_X86 and CPU_ARM both defined.
+#endif
+#if !defined(ARCH_CPU_BIG_ENDIAN) && !defined(ARCH_CPU_LITTLE_ENDIAN)
+// x86, arm or GCC provided __BYTE_ORDER__ macros
+#if CPU_X86 || CPU_ARM || \
+ (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
+#define ARCH_CPU_LITTLE_ENDIAN
+#elif defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#define ARCH_CPU_BIG_ENDIAN
+#else
+#error ARCH_CPU_BIG_ENDIAN or ARCH_CPU_LITTLE_ENDIAN should be defined.
+#endif
+#endif
+#if defined(ARCH_CPU_BIG_ENDIAN) && defined(ARCH_CPU_LITTLE_ENDIAN)
+#error ARCH_CPU_BIG_ENDIAN and ARCH_CPU_LITTLE_ENDIAN both defined.
+#endif
+
+#if defined(WEBRTC_WIN)
+typedef int socklen_t;
+#endif
+
+namespace rtc {
+template<class T> inline T _min(T a, T b) { return (a > b) ? b : a; }
+template<class T> inline T _max(T a, T b) { return (a < b) ? b : a; }
+
+// For wait functions that take a number of milliseconds, kForever indicates
+// unlimited time.
+const int kForever = -1;
+}
+
+#if defined(WEBRTC_WIN)
+#if _MSC_VER < 1700
+ #define alignof(t) __alignof(t)
+#endif
+#else // !WEBRTC_WIN
+#define alignof(t) __alignof__(t)
+#endif // !WEBRTC_WIN
+#define IS_ALIGNED(p, a) (0==(reinterpret_cast<uintptr_t>(p) & ((a)-1)))
+#define ALIGNP(p, t) \
+ (reinterpret_cast<uint8*>(((reinterpret_cast<uintptr_t>(p) + \
+ ((t)-1)) & ~((t)-1))))
+
+// LIBJINGLE_DEFINE_STATIC_LOCAL() is a libjingle's copy
+// of CR_DEFINE_STATIC_LOCAL().
+#define LIBJINGLE_DEFINE_STATIC_LOCAL(type, name, arguments) \
+ CR_DEFINE_STATIC_LOCAL(type, name, arguments)
+
+#endif // OVERRIDES_WEBRTC_BASE_BASICTYPES_H__
diff --git a/overrides/webrtc/base/constructormagic.h b/overrides/webrtc/base/constructormagic.h
new file mode 100644
index 00000000..bb89f91f
--- /dev/null
+++ b/overrides/webrtc/base/constructormagic.h
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2009 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 overrides the inclusion of webrtc/base/constructormagic.h
+// We do this because constructor magic defines DISALLOW_EVIL_CONSTRUCTORS,
+// but we want to use the version from Chromium.
+
+#ifndef OVERRIDES_WEBRTC_BASE_CONSTRUCTORMAGIC_H__
+#define OVERRIDES_WEBRTC_BASE_CONSTRUCTORMAGIC_H__
+
+#include "base/basictypes.h"
+
+#endif // OVERRIDES_WEBRTC_BASE_CONSTRUCTORMAGIC_H__
diff --git a/overrides/webrtc/base/logging.cc b/overrides/webrtc/base/logging.cc
new file mode 100644
index 00000000..2e43c501
--- /dev/null
+++ b/overrides/webrtc/base/logging.cc
@@ -0,0 +1,317 @@
+/*
+ * Copyright 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.
+ */
+
+#include "third_party/webrtc/overrides/webrtc/base/logging.h"
+
+#if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
+#include <CoreServices/CoreServices.h>
+#endif // OS_MACOSX
+
+#include <iomanip>
+
+#include "base/atomicops.h"
+#include "base/strings/string_util.h"
+#include "base/threading/platform_thread.h"
+#include "third_party/webrtc/base/ipaddress.h"
+#include "third_party/webrtc/base/stream.h"
+#include "third_party/webrtc/base/stringencode.h"
+#include "third_party/webrtc/base/stringutils.h"
+#include "third_party/webrtc/base/timeutils.h"
+
+// From this file we can't use VLOG since it expands into usage of the __FILE__
+// macro (for correct filtering). The actual logging call from DIAGNOSTIC_LOG in
+// ~DiagnosticLogMessage. Note that the second parameter to the LAZY_STREAM
+// macro is true since the filter check has already been done for
+// DIAGNOSTIC_LOG.
+#define LOG_LAZY_STREAM_DIRECT(file_name, line_number, sev) \
+ LAZY_STREAM(logging::LogMessage(file_name, line_number, \
+ -sev).stream(), true)
+
+namespace rtc {
+
+void (*g_logging_delegate_function)(const std::string&) = NULL;
+void (*g_extra_logging_init_function)(
+ void (*logging_delegate_function)(const std::string&)) = NULL;
+#ifndef NDEBUG
+COMPILE_ASSERT(sizeof(base::subtle::Atomic32) == sizeof(base::PlatformThreadId),
+ atomic32_not_same_size_as_platformthreadid);
+base::subtle::Atomic32 g_init_logging_delegate_thread_id = 0;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// Constant Labels
+/////////////////////////////////////////////////////////////////////////////
+
+const char* FindLabel(int value, const ConstantLabel entries[]) {
+ for (int i = 0; entries[i].label; ++i) {
+ if (value == entries[i].value) return entries[i].label;
+ }
+ return 0;
+}
+
+std::string ErrorName(int err, const ConstantLabel* err_table) {
+ if (err == 0)
+ return "No error";
+
+ if (err_table != 0) {
+ if (const char * value = FindLabel(err, err_table))
+ return value;
+ }
+
+ char buffer[16];
+ base::snprintf(buffer, sizeof(buffer), "0x%08x", err);
+ return buffer;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Log helper functions
+/////////////////////////////////////////////////////////////////////////////
+
+// Generates extra information for LOG_E.
+static std::string GenerateExtra(LogErrorContext err_ctx,
+ int err,
+ const char* module) {
+ if (err_ctx != ERRCTX_NONE) {
+ std::ostringstream tmp;
+ tmp << ": ";
+ tmp << "[0x" << std::setfill('0') << std::hex << std::setw(8) << err << "]";
+ switch (err_ctx) {
+ case ERRCTX_ERRNO:
+ tmp << " " << strerror(err);
+ break;
+#if defined(WEBRTC_WIN)
+ case ERRCTX_HRESULT: {
+ char msgbuf[256];
+ DWORD flags = FORMAT_MESSAGE_FROM_SYSTEM;
+ HMODULE hmod = GetModuleHandleA(module);
+ if (hmod)
+ flags |= FORMAT_MESSAGE_FROM_HMODULE;
+ if (DWORD len = FormatMessageA(
+ flags, hmod, err,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ msgbuf, sizeof(msgbuf) / sizeof(msgbuf[0]), NULL)) {
+ while ((len > 0) &&
+ isspace(static_cast<unsigned char>(msgbuf[len-1]))) {
+ msgbuf[--len] = 0;
+ }
+ tmp << " " << msgbuf;
+ }
+ break;
+ }
+#endif // OS_WIN
+#if defined(WEBRTC_IOS)
+ case ERRCTX_OSSTATUS:
+ tmp << " " << "Unknown LibJingle error: " << err;
+ break;
+#elif defined(WEBRTC_MAC)
+ case ERRCTX_OSSTATUS: {
+ tmp << " " << nonnull(GetMacOSStatusErrorString(err), "Unknown error");
+ if (const char* desc = GetMacOSStatusCommentString(err)) {
+ tmp << ": " << desc;
+ }
+ break;
+ }
+#endif // OS_MACOSX
+ default:
+ break;
+ }
+ return tmp.str();
+ }
+ return "";
+}
+
+DiagnosticLogMessage::DiagnosticLogMessage(const char* file,
+ int line,
+ LoggingSeverity severity,
+ bool log_to_chrome,
+ LogErrorContext err_ctx,
+ int err)
+ : file_name_(file),
+ line_(line),
+ severity_(severity),
+ log_to_chrome_(log_to_chrome) {
+ extra_ = GenerateExtra(err_ctx, err, NULL);
+}
+
+DiagnosticLogMessage::DiagnosticLogMessage(const char* file,
+ int line,
+ LoggingSeverity severity,
+ bool log_to_chrome,
+ LogErrorContext err_ctx,
+ int err,
+ const char* module)
+ : file_name_(file),
+ line_(line),
+ severity_(severity),
+ log_to_chrome_(log_to_chrome) {
+ extra_ = GenerateExtra(err_ctx, err, module);
+}
+
+DiagnosticLogMessage::~DiagnosticLogMessage() {
+ print_stream_ << extra_;
+ const std::string& str = print_stream_.str();
+ if (log_to_chrome_)
+ LOG_LAZY_STREAM_DIRECT(file_name_, line_, severity_) << str;
+ if (g_logging_delegate_function && severity_ <= LS_INFO) {
+ g_logging_delegate_function(str);
+ }
+}
+
+// Note: this function is a copy from the overriden libjingle implementation.
+void LogMultiline(LoggingSeverity level, const char* label, bool input,
+ const void* data, size_t len, bool hex_mode,
+ LogMultilineState* state) {
+ if (!LOG_CHECK_LEVEL_V(level))
+ return;
+
+ const char * direction = (input ? " << " : " >> ");
+
+ // NULL data means to flush our count of unprintable characters.
+ if (!data) {
+ if (state && state->unprintable_count_[input]) {
+ LOG_V(level) << label << direction << "## "
+ << state->unprintable_count_[input]
+ << " consecutive unprintable ##";
+ state->unprintable_count_[input] = 0;
+ }
+ return;
+ }
+
+ // The ctype classification functions want unsigned chars.
+ const unsigned char* udata = static_cast<const unsigned char*>(data);
+
+ if (hex_mode) {
+ const size_t LINE_SIZE = 24;
+ char hex_line[LINE_SIZE * 9 / 4 + 2], asc_line[LINE_SIZE + 1];
+ while (len > 0) {
+ memset(asc_line, ' ', sizeof(asc_line));
+ memset(hex_line, ' ', sizeof(hex_line));
+ size_t line_len = _min(len, LINE_SIZE);
+ for (size_t i = 0; i < line_len; ++i) {
+ unsigned char ch = udata[i];
+ asc_line[i] = isprint(ch) ? ch : '.';
+ hex_line[i*2 + i/4] = hex_encode(ch >> 4);
+ hex_line[i*2 + i/4 + 1] = hex_encode(ch & 0xf);
+ }
+ asc_line[sizeof(asc_line)-1] = 0;
+ hex_line[sizeof(hex_line)-1] = 0;
+ LOG_V(level) << label << direction
+ << asc_line << " " << hex_line << " ";
+ udata += line_len;
+ len -= line_len;
+ }
+ return;
+ }
+
+ size_t consecutive_unprintable = state ? state->unprintable_count_[input] : 0;
+
+ const unsigned char* end = udata + len;
+ while (udata < end) {
+ const unsigned char* line = udata;
+ const unsigned char* end_of_line = strchrn<unsigned char>(udata,
+ end - udata,
+ '\n');
+ if (!end_of_line) {
+ udata = end_of_line = end;
+ } else {
+ udata = end_of_line + 1;
+ }
+
+ bool is_printable = true;
+
+ // If we are in unprintable mode, we need to see a line of at least
+ // kMinPrintableLine characters before we'll switch back.
+ const ptrdiff_t kMinPrintableLine = 4;
+ if (consecutive_unprintable && ((end_of_line - line) < kMinPrintableLine)) {
+ is_printable = false;
+ } else {
+ // Determine if the line contains only whitespace and printable
+ // characters.
+ bool is_entirely_whitespace = true;
+ for (const unsigned char* pos = line; pos < end_of_line; ++pos) {
+ if (isspace(*pos))
+ continue;
+ is_entirely_whitespace = false;
+ if (!isprint(*pos)) {
+ is_printable = false;
+ break;
+ }
+ }
+ // Treat an empty line following unprintable data as unprintable.
+ if (consecutive_unprintable && is_entirely_whitespace) {
+ is_printable = false;
+ }
+ }
+ if (!is_printable) {
+ consecutive_unprintable += (udata - line);
+ continue;
+ }
+ // Print out the current line, but prefix with a count of prior unprintable
+ // characters.
+ if (consecutive_unprintable) {
+ LOG_V(level) << label << direction << "## " << consecutive_unprintable
+ << " consecutive unprintable ##";
+ consecutive_unprintable = 0;
+ }
+ // Strip off trailing whitespace.
+ while ((end_of_line > line) && isspace(*(end_of_line-1))) {
+ --end_of_line;
+ }
+ // Filter out any private data
+ std::string substr(reinterpret_cast<const char*>(line), end_of_line - line);
+ std::string::size_type pos_private = substr.find("Email");
+ if (pos_private == std::string::npos) {
+ pos_private = substr.find("Passwd");
+ }
+ if (pos_private == std::string::npos) {
+ LOG_V(level) << label << direction << substr;
+ } else {
+ LOG_V(level) << label << direction << "## omitted for privacy ##";
+ }
+ }
+
+ if (state) {
+ state->unprintable_count_[input] = consecutive_unprintable;
+ }
+}
+
+void InitDiagnosticLoggingDelegateFunction(
+ void (*delegate)(const std::string&)) {
+#ifndef NDEBUG
+ // Ensure that this function is always called from the same thread.
+ base::subtle::NoBarrier_CompareAndSwap(&g_init_logging_delegate_thread_id, 0,
+ static_cast<base::subtle::Atomic32>(base::PlatformThread::CurrentId()));
+ DCHECK_EQ(g_init_logging_delegate_thread_id,
+ base::PlatformThread::CurrentId());
+#endif
+ CHECK(delegate);
+ // This function may be called with the same argument several times if the
+ // page is reloaded or there are several PeerConnections on one page with
+ // logging enabled. This is OK, we simply don't have to do anything.
+ if (delegate == g_logging_delegate_function)
+ return;
+ CHECK(!g_logging_delegate_function);
+#ifdef NDEBUG
+ IPAddress::set_strip_sensitive(true);
+#endif
+ g_logging_delegate_function = delegate;
+
+ if (g_extra_logging_init_function)
+ g_extra_logging_init_function(delegate);
+}
+
+void SetExtraLoggingInit(
+ void (*function)(void (*delegate)(const std::string&))) {
+ CHECK(function);
+ CHECK(!g_extra_logging_init_function);
+ g_extra_logging_init_function = function;
+}
+
+} // namespace rtc
diff --git a/overrides/webrtc/base/logging.h b/overrides/webrtc/base/logging.h
new file mode 100644
index 00000000..d8dfca2c
--- /dev/null
+++ b/overrides/webrtc/base/logging.h
@@ -0,0 +1,221 @@
+/*
+ * Copyright 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 overrides the logging macros in libjingle (webrtc/base/logging.h).
+// Instead of using libjingle's logging implementation, the libjingle macros are
+// mapped to the corresponding base/logging.h macro (chromium's VLOG).
+// If this file is included outside of libjingle (e.g. in wrapper code) it
+// should be included after base/logging.h (if any) or compiler error or
+// unexpected behavior may occur (macros that have the same name in libjingle as
+// in chromium will use the libjingle definition if this file is included
+// first).
+
+// Setting the LoggingSeverity (and lower) that should be written to file should
+// be done via command line by specifying the flags:
+// --vmodule or --v please see base/logging.h for details on how to use them.
+// Specifying what file to write to is done using InitLogging also in
+// base/logging.h.
+
+// The macros and classes declared in here are not described as they are
+// NOT TO BE USED outside of libjingle.
+
+#ifndef THIRD_PARTY_LIBJINGLE_OVERRIDES_WEBRTC_BASE_LOGGING_H_
+#define THIRD_PARTY_LIBJINGLE_OVERRIDES_WEBRTC_BASE_LOGGING_H_
+
+#include <sstream>
+#include <string>
+
+#include "base/logging.h"
+#include "third_party/webrtc/base/scoped_ref_ptr.h"
+
+namespace rtc {
+
+///////////////////////////////////////////////////////////////////////////////
+// ConstantLabel can be used to easily generate string names from constant
+// values. This can be useful for logging descriptive names of error messages.
+// Usage:
+// const ConstantLabel LIBRARY_ERRORS[] = {
+// KLABEL(SOME_ERROR),
+// KLABEL(SOME_OTHER_ERROR),
+// ...
+// LASTLABEL
+// }
+//
+// int err = LibraryFunc();
+// LOG(LS_ERROR) << "LibraryFunc returned: "
+// << ErrorName(err, LIBRARY_ERRORS);
+
+struct ConstantLabel {
+ int value;
+ const char* label;
+};
+#define KLABEL(x) { x, #x }
+#define LASTLABEL { 0, 0 }
+
+const char* FindLabel(int value, const ConstantLabel entries[]);
+std::string ErrorName(int err, const ConstantLabel* err_table);
+
+//////////////////////////////////////////////////////////////////////
+// Note that the non-standard LoggingSeverity aliases exist because they are
+// still in broad use. The meanings of the levels are:
+// LS_SENSITIVE: Information which should only be logged with the consent
+// of the user, due to privacy concerns.
+// LS_VERBOSE: This level is for data which we do not want to appear in the
+// normal debug log, but should appear in diagnostic logs.
+// LS_INFO: Chatty level used in debugging for all sorts of things, the default
+// in debug builds.
+// LS_WARNING: Something that may warrant investigation.
+// LS_ERROR: Something that should not have occurred.
+// Note that LoggingSeverity is mapped over to chromiums verbosity levels where
+// anything lower than or equal to the current verbosity level is written to
+// file which is the opposite of logging severity in libjingle where higher
+// severity numbers than or equal to the current severity level are written to
+// file. Also, note that the values are explicitly defined here for convenience
+// since the command line flag must be set using numerical values.
+enum LoggingSeverity { LS_ERROR = 1,
+ LS_WARNING = 2,
+ LS_INFO = 3,
+ LS_VERBOSE = 4,
+ LS_SENSITIVE = 5,
+ INFO = LS_INFO,
+ WARNING = LS_WARNING,
+ LERROR = LS_ERROR };
+
+// LogErrorContext assists in interpreting the meaning of an error value.
+enum LogErrorContext {
+ ERRCTX_NONE,
+ ERRCTX_ERRNO, // System-local errno
+ ERRCTX_HRESULT, // Windows HRESULT
+ ERRCTX_OSSTATUS, // MacOS OSStatus
+
+ // Abbreviations for LOG_E macro
+ ERRCTX_EN = ERRCTX_ERRNO, // LOG_E(sev, EN, x)
+ ERRCTX_HR = ERRCTX_HRESULT, // LOG_E(sev, HR, x)
+ ERRCTX_OS = ERRCTX_OSSTATUS, // LOG_E(sev, OS, x)
+};
+
+// Class that writes a log message to the logging delegate ("WebRTC logging
+// stream" in Chrome) and to Chrome's logging stream.
+class DiagnosticLogMessage {
+ public:
+ DiagnosticLogMessage(const char* file, int line, LoggingSeverity severity,
+ bool log_to_chrome, LogErrorContext err_ctx, int err);
+ DiagnosticLogMessage(const char* file, int line, LoggingSeverity severity,
+ bool log_to_chrome, LogErrorContext err_ctx, int err,
+ const char* module);
+ ~DiagnosticLogMessage();
+
+ void CreateTimestamp();
+
+ std::ostream& stream() { return print_stream_; }
+
+ private:
+ const char* file_name_;
+ const int line_;
+ const LoggingSeverity severity_;
+ const bool log_to_chrome_;
+
+ std::string extra_;
+
+ std::ostringstream print_stream_;
+};
+
+// This class is used to explicitly ignore values in the conditional
+// logging macros. This avoids compiler warnings like "value computed
+// is not used" and "statement has no effect".
+class LogMessageVoidify {
+ public:
+ LogMessageVoidify() { }
+ // This has to be an operator with a precedence lower than << but
+ // higher than ?:
+ void operator&(std::ostream&) { }
+};
+
+//////////////////////////////////////////////////////////////////////
+// Logging Helpers
+//////////////////////////////////////////////////////////////////////
+
+class LogMultilineState {
+ public:
+ size_t unprintable_count_[2];
+ LogMultilineState() {
+ unprintable_count_[0] = unprintable_count_[1] = 0;
+ }
+};
+
+// When possible, pass optional state variable to track various data across
+// multiple calls to LogMultiline. Otherwise, pass NULL.
+void LogMultiline(LoggingSeverity level, const char* label, bool input,
+ const void* data, size_t len, bool hex_mode,
+ LogMultilineState* state);
+
+// TODO(grunell): Change name to InitDiagnosticLoggingDelegate or
+// InitDiagnosticLogging. Change also in init_webrtc.h/cc.
+// TODO(grunell): typedef the delegate function.
+void InitDiagnosticLoggingDelegateFunction(
+ void (*delegate)(const std::string&));
+
+void SetExtraLoggingInit(
+ void (*function)(void (*delegate)(const std::string&)));
+} // namespace rtc
+
+//////////////////////////////////////////////////////////////////////
+// Libjingle macros which are mapped over to their VLOG equivalent in
+// base/logging.h
+//////////////////////////////////////////////////////////////////////
+
+#if defined(LOGGING_INSIDE_WEBRTC)
+
+#define DIAGNOSTIC_LOG(sev, ctx, err, ...) \
+ rtc::DiagnosticLogMessage( \
+ __FILE__, __LINE__, sev, VLOG_IS_ON(sev), \
+ rtc::ERRCTX_ ## ctx, err, ##__VA_ARGS__).stream()
+
+#define LOG_CHECK_LEVEL(sev) VLOG_IS_ON(rtc::sev)
+#define LOG_CHECK_LEVEL_V(sev) VLOG_IS_ON(sev)
+
+#define LOG_V(sev) DIAGNOSTIC_LOG(sev, NONE, 0)
+#undef LOG
+#define LOG(sev) DIAGNOSTIC_LOG(rtc::sev, NONE, 0)
+
+// The _F version prefixes the message with the current function name.
+#if defined(__GNUC__) && defined(_DEBUG)
+#define LOG_F(sev) LOG(sev) << __PRETTY_FUNCTION__ << ": "
+#else
+#define LOG_F(sev) LOG(sev) << __FUNCTION__ << ": "
+#endif
+
+#define LOG_E(sev, ctx, err, ...) \
+ DIAGNOSTIC_LOG(rtc::sev, ctx, err, ##__VA_ARGS__)
+
+#undef LOG_ERRNO_EX
+#define LOG_ERRNO_EX(sev, err) LOG_E(sev, ERRNO, err)
+#undef LOG_ERRNO
+#define LOG_ERRNO(sev) LOG_ERRNO_EX(sev, errno)
+
+#if defined(WEBRTC_WIN)
+#define LOG_GLE_EX(sev, err) LOG_E(sev, HRESULT, err)
+#define LOG_GLE(sev) LOG_GLE_EX(sev, GetLastError())
+#define LOG_GLEM(sev, mod) LOG_E(sev, HRESULT, GetLastError(), mod)
+#define LOG_ERR_EX(sev, err) LOG_GLE_EX(sev, err)
+#define LOG_ERR(sev) LOG_GLE(sev)
+#define LAST_SYSTEM_ERROR (::GetLastError())
+#else
+#define LOG_ERR_EX(sev, err) LOG_ERRNO_EX(sev, err)
+#define LOG_ERR(sev) LOG_ERRNO(sev)
+#define LAST_SYSTEM_ERROR (errno)
+#endif // OS_WIN
+
+#undef PLOG
+#define PLOG(sev, err) LOG_ERR_EX(sev, err)
+
+#endif // LOGGING_INSIDE_WEBRTC
+
+#endif // THIRD_PARTY_LIBJINGLE_OVERRIDES_WEBRTC_BASE_LOGGING_H_
diff --git a/overrides/webrtc/base/win32socketinit.cc b/overrides/webrtc/base/win32socketinit.cc
new file mode 100644
index 00000000..929ce8d3
--- /dev/null
+++ b/overrides/webrtc/base/win32socketinit.cc
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2006 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.
+ */
+
+// Redirect Libjingle's winsock initialization activity into Chromium's
+// singleton object that managest precisely that for the browser.
+
+#include "webrtc/base/win32socketinit.h"
+
+#include "net/base/winsock_init.h"
+
+#if !defined(WEBRTC_WIN)
+#error "Only compile this on Windows"
+#endif
+
+namespace rtc {
+
+void EnsureWinsockInit() {
+ net::EnsureWinsockInit();
+}
+
+} // namespace rtc