зеркало из https://github.com/mozilla/pjs.git
Bug 680864 - Remove CHROMIUM_MOZILLA_BUILD ifdefs, since always defined and #ifndef codepaths broken anyway; r=cjones
This commit is contained in:
Родитель
0ea341dfbe
Коммит
3f11726bf8
|
@ -48,7 +48,6 @@ EXTRA_DEPS += $(topsrcdir)/ipc/chromium/chromium-config.mk
|
|||
|
||||
DEFINES += \
|
||||
-DEXCLUDE_SKIA_DEPENDENCIES \
|
||||
-DCHROMIUM_MOZILLA_BUILD \
|
||||
$(NULL)
|
||||
|
||||
LOCAL_INCLUDES += \
|
||||
|
|
|
@ -64,11 +64,9 @@ void AtExitManager::ProcessCallbacksNow() {
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
// static
|
||||
bool AtExitManager::AlreadyRegistered() {
|
||||
return !!g_top_manager;
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace base
|
||||
|
|
|
@ -51,9 +51,7 @@ class AtExitManager {
|
|||
// is possible to register new callbacks after calling this function.
|
||||
static void ProcessCallbacksNow();
|
||||
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
static bool AlreadyRegistered();
|
||||
#endif
|
||||
|
||||
private:
|
||||
struct CallbackAndParam {
|
||||
|
|
|
@ -196,7 +196,6 @@ inline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) {
|
|||
*ptr = value;
|
||||
}
|
||||
|
||||
#if defined(CHROMIUM_MOZILLA_BUILD)
|
||||
inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,
|
||||
Atomic64 old_value,
|
||||
Atomic64 new_value) {
|
||||
|
@ -207,7 +206,6 @@ inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,
|
|||
}
|
||||
return x;
|
||||
}
|
||||
#endif
|
||||
|
||||
inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) {
|
||||
*ptr = value;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#ifndef BASE_BASE_SWITCHES_H_
|
||||
#define BASE_BASE_SWITCHES_H_
|
||||
|
||||
#if defined(CHROMIUM_MOZILLA_BUILD) && defined(COMPILER_MSVC)
|
||||
#if defined(COMPILER_MSVC)
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
#ifndef BASE_BASICTYPES_H_
|
||||
#define BASE_BASICTYPES_H_
|
||||
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
|
||||
// Chromium includes a prtypes.h also, but it has been modified to include
|
||||
// their build_config.h as well. We can therefore test for both to determine
|
||||
// if someone screws up the include order.
|
||||
|
@ -41,8 +39,6 @@
|
|||
#define _WIN32
|
||||
#endif
|
||||
|
||||
#endif // CHROMIUM_MOZILLA_BUILD
|
||||
|
||||
#include <limits.h> // So we can set the bounds of our types
|
||||
#include <stddef.h> // For size_t
|
||||
#include <string.h> // for memcpy
|
||||
|
@ -63,7 +59,7 @@ typedef short int16;
|
|||
#define _INT32
|
||||
typedef int int32;
|
||||
#endif
|
||||
#if !(defined(CHROMIUM_MOZILLA_BUILD) && defined(PROTYPES_H))
|
||||
#ifndef PROTYPES_H
|
||||
typedef long long int64;
|
||||
#endif
|
||||
|
||||
|
@ -81,7 +77,7 @@ typedef unsigned short uint16;
|
|||
#define _UINT32
|
||||
typedef unsigned int uint32;
|
||||
#endif
|
||||
#if !(defined(CHROMIUM_MOZILLA_BUILD) && defined(PROTYPES_H))
|
||||
#ifndef PROTYPES_H
|
||||
typedef unsigned long long uint64;
|
||||
#endif
|
||||
|
||||
|
@ -104,7 +100,6 @@ const int32 kint32max = (( int32) 0x7FFFFFFF);
|
|||
const int64 kint64min = (( int64) GG_LONGLONG(0x8000000000000000));
|
||||
const int64 kint64max = (( int64) GG_LONGLONG(0x7FFFFFFFFFFFFFFF));
|
||||
|
||||
#if defined(CHROMIUM_MOZILLA_BUILD)
|
||||
// Platform- and hardware-dependent printf specifiers
|
||||
# if defined(OS_POSIX)
|
||||
# define __STDC_FORMAT_MACROS 1
|
||||
|
@ -120,7 +115,6 @@ const int64 kint64max = (( int64) GG_LONGLONG(0x7FFFFFFFFFFFFFFF));
|
|||
# define PRIu64L L"I64u"
|
||||
# define PRIx64L L"I64x"
|
||||
# endif
|
||||
#endif // defined(CHROMIUM_MOZILLA_BUILD)
|
||||
|
||||
// A macro to disallow the copy constructor and operator= functions
|
||||
// This should be used in the private: declarations for a class
|
||||
|
|
|
@ -65,11 +65,9 @@ class CommandLine {
|
|||
return current_process_commandline_;
|
||||
}
|
||||
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
static bool IsInitialized() {
|
||||
return !!current_process_commandline_;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Returns true if this command line contains the given switch.
|
||||
// (Switch names are case-insensitive.)
|
||||
|
|
|
@ -144,25 +144,5 @@ void StackTrace::PrintBacktrace() {
|
|||
}
|
||||
|
||||
void StackTrace::OutputToStream(std::ostream* os) {
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
return;
|
||||
#else
|
||||
scoped_ptr_malloc<char*> trace_symbols(
|
||||
backtrace_symbols(&trace_[0], trace_.size()));
|
||||
|
||||
// If we can't retrieve the symbols, print an error and just dump the raw
|
||||
// addresses.
|
||||
if (trace_symbols.get() == NULL) {
|
||||
(*os) << "Unable get symbols for backtrace (" << strerror(errno)
|
||||
<< "). Dumping raw addresses in trace:\n";
|
||||
for (size_t i = 0; i < trace_.size(); ++i) {
|
||||
(*os) << "\t" << trace_[i] << "\n";
|
||||
}
|
||||
} else {
|
||||
(*os) << "Backtrace:\n";
|
||||
for (size_t i = 0; i < trace_.size(); ++i) {
|
||||
(*os) << "\t" << trace_symbols.get()[i] << "\n";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -21,13 +21,11 @@
|
|||
|
||||
namespace base {
|
||||
|
||||
#if defined(CHROMIUM_MOZILLA_BUILD)
|
||||
#define DVLOG(x) LOG(ERROR)
|
||||
#define CHECK_GT DCHECK_GT
|
||||
#define CHECK_LT DCHECK_LT
|
||||
typedef ::Lock Lock;
|
||||
typedef ::AutoLock AutoLock;
|
||||
#endif
|
||||
|
||||
// Static table of checksums for all possible 8 bit bytes.
|
||||
const uint32 Histogram::kCrcTable[256] = {0x0, 0x77073096L, 0xee0e612cL,
|
||||
|
|
|
@ -45,11 +45,7 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#if defined(CHROMIUM_MOZILLA_BUILD)
|
||||
#define BASE_API
|
||||
#else
|
||||
#include "base/base_api.h"
|
||||
#endif
|
||||
#include "testing/gtest/include/gtest/gtest_prod.h"
|
||||
#include "base/time.h"
|
||||
#include "base/lock.h"
|
||||
|
|
|
@ -72,7 +72,6 @@ class IDMap {
|
|||
return data_.empty();
|
||||
}
|
||||
|
||||
#if defined(CHROMIUM_MOZILLA_BUILD)
|
||||
void Clear() {
|
||||
data_.clear();
|
||||
}
|
||||
|
@ -84,7 +83,6 @@ class IDMap {
|
|||
return true;
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
T* Lookup(int32 id) const {
|
||||
const_iterator i = data_.find(id);
|
||||
|
|
|
@ -3,9 +3,6 @@
|
|||
// found in the LICENSE file.
|
||||
|
||||
#include "base/logging.h"
|
||||
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
|
||||
#include "prmem.h"
|
||||
#include "prprf.h"
|
||||
#include "base/string_util.h"
|
||||
|
@ -106,570 +103,3 @@ operator<<(mozilla::Logger& log, void* p)
|
|||
log.printf("%p", p);
|
||||
return log;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include <windows.h>
|
||||
typedef HANDLE FileHandle;
|
||||
typedef HANDLE MutexHandle;
|
||||
#elif defined(OS_MACOSX)
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#include <mach/mach.h>
|
||||
#include <mach/mach_time.h>
|
||||
#include <mach-o/dyld.h>
|
||||
#elif defined(OS_LINUX)
|
||||
#include <sys/syscall.h>
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
#if defined(OS_POSIX)
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#define MAX_PATH PATH_MAX
|
||||
typedef FILE* FileHandle;
|
||||
typedef pthread_mutex_t* MutexHandle;
|
||||
#endif
|
||||
|
||||
#include <ctime>
|
||||
#include <iomanip>
|
||||
#include <cstring>
|
||||
#include <algorithm>
|
||||
|
||||
#include "base/base_switches.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/debug_util.h"
|
||||
#include "base/lock_impl.h"
|
||||
#include "base/string_piece.h"
|
||||
#include "base/string_util.h"
|
||||
#include "base/sys_string_conversions.h"
|
||||
|
||||
namespace logging {
|
||||
|
||||
bool g_enable_dcheck = false;
|
||||
|
||||
const char* const log_severity_names[LOG_NUM_SEVERITIES] = {
|
||||
"INFO", "WARNING", "ERROR", "ERROR_REPORT", "FATAL" };
|
||||
|
||||
int min_log_level = 0;
|
||||
LogLockingState lock_log_file = LOCK_LOG_FILE;
|
||||
|
||||
// The default set here for logging_destination will only be used if
|
||||
// InitLogging is not called. On Windows, use a file next to the exe;
|
||||
// on POSIX platforms, where it may not even be possible to locate the
|
||||
// executable on disk, use stderr.
|
||||
#if defined(OS_WIN)
|
||||
LoggingDestination logging_destination = LOG_ONLY_TO_FILE;
|
||||
#elif defined(OS_POSIX)
|
||||
LoggingDestination logging_destination = LOG_ONLY_TO_SYSTEM_DEBUG_LOG;
|
||||
#endif
|
||||
|
||||
const int kMaxFilteredLogLevel = LOG_WARNING;
|
||||
std::string* log_filter_prefix;
|
||||
|
||||
// For LOG_ERROR and above, always print to stderr.
|
||||
const int kAlwaysPrintErrorLevel = LOG_ERROR;
|
||||
|
||||
// Which log file to use? This is initialized by InitLogging or
|
||||
// will be lazily initialized to the default value when it is
|
||||
// first needed.
|
||||
#if defined(OS_WIN)
|
||||
typedef wchar_t PathChar;
|
||||
typedef std::wstring PathString;
|
||||
#else
|
||||
typedef char PathChar;
|
||||
typedef std::string PathString;
|
||||
#endif
|
||||
PathString* log_file_name = NULL;
|
||||
|
||||
// this file is lazily opened and the handle may be NULL
|
||||
FileHandle log_file = NULL;
|
||||
|
||||
// what should be prepended to each message?
|
||||
bool log_process_id = false;
|
||||
bool log_thread_id = false;
|
||||
bool log_timestamp = true;
|
||||
bool log_tickcount = false;
|
||||
|
||||
// An assert handler override specified by the client to be called instead of
|
||||
// the debug message dialog and process termination.
|
||||
LogAssertHandlerFunction log_assert_handler = NULL;
|
||||
// An report handler override specified by the client to be called instead of
|
||||
// the debug message dialog.
|
||||
LogReportHandlerFunction log_report_handler = NULL;
|
||||
|
||||
// The lock is used if log file locking is false. It helps us avoid problems
|
||||
// with multiple threads writing to the log file at the same time. Use
|
||||
// LockImpl directly instead of using Lock, because Lock makes logging calls.
|
||||
static LockImpl* log_lock = NULL;
|
||||
|
||||
// When we don't use a lock, we are using a global mutex. We need to do this
|
||||
// because LockFileEx is not thread safe.
|
||||
#if defined(OS_WIN)
|
||||
MutexHandle log_mutex = NULL;
|
||||
#elif defined(OS_POSIX)
|
||||
pthread_mutex_t log_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
#endif
|
||||
|
||||
// Helper functions to wrap platform differences.
|
||||
|
||||
int32 CurrentProcessId() {
|
||||
#if defined(OS_WIN)
|
||||
return GetCurrentProcessId();
|
||||
#elif defined(OS_POSIX)
|
||||
return getpid();
|
||||
#endif
|
||||
}
|
||||
|
||||
int32 CurrentThreadId() {
|
||||
#if defined(OS_WIN)
|
||||
return GetCurrentThreadId();
|
||||
#elif defined(OS_MACOSX)
|
||||
return mach_thread_self();
|
||||
#elif defined(OS_LINUX)
|
||||
return syscall(__NR_gettid);
|
||||
#endif
|
||||
}
|
||||
|
||||
uint64 TickCount() {
|
||||
#if defined(OS_WIN)
|
||||
return GetTickCount();
|
||||
#elif defined(OS_MACOSX)
|
||||
return mach_absolute_time();
|
||||
#elif defined(OS_LINUX)
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
|
||||
uint64 absolute_micro =
|
||||
static_cast<int64>(ts.tv_sec) * 1000000 +
|
||||
static_cast<int64>(ts.tv_nsec) / 1000;
|
||||
|
||||
return absolute_micro;
|
||||
#endif
|
||||
}
|
||||
|
||||
void CloseFile(FileHandle log) {
|
||||
#if defined(OS_WIN)
|
||||
CloseHandle(log);
|
||||
#else
|
||||
fclose(log);
|
||||
#endif
|
||||
}
|
||||
|
||||
void DeleteFilePath(const PathString& log_name) {
|
||||
#if defined(OS_WIN)
|
||||
DeleteFile(log_name.c_str());
|
||||
#else
|
||||
unlink(log_name.c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
// Called by logging functions to ensure that debug_file is initialized
|
||||
// and can be used for writing. Returns false if the file could not be
|
||||
// initialized. debug_file will be NULL in this case.
|
||||
bool InitializeLogFileHandle() {
|
||||
if (log_file)
|
||||
return true;
|
||||
|
||||
if (!log_file_name) {
|
||||
// Nobody has called InitLogging to specify a debug log file, so here we
|
||||
// initialize the log file name to a default.
|
||||
#if defined(OS_WIN)
|
||||
// On Windows we use the same path as the exe.
|
||||
wchar_t module_name[MAX_PATH];
|
||||
GetModuleFileName(NULL, module_name, MAX_PATH);
|
||||
log_file_name = new std::wstring(module_name);
|
||||
std::wstring::size_type last_backslash =
|
||||
log_file_name->rfind('\\', log_file_name->size());
|
||||
if (last_backslash != std::wstring::npos)
|
||||
log_file_name->erase(last_backslash + 1);
|
||||
*log_file_name += L"debug.log";
|
||||
#elif defined(OS_POSIX)
|
||||
// On other platforms we just use the current directory.
|
||||
log_file_name = new std::string("debug.log");
|
||||
#endif
|
||||
}
|
||||
|
||||
if (logging_destination == LOG_ONLY_TO_FILE ||
|
||||
logging_destination == LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG) {
|
||||
#if defined(OS_WIN)
|
||||
log_file = CreateFile(log_file_name->c_str(), GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
|
||||
OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
if (log_file == INVALID_HANDLE_VALUE || log_file == NULL) {
|
||||
// try the current directory
|
||||
log_file = CreateFile(L".\\debug.log", GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
|
||||
OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
if (log_file == INVALID_HANDLE_VALUE || log_file == NULL) {
|
||||
log_file = NULL;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
SetFilePointer(log_file, 0, 0, FILE_END);
|
||||
#elif defined(OS_POSIX)
|
||||
log_file = fopen(log_file_name->c_str(), "a");
|
||||
if (log_file == NULL)
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void InitLogMutex() {
|
||||
#if defined(OS_WIN)
|
||||
if (!log_mutex) {
|
||||
// \ is not a legal character in mutex names so we replace \ with /
|
||||
std::wstring safe_name(*log_file_name);
|
||||
std::replace(safe_name.begin(), safe_name.end(), '\\', '/');
|
||||
std::wstring t(L"Global\\");
|
||||
t.append(safe_name);
|
||||
log_mutex = ::CreateMutex(NULL, FALSE, t.c_str());
|
||||
}
|
||||
#elif defined(OS_POSIX)
|
||||
// statically initialized
|
||||
#endif
|
||||
}
|
||||
|
||||
void InitLogging(const PathChar* new_log_file, LoggingDestination logging_dest,
|
||||
LogLockingState lock_log, OldFileDeletionState delete_old) {
|
||||
g_enable_dcheck =
|
||||
CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableDCHECK);
|
||||
|
||||
if (log_file) {
|
||||
// calling InitLogging twice or after some log call has already opened the
|
||||
// default log file will re-initialize to the new options
|
||||
CloseFile(log_file);
|
||||
log_file = NULL;
|
||||
}
|
||||
|
||||
lock_log_file = lock_log;
|
||||
logging_destination = logging_dest;
|
||||
|
||||
// ignore file options if logging is disabled or only to system
|
||||
if (logging_destination == LOG_NONE ||
|
||||
logging_destination == LOG_ONLY_TO_SYSTEM_DEBUG_LOG)
|
||||
return;
|
||||
|
||||
if (!log_file_name)
|
||||
log_file_name = new PathString();
|
||||
*log_file_name = new_log_file;
|
||||
if (delete_old == DELETE_OLD_LOG_FILE)
|
||||
DeleteFilePath(*log_file_name);
|
||||
|
||||
if (lock_log_file == LOCK_LOG_FILE) {
|
||||
InitLogMutex();
|
||||
} else if (!log_lock) {
|
||||
log_lock = new LockImpl();
|
||||
}
|
||||
|
||||
InitializeLogFileHandle();
|
||||
}
|
||||
|
||||
void SetMinLogLevel(int level) {
|
||||
min_log_level = level;
|
||||
}
|
||||
|
||||
int GetMinLogLevel() {
|
||||
return min_log_level;
|
||||
}
|
||||
|
||||
void SetLogFilterPrefix(const char* filter) {
|
||||
if (log_filter_prefix) {
|
||||
delete log_filter_prefix;
|
||||
log_filter_prefix = NULL;
|
||||
}
|
||||
|
||||
if (filter)
|
||||
log_filter_prefix = new std::string(filter);
|
||||
}
|
||||
|
||||
void SetLogItems(bool enable_process_id, bool enable_thread_id,
|
||||
bool enable_timestamp, bool enable_tickcount) {
|
||||
log_process_id = enable_process_id;
|
||||
log_thread_id = enable_thread_id;
|
||||
log_timestamp = enable_timestamp;
|
||||
log_tickcount = enable_tickcount;
|
||||
}
|
||||
|
||||
void SetLogAssertHandler(LogAssertHandlerFunction handler) {
|
||||
log_assert_handler = handler;
|
||||
}
|
||||
|
||||
void SetLogReportHandler(LogReportHandlerFunction handler) {
|
||||
log_report_handler = handler;
|
||||
}
|
||||
|
||||
// Displays a message box to the user with the error message in it. For
|
||||
// Windows programs, it's possible that the message loop is messed up on
|
||||
// a fatal error, and creating a MessageBox will cause that message loop
|
||||
// to be run. Instead, we try to spawn another process that displays its
|
||||
// command line. We look for "Debug Message.exe" in the same directory as
|
||||
// the application. If it exists, we use it, otherwise, we use a regular
|
||||
// message box.
|
||||
void DisplayDebugMessage(const std::string& str) {
|
||||
if (str.empty())
|
||||
return;
|
||||
|
||||
#if defined(OS_WIN)
|
||||
// look for the debug dialog program next to our application
|
||||
wchar_t prog_name[MAX_PATH];
|
||||
GetModuleFileNameW(NULL, prog_name, MAX_PATH);
|
||||
wchar_t* backslash = wcsrchr(prog_name, '\\');
|
||||
if (backslash)
|
||||
backslash[1] = 0;
|
||||
wcscat_s(prog_name, MAX_PATH, L"debug_message.exe");
|
||||
|
||||
std::wstring cmdline = base::SysUTF8ToWide(str);
|
||||
if (cmdline.empty())
|
||||
return;
|
||||
|
||||
STARTUPINFO startup_info;
|
||||
memset(&startup_info, 0, sizeof(startup_info));
|
||||
startup_info.cb = sizeof(startup_info);
|
||||
|
||||
PROCESS_INFORMATION process_info;
|
||||
if (CreateProcessW(prog_name, &cmdline[0], NULL, NULL, false, 0, NULL,
|
||||
NULL, &startup_info, &process_info)) {
|
||||
WaitForSingleObject(process_info.hProcess, INFINITE);
|
||||
CloseHandle(process_info.hThread);
|
||||
CloseHandle(process_info.hProcess);
|
||||
} else {
|
||||
// debug process broken, let's just do a message box
|
||||
MessageBoxW(NULL, &cmdline[0], L"Fatal error",
|
||||
MB_OK | MB_ICONHAND | MB_TOPMOST);
|
||||
}
|
||||
#else
|
||||
fprintf(stderr, "%s\n", str.c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(OS_WIN)
|
||||
LogMessage::SaveLastError::SaveLastError() : last_error_(::GetLastError()) {
|
||||
}
|
||||
|
||||
LogMessage::SaveLastError::~SaveLastError() {
|
||||
::SetLastError(last_error_);
|
||||
}
|
||||
#endif // defined(OS_WIN)
|
||||
|
||||
LogMessage::LogMessage(const char* file, int line, LogSeverity severity,
|
||||
int ctr)
|
||||
: severity_(severity) {
|
||||
Init(file, line);
|
||||
}
|
||||
|
||||
LogMessage::LogMessage(const char* file, int line, const CheckOpString& result)
|
||||
: severity_(LOG_FATAL) {
|
||||
Init(file, line);
|
||||
stream_ << "Check failed: " << (*result.str_);
|
||||
}
|
||||
|
||||
LogMessage::LogMessage(const char* file, int line, LogSeverity severity,
|
||||
const CheckOpString& result)
|
||||
: severity_(severity) {
|
||||
Init(file, line);
|
||||
stream_ << "Check failed: " << (*result.str_);
|
||||
}
|
||||
|
||||
LogMessage::LogMessage(const char* file, int line)
|
||||
: severity_(LOG_INFO) {
|
||||
Init(file, line);
|
||||
}
|
||||
|
||||
LogMessage::LogMessage(const char* file, int line, LogSeverity severity)
|
||||
: severity_(severity) {
|
||||
Init(file, line);
|
||||
}
|
||||
|
||||
// writes the common header info to the stream
|
||||
void LogMessage::Init(const char* file, int line) {
|
||||
// log only the filename
|
||||
const char* last_slash = strrchr(file, '\\');
|
||||
if (last_slash)
|
||||
file = last_slash + 1;
|
||||
|
||||
// TODO(darin): It might be nice if the columns were fixed width.
|
||||
|
||||
stream_ << '[';
|
||||
if (log_process_id)
|
||||
stream_ << CurrentProcessId() << ':';
|
||||
if (log_thread_id)
|
||||
stream_ << CurrentThreadId() << ':';
|
||||
if (log_timestamp) {
|
||||
time_t t = time(NULL);
|
||||
#if _MSC_VER >= 1400
|
||||
struct tm local_time = {0};
|
||||
localtime_s(&local_time, &t);
|
||||
struct tm* tm_time = &local_time;
|
||||
#else
|
||||
struct tm* tm_time = localtime(&t);
|
||||
#endif
|
||||
stream_ << std::setfill('0')
|
||||
<< std::setw(2) << 1 + tm_time->tm_mon
|
||||
<< std::setw(2) << tm_time->tm_mday
|
||||
<< '/'
|
||||
<< std::setw(2) << tm_time->tm_hour
|
||||
<< std::setw(2) << tm_time->tm_min
|
||||
<< std::setw(2) << tm_time->tm_sec
|
||||
<< ':';
|
||||
}
|
||||
if (log_tickcount)
|
||||
stream_ << TickCount() << ':';
|
||||
stream_ << log_severity_names[severity_] << ":" << file <<
|
||||
"(" << line << ")] ";
|
||||
|
||||
message_start_ = stream_.tellp();
|
||||
}
|
||||
|
||||
LogMessage::~LogMessage() {
|
||||
// TODO(brettw) modify the macros so that nothing is executed when the log
|
||||
// level is too high.
|
||||
if (severity_ < min_log_level)
|
||||
return;
|
||||
|
||||
std::string str_newline(stream_.str());
|
||||
#if defined(OS_WIN)
|
||||
str_newline.append("\r\n");
|
||||
#else
|
||||
str_newline.append("\n");
|
||||
#endif
|
||||
|
||||
if (log_filter_prefix && severity_ <= kMaxFilteredLogLevel &&
|
||||
str_newline.compare(message_start_, log_filter_prefix->size(),
|
||||
log_filter_prefix->data()) != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (logging_destination == LOG_ONLY_TO_SYSTEM_DEBUG_LOG ||
|
||||
logging_destination == LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG) {
|
||||
#if defined(OS_WIN)
|
||||
OutputDebugStringA(str_newline.c_str());
|
||||
if (severity_ >= kAlwaysPrintErrorLevel)
|
||||
#endif
|
||||
// TODO(erikkay): this interferes with the layout tests since it grabs
|
||||
// stderr and stdout and diffs them against known data. Our info and warn
|
||||
// logs add noise to that. Ideally, the layout tests would set the log
|
||||
// level to ignore anything below error. When that happens, we should
|
||||
// take this fprintf out of the #else so that Windows users can benefit
|
||||
// from the output when running tests from the command-line. In the
|
||||
// meantime, we leave this in for Mac and Linux, but until this is fixed
|
||||
// they won't be able to pass any layout tests that have info or warn logs.
|
||||
// See http://b/1343647
|
||||
fprintf(stderr, "%s", str_newline.c_str());
|
||||
} else if (severity_ >= kAlwaysPrintErrorLevel) {
|
||||
// When we're only outputting to a log file, above a certain log level, we
|
||||
// should still output to stderr so that we can better detect and diagnose
|
||||
// problems with unit tests, especially on the buildbots.
|
||||
fprintf(stderr, "%s", str_newline.c_str());
|
||||
}
|
||||
|
||||
// write to log file
|
||||
if (logging_destination != LOG_NONE &&
|
||||
logging_destination != LOG_ONLY_TO_SYSTEM_DEBUG_LOG &&
|
||||
InitializeLogFileHandle()) {
|
||||
// We can have multiple threads and/or processes, so try to prevent them
|
||||
// from clobbering each other's writes.
|
||||
if (lock_log_file == LOCK_LOG_FILE) {
|
||||
// Ensure that the mutex is initialized in case the client app did not
|
||||
// call InitLogging. This is not thread safe. See below.
|
||||
InitLogMutex();
|
||||
|
||||
#if defined(OS_WIN)
|
||||
DWORD r = ::WaitForSingleObject(log_mutex, INFINITE);
|
||||
DCHECK(r != WAIT_ABANDONED);
|
||||
#elif defined(OS_POSIX)
|
||||
pthread_mutex_lock(&log_mutex);
|
||||
#endif
|
||||
} else {
|
||||
// use the lock
|
||||
if (!log_lock) {
|
||||
// The client app did not call InitLogging, and so the lock has not
|
||||
// been created. We do this on demand, but if two threads try to do
|
||||
// this at the same time, there will be a race condition to create
|
||||
// the lock. This is why InitLogging should be called from the main
|
||||
// thread at the beginning of execution.
|
||||
log_lock = new LockImpl();
|
||||
}
|
||||
log_lock->Lock();
|
||||
}
|
||||
|
||||
#if defined(OS_WIN)
|
||||
SetFilePointer(log_file, 0, 0, SEEK_END);
|
||||
DWORD num_written;
|
||||
WriteFile(log_file,
|
||||
static_cast<const void*>(str_newline.c_str()),
|
||||
static_cast<DWORD>(str_newline.length()),
|
||||
&num_written,
|
||||
NULL);
|
||||
#else
|
||||
fprintf(log_file, "%s", str_newline.c_str());
|
||||
#endif
|
||||
|
||||
if (lock_log_file == LOCK_LOG_FILE) {
|
||||
#if defined(OS_WIN)
|
||||
ReleaseMutex(log_mutex);
|
||||
#elif defined(OS_POSIX)
|
||||
pthread_mutex_unlock(&log_mutex);
|
||||
#endif
|
||||
} else {
|
||||
log_lock->Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
if (severity_ == LOG_FATAL) {
|
||||
// display a message or break into the debugger on a fatal error
|
||||
if (DebugUtil::BeingDebugged()) {
|
||||
DebugUtil::BreakDebugger();
|
||||
} else {
|
||||
#ifndef NDEBUG
|
||||
// Dump a stack trace on a fatal.
|
||||
StackTrace trace;
|
||||
stream_ << "\n"; // Newline to separate from log message.
|
||||
trace.OutputToStream(&stream_);
|
||||
#endif
|
||||
|
||||
if (log_assert_handler) {
|
||||
// make a copy of the string for the handler out of paranoia
|
||||
log_assert_handler(std::string(stream_.str()));
|
||||
} else {
|
||||
// Don't use the string with the newline, get a fresh version to send to
|
||||
// the debug message process. We also don't display assertions to the
|
||||
// user in release mode. The enduser can't do anything with this
|
||||
// information, and displaying message boxes when the application is
|
||||
// hosed can cause additional problems.
|
||||
#ifndef NDEBUG
|
||||
DisplayDebugMessage(stream_.str());
|
||||
#endif
|
||||
// Crash the process to generate a dump.
|
||||
DebugUtil::BreakDebugger();
|
||||
}
|
||||
}
|
||||
} else if (severity_ == LOG_ERROR_REPORT) {
|
||||
// We are here only if the user runs with --enable-dcheck in release mode.
|
||||
if (log_report_handler) {
|
||||
log_report_handler(std::string(stream_.str()));
|
||||
} else {
|
||||
DisplayDebugMessage(stream_.str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CloseLogFile() {
|
||||
if (!log_file)
|
||||
return;
|
||||
|
||||
CloseFile(log_file);
|
||||
log_file = NULL;
|
||||
}
|
||||
|
||||
} // namespace logging
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const wchar_t* wstr) {
|
||||
return out << base::SysWideToUTF8(std::wstring(wstr));
|
||||
}
|
||||
|
||||
#endif // CHROMIUM_MOZILLA_BUILD
|
||||
|
|
|
@ -9,9 +9,6 @@
|
|||
#include <cstring>
|
||||
|
||||
#include "base/basictypes.h"
|
||||
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
|
||||
#include "prlog.h"
|
||||
|
||||
// Replace the Chromium logging code with NSPR-based logging code and
|
||||
|
@ -123,640 +120,4 @@ const mozilla::EmptyLog& operator <<(const mozilla::EmptyLog& log, const T&)
|
|||
#endif
|
||||
#define assert DLOG_ASSERT
|
||||
|
||||
#else
|
||||
|
||||
#include <sstream>
|
||||
|
||||
//
|
||||
// Optional message capabilities
|
||||
// -----------------------------
|
||||
// Assertion failed messages and fatal errors are displayed in a dialog box
|
||||
// before the application exits. However, running this UI creates a message
|
||||
// loop, which causes application messages to be processed and potentially
|
||||
// dispatched to existing application windows. Since the application is in a
|
||||
// bad state when this assertion dialog is displayed, these messages may not
|
||||
// get processed and hang the dialog, or the application might go crazy.
|
||||
//
|
||||
// Therefore, it can be beneficial to display the error dialog in a separate
|
||||
// process from the main application. When the logging system needs to display
|
||||
// a fatal error dialog box, it will look for a program called
|
||||
// "DebugMessage.exe" in the same directory as the application executable. It
|
||||
// will run this application with the message as the command line, and will
|
||||
// not include the name of the application as is traditional for easier
|
||||
// parsing.
|
||||
//
|
||||
// The code for DebugMessage.exe is only one line. In WinMain, do:
|
||||
// MessageBox(NULL, GetCommandLineW(), L"Fatal Error", 0);
|
||||
//
|
||||
// If DebugMessage.exe is not found, the logging code will use a normal
|
||||
// MessageBox, potentially causing the problems discussed above.
|
||||
|
||||
|
||||
// Instructions
|
||||
// ------------
|
||||
//
|
||||
// Make a bunch of macros for logging. The way to log things is to stream
|
||||
// things to LOG(<a particular severity level>). E.g.,
|
||||
//
|
||||
// LOG(INFO) << "Found " << num_cookies << " cookies";
|
||||
//
|
||||
// You can also do conditional logging:
|
||||
//
|
||||
// LOG_IF(INFO, num_cookies > 10) << "Got lots of cookies";
|
||||
//
|
||||
// The above will cause log messages to be output on the 1st, 11th, 21st, ...
|
||||
// times it is executed. Note that the special COUNTER value is used to
|
||||
// identify which repetition is happening.
|
||||
//
|
||||
// The CHECK(condition) macro is active in both debug and release builds and
|
||||
// effectively performs a LOG(FATAL) which terminates the process and
|
||||
// generates a crashdump unless a debugger is attached.
|
||||
//
|
||||
// There are also "debug mode" logging macros like the ones above:
|
||||
//
|
||||
// DLOG(INFO) << "Found cookies";
|
||||
//
|
||||
// DLOG_IF(INFO, num_cookies > 10) << "Got lots of cookies";
|
||||
//
|
||||
// All "debug mode" logging is compiled away to nothing for non-debug mode
|
||||
// compiles. LOG_IF and development flags also work well together
|
||||
// because the code can be compiled away sometimes.
|
||||
//
|
||||
// We also have
|
||||
//
|
||||
// LOG_ASSERT(assertion);
|
||||
// DLOG_ASSERT(assertion);
|
||||
//
|
||||
// which is syntactic sugar for {,D}LOG_IF(FATAL, assert fails) << assertion;
|
||||
//
|
||||
// We also override the standard 'assert' to use 'DLOG_ASSERT'.
|
||||
//
|
||||
// The supported severity levels for macros that allow you to specify one
|
||||
// are (in increasing order of severity) INFO, WARNING, ERROR, ERROR_REPORT,
|
||||
// and FATAL.
|
||||
//
|
||||
// Very important: logging a message at the FATAL severity level causes
|
||||
// the program to terminate (after the message is logged).
|
||||
//
|
||||
// Note the special severity of ERROR_REPORT only available/relevant in normal
|
||||
// mode, which displays error dialog without terminating the program. There is
|
||||
// no error dialog for severity ERROR or below in normal mode.
|
||||
//
|
||||
// There is also the special severity of DFATAL, which logs FATAL in
|
||||
// debug mode, ERROR_REPORT in normal mode.
|
||||
|
||||
namespace logging {
|
||||
|
||||
// Where to record logging output? A flat file and/or system debug log via
|
||||
// OutputDebugString. Defaults on Windows to LOG_ONLY_TO_FILE, and on
|
||||
// POSIX to LOG_ONLY_TO_SYSTEM_DEBUG_LOG (aka stderr).
|
||||
enum LoggingDestination { LOG_NONE,
|
||||
LOG_ONLY_TO_FILE,
|
||||
LOG_ONLY_TO_SYSTEM_DEBUG_LOG,
|
||||
LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG };
|
||||
|
||||
// Indicates that the log file should be locked when being written to.
|
||||
// Often, there is no locking, which is fine for a single threaded program.
|
||||
// If logging is being done from multiple threads or there can be more than
|
||||
// one process doing the logging, the file should be locked during writes to
|
||||
// make each log outut atomic. Other writers will block.
|
||||
//
|
||||
// All processes writing to the log file must have their locking set for it to
|
||||
// work properly. Defaults to DONT_LOCK_LOG_FILE.
|
||||
enum LogLockingState { LOCK_LOG_FILE, DONT_LOCK_LOG_FILE };
|
||||
|
||||
// On startup, should we delete or append to an existing log file (if any)?
|
||||
// Defaults to APPEND_TO_OLD_LOG_FILE.
|
||||
enum OldFileDeletionState { DELETE_OLD_LOG_FILE, APPEND_TO_OLD_LOG_FILE };
|
||||
|
||||
// Sets the log file name and other global logging state. Calling this function
|
||||
// is recommended, and is normally done at the beginning of application init.
|
||||
// If you don't call it, all the flags will be initialized to their default
|
||||
// values, and there is a race condition that may leak a critical section
|
||||
// object if two threads try to do the first log at the same time.
|
||||
// See the definition of the enums above for descriptions and default values.
|
||||
//
|
||||
// The default log file is initialized to "debug.log" in the application
|
||||
// directory. You probably don't want this, especially since the program
|
||||
// directory may not be writable on an enduser's system.
|
||||
#if defined(OS_WIN)
|
||||
void InitLogging(const wchar_t* log_file, LoggingDestination logging_dest,
|
||||
LogLockingState lock_log, OldFileDeletionState delete_old);
|
||||
#elif defined(OS_POSIX)
|
||||
// TODO(avi): do we want to do a unification of character types here?
|
||||
void InitLogging(const char* log_file, LoggingDestination logging_dest,
|
||||
LogLockingState lock_log, OldFileDeletionState delete_old);
|
||||
#endif
|
||||
|
||||
// Sets the log level. Anything at or above this level will be written to the
|
||||
// log file/displayed to the user (if applicable). Anything below this level
|
||||
// will be silently ignored. The log level defaults to 0 (everything is logged)
|
||||
// if this function is not called.
|
||||
void SetMinLogLevel(int level);
|
||||
|
||||
// Gets the current log level.
|
||||
int GetMinLogLevel();
|
||||
|
||||
// Sets the log filter prefix. Any log message below LOG_ERROR severity that
|
||||
// doesn't start with this prefix with be silently ignored. The filter defaults
|
||||
// to NULL (everything is logged) if this function is not called. Messages
|
||||
// with severity of LOG_ERROR or higher will not be filtered.
|
||||
void SetLogFilterPrefix(const char* filter);
|
||||
|
||||
// Sets the common items you want to be prepended to each log message.
|
||||
// process and thread IDs default to off, the timestamp defaults to on.
|
||||
// If this function is not called, logging defaults to writing the timestamp
|
||||
// only.
|
||||
void SetLogItems(bool enable_process_id, bool enable_thread_id,
|
||||
bool enable_timestamp, bool enable_tickcount);
|
||||
|
||||
// Sets the Log Assert Handler that will be used to notify of check failures.
|
||||
// The default handler shows a dialog box and then terminate the process,
|
||||
// however clients can use this function to override with their own handling
|
||||
// (e.g. a silent one for Unit Tests)
|
||||
typedef void (*LogAssertHandlerFunction)(const std::string& str);
|
||||
void SetLogAssertHandler(LogAssertHandlerFunction handler);
|
||||
// Sets the Log Report Handler that will be used to notify of check failures
|
||||
// in non-debug mode. The default handler shows a dialog box and continues
|
||||
// the execution, however clients can use this function to override with their
|
||||
// own handling.
|
||||
typedef void (*LogReportHandlerFunction)(const std::string& str);
|
||||
void SetLogReportHandler(LogReportHandlerFunction handler);
|
||||
|
||||
typedef int LogSeverity;
|
||||
const LogSeverity LOG_INFO = 0;
|
||||
const LogSeverity LOG_WARNING = 1;
|
||||
const LogSeverity LOG_ERROR = 2;
|
||||
const LogSeverity LOG_ERROR_REPORT = 3;
|
||||
const LogSeverity LOG_FATAL = 4;
|
||||
const LogSeverity LOG_NUM_SEVERITIES = 5;
|
||||
|
||||
// LOG_DFATAL_LEVEL is LOG_FATAL in debug mode, ERROR_REPORT in normal mode
|
||||
#ifdef NDEBUG
|
||||
const LogSeverity LOG_DFATAL_LEVEL = LOG_ERROR_REPORT;
|
||||
#else
|
||||
const LogSeverity LOG_DFATAL_LEVEL = LOG_FATAL;
|
||||
#endif
|
||||
|
||||
// A few definitions of macros that don't generate much code. These are used
|
||||
// by LOG() and LOG_IF, etc. Since these are used all over our code, it's
|
||||
// better to have compact code for these operations.
|
||||
#define COMPACT_GOOGLE_LOG_INFO \
|
||||
logging::LogMessage(__FILE__, __LINE__)
|
||||
#define COMPACT_GOOGLE_LOG_WARNING \
|
||||
logging::LogMessage(__FILE__, __LINE__, logging::LOG_WARNING)
|
||||
#define COMPACT_GOOGLE_LOG_ERROR \
|
||||
logging::LogMessage(__FILE__, __LINE__, logging::LOG_ERROR)
|
||||
#define COMPACT_GOOGLE_LOG_ERROR_REPORT \
|
||||
logging::LogMessage(__FILE__, __LINE__, logging::LOG_ERROR_REPORT)
|
||||
#define COMPACT_GOOGLE_LOG_FATAL \
|
||||
logging::LogMessage(__FILE__, __LINE__, logging::LOG_FATAL)
|
||||
#define COMPACT_GOOGLE_LOG_DFATAL \
|
||||
logging::LogMessage(__FILE__, __LINE__, logging::LOG_DFATAL_LEVEL)
|
||||
|
||||
// wingdi.h defines ERROR to be 0. When we call LOG(ERROR), it gets
|
||||
// substituted with 0, and it expands to COMPACT_GOOGLE_LOG_0. To allow us
|
||||
// to keep using this syntax, we define this macro to do the same thing
|
||||
// as COMPACT_GOOGLE_LOG_ERROR, and also define ERROR the same way that
|
||||
// the Windows SDK does for consistency.
|
||||
#define ERROR 0
|
||||
#define COMPACT_GOOGLE_LOG_0 \
|
||||
logging::LogMessage(__FILE__, __LINE__, logging::LOG_ERROR)
|
||||
|
||||
// We use the preprocessor's merging operator, "##", so that, e.g.,
|
||||
// LOG(INFO) becomes the token COMPACT_GOOGLE_LOG_INFO. There's some funny
|
||||
// subtle difference between ostream member streaming functions (e.g.,
|
||||
// ostream::operator<<(int) and ostream non-member streaming functions
|
||||
// (e.g., ::operator<<(ostream&, string&): it turns out that it's
|
||||
// impossible to stream something like a string directly to an unnamed
|
||||
// ostream. We employ a neat hack by calling the stream() member
|
||||
// function of LogMessage which seems to avoid the problem.
|
||||
|
||||
#define LOG(severity) COMPACT_GOOGLE_LOG_ ## severity.stream()
|
||||
#define SYSLOG(severity) LOG(severity)
|
||||
|
||||
#define LOG_IF(severity, condition) \
|
||||
!(condition) ? (void) 0 : logging::LogMessageVoidify() & LOG(severity)
|
||||
#define SYSLOG_IF(severity, condition) LOG_IF(severity, condition)
|
||||
|
||||
#define LOG_ASSERT(condition) \
|
||||
LOG_IF(FATAL, !(condition)) << "Assert failed: " #condition ". "
|
||||
#define SYSLOG_ASSERT(condition) \
|
||||
SYSLOG_IF(FATAL, !(condition)) << "Assert failed: " #condition ". "
|
||||
|
||||
// CHECK dies with a fatal error if condition is not true. It is *not*
|
||||
// controlled by NDEBUG, so the check will be executed regardless of
|
||||
// compilation mode.
|
||||
#define CHECK(condition) \
|
||||
LOG_IF(FATAL, !(condition)) << "Check failed: " #condition ". "
|
||||
|
||||
// A container for a string pointer which can be evaluated to a bool -
|
||||
// true iff the pointer is NULL.
|
||||
struct CheckOpString {
|
||||
CheckOpString(std::string* str) : str_(str) { }
|
||||
// No destructor: if str_ is non-NULL, we're about to LOG(FATAL),
|
||||
// so there's no point in cleaning up str_.
|
||||
operator bool() const { return str_ != NULL; }
|
||||
std::string* str_;
|
||||
};
|
||||
|
||||
// Build the error message string. This is separate from the "Impl"
|
||||
// function template because it is not performance critical and so can
|
||||
// be out of line, while the "Impl" code should be inline.
|
||||
template<class t1, class t2>
|
||||
std::string* MakeCheckOpString(const t1& v1, const t2& v2, const char* names) {
|
||||
std::ostringstream ss;
|
||||
ss << names << " (" << v1 << " vs. " << v2 << ")";
|
||||
std::string* msg = new std::string(ss.str());
|
||||
return msg;
|
||||
}
|
||||
|
||||
extern std::string* MakeCheckOpStringIntInt(int v1, int v2, const char* names);
|
||||
|
||||
template<int, int>
|
||||
std::string* MakeCheckOpString(const int& v1,
|
||||
const int& v2,
|
||||
const char* names) {
|
||||
return MakeCheckOpStringIntInt(v1, v2, names);
|
||||
}
|
||||
|
||||
// Plus some debug-logging macros that get compiled to nothing for production
|
||||
//
|
||||
// DEBUG_MODE is for uses like
|
||||
// if (DEBUG_MODE) foo.CheckThatFoo();
|
||||
// instead of
|
||||
// #ifndef NDEBUG
|
||||
// foo.CheckThatFoo();
|
||||
// #endif
|
||||
|
||||
#ifdef OFFICIAL_BUILD
|
||||
// We want to have optimized code for an official build so we remove DLOGS and
|
||||
// DCHECK from the executable.
|
||||
|
||||
#define DLOG(severity) \
|
||||
true ? (void) 0 : logging::LogMessageVoidify() & LOG(severity)
|
||||
|
||||
#define DLOG_IF(severity, condition) \
|
||||
true ? (void) 0 : logging::LogMessageVoidify() & LOG(severity)
|
||||
|
||||
#define DLOG_ASSERT(condition) \
|
||||
true ? (void) 0 : LOG_ASSERT(condition)
|
||||
|
||||
enum { DEBUG_MODE = 0 };
|
||||
|
||||
// This macro can be followed by a sequence of stream parameters in
|
||||
// non-debug mode. The DCHECK and friends macros use this so that
|
||||
// the expanded expression DCHECK(foo) << "asdf" is still syntactically
|
||||
// valid, even though the expression will get optimized away.
|
||||
// In order to avoid variable unused warnings for code that only uses a
|
||||
// variable in a CHECK, we make sure to use the macro arguments.
|
||||
#define NDEBUG_EAT_STREAM_PARAMETERS \
|
||||
logging::LogMessage(__FILE__, __LINE__).stream()
|
||||
|
||||
#define DCHECK(condition) \
|
||||
while (false && (condition)) NDEBUG_EAT_STREAM_PARAMETERS
|
||||
|
||||
#define DCHECK_EQ(val1, val2) \
|
||||
while (false && (val1) == (val2)) NDEBUG_EAT_STREAM_PARAMETERS
|
||||
|
||||
#define DCHECK_NE(val1, val2) \
|
||||
while (false && (val1) == (val2)) NDEBUG_EAT_STREAM_PARAMETERS
|
||||
|
||||
#define DCHECK_LE(val1, val2) \
|
||||
while (false && (val1) == (val2)) NDEBUG_EAT_STREAM_PARAMETERS
|
||||
|
||||
#define DCHECK_LT(val1, val2) \
|
||||
while (false && (val1) == (val2)) NDEBUG_EAT_STREAM_PARAMETERS
|
||||
|
||||
#define DCHECK_GE(val1, val2) \
|
||||
while (false && (val1) == (val2)) NDEBUG_EAT_STREAM_PARAMETERS
|
||||
|
||||
#define DCHECK_GT(val1, val2) \
|
||||
while (false && (val1) == (val2)) NDEBUG_EAT_STREAM_PARAMETERS
|
||||
|
||||
#define DCHECK_STREQ(str1, str2) \
|
||||
while (false && (str1) == (str2)) NDEBUG_EAT_STREAM_PARAMETERS
|
||||
|
||||
#define DCHECK_STRCASEEQ(str1, str2) \
|
||||
while (false && (str1) == (str2)) NDEBUG_EAT_STREAM_PARAMETERS
|
||||
|
||||
#define DCHECK_STRNE(str1, str2) \
|
||||
while (false && (str1) == (str2)) NDEBUG_EAT_STREAM_PARAMETERS
|
||||
|
||||
#define DCHECK_STRCASENE(str1, str2) \
|
||||
while (false && (str1) == (str2)) NDEBUG_EAT_STREAM_PARAMETERS
|
||||
|
||||
#else
|
||||
#ifndef NDEBUG
|
||||
// On a regular debug build, we want to have DCHECKS and DLOGS enabled.
|
||||
|
||||
#define DLOG(severity) LOG(severity)
|
||||
#define DLOG_IF(severity, condition) LOG_IF(severity, condition)
|
||||
#define DLOG_ASSERT(condition) LOG_ASSERT(condition)
|
||||
|
||||
// debug-only checking. not executed in NDEBUG mode.
|
||||
enum { DEBUG_MODE = 1 };
|
||||
#define DCHECK(condition) \
|
||||
LOG_IF(FATAL, !(condition)) << "Check failed: " #condition ". "
|
||||
|
||||
// Helper macro for binary operators.
|
||||
// Don't use this macro directly in your code, use DCHECK_EQ et al below.
|
||||
#define DCHECK_OP(name, op, val1, val2) \
|
||||
if (logging::CheckOpString _result = \
|
||||
logging::Check##name##Impl((val1), (val2), #val1 " " #op " " #val2)) \
|
||||
logging::LogMessage(__FILE__, __LINE__, _result).stream()
|
||||
|
||||
// Helper functions for string comparisons.
|
||||
// To avoid bloat, the definitions are in logging.cc.
|
||||
#define DECLARE_DCHECK_STROP_IMPL(func, expected) \
|
||||
std::string* Check##func##expected##Impl(const char* s1, \
|
||||
const char* s2, \
|
||||
const char* names);
|
||||
DECLARE_DCHECK_STROP_IMPL(strcmp, true)
|
||||
DECLARE_DCHECK_STROP_IMPL(strcmp, false)
|
||||
DECLARE_DCHECK_STROP_IMPL(_stricmp, true)
|
||||
DECLARE_DCHECK_STROP_IMPL(_stricmp, false)
|
||||
#undef DECLARE_DCHECK_STROP_IMPL
|
||||
|
||||
// Helper macro for string comparisons.
|
||||
// Don't use this macro directly in your code, use CHECK_STREQ et al below.
|
||||
#define DCHECK_STROP(func, op, expected, s1, s2) \
|
||||
while (CheckOpString _result = \
|
||||
logging::Check##func##expected##Impl((s1), (s2), \
|
||||
#s1 " " #op " " #s2)) \
|
||||
LOG(FATAL) << *_result.str_
|
||||
|
||||
// String (char*) equality/inequality checks.
|
||||
// CASE versions are case-insensitive.
|
||||
//
|
||||
// Note that "s1" and "s2" may be temporary strings which are destroyed
|
||||
// by the compiler at the end of the current "full expression"
|
||||
// (e.g. DCHECK_STREQ(Foo().c_str(), Bar().c_str())).
|
||||
|
||||
#define DCHECK_STREQ(s1, s2) DCHECK_STROP(strcmp, ==, true, s1, s2)
|
||||
#define DCHECK_STRNE(s1, s2) DCHECK_STROP(strcmp, !=, false, s1, s2)
|
||||
#define DCHECK_STRCASEEQ(s1, s2) DCHECK_STROP(_stricmp, ==, true, s1, s2)
|
||||
#define DCHECK_STRCASENE(s1, s2) DCHECK_STROP(_stricmp, !=, false, s1, s2)
|
||||
|
||||
#define DCHECK_INDEX(I,A) DCHECK(I < (sizeof(A)/sizeof(A[0])))
|
||||
#define DCHECK_BOUND(B,A) DCHECK(B <= (sizeof(A)/sizeof(A[0])))
|
||||
|
||||
#else // NDEBUG
|
||||
// On a regular release build we want to be able to enable DCHECKS through the
|
||||
// command line.
|
||||
#define DLOG(severity) \
|
||||
true ? (void) 0 : logging::LogMessageVoidify() & LOG(severity)
|
||||
|
||||
#define DLOG_IF(severity, condition) \
|
||||
true ? (void) 0 : logging::LogMessageVoidify() & LOG(severity)
|
||||
|
||||
#define DLOG_ASSERT(condition) \
|
||||
true ? (void) 0 : LOG_ASSERT(condition)
|
||||
|
||||
enum { DEBUG_MODE = 0 };
|
||||
|
||||
// This macro can be followed by a sequence of stream parameters in
|
||||
// non-debug mode. The DCHECK and friends macros use this so that
|
||||
// the expanded expression DCHECK(foo) << "asdf" is still syntactically
|
||||
// valid, even though the expression will get optimized away.
|
||||
#define NDEBUG_EAT_STREAM_PARAMETERS \
|
||||
logging::LogMessage(__FILE__, __LINE__).stream()
|
||||
|
||||
// Set to true in InitLogging when we want to enable the dchecks in release.
|
||||
extern bool g_enable_dcheck;
|
||||
#define DCHECK(condition) \
|
||||
!logging::g_enable_dcheck ? void (0) : \
|
||||
LOG_IF(ERROR_REPORT, !(condition)) << "Check failed: " #condition ". "
|
||||
|
||||
// Helper macro for binary operators.
|
||||
// Don't use this macro directly in your code, use DCHECK_EQ et al below.
|
||||
#define DCHECK_OP(name, op, val1, val2) \
|
||||
if (logging::g_enable_dcheck) \
|
||||
if (logging::CheckOpString _result = \
|
||||
logging::Check##name##Impl((val1), (val2), #val1 " " #op " " #val2)) \
|
||||
logging::LogMessage(__FILE__, __LINE__, logging::LOG_ERROR_REPORT, \
|
||||
_result).stream()
|
||||
|
||||
#define DCHECK_STREQ(str1, str2) \
|
||||
while (false) NDEBUG_EAT_STREAM_PARAMETERS
|
||||
|
||||
#define DCHECK_STRCASEEQ(str1, str2) \
|
||||
while (false) NDEBUG_EAT_STREAM_PARAMETERS
|
||||
|
||||
#define DCHECK_STRNE(str1, str2) \
|
||||
while (false) NDEBUG_EAT_STREAM_PARAMETERS
|
||||
|
||||
#define DCHECK_STRCASENE(str1, str2) \
|
||||
while (false) NDEBUG_EAT_STREAM_PARAMETERS
|
||||
|
||||
#endif // NDEBUG
|
||||
|
||||
// Helper functions for DCHECK_OP macro.
|
||||
// The (int, int) specialization works around the issue that the compiler
|
||||
// will not instantiate the template version of the function on values of
|
||||
// unnamed enum type - see comment below.
|
||||
#define DEFINE_DCHECK_OP_IMPL(name, op) \
|
||||
template <class t1, class t2> \
|
||||
inline std::string* Check##name##Impl(const t1& v1, const t2& v2, \
|
||||
const char* names) { \
|
||||
if (v1 op v2) return NULL; \
|
||||
else return MakeCheckOpString(v1, v2, names); \
|
||||
} \
|
||||
inline std::string* Check##name##Impl(int v1, int v2, const char* names) { \
|
||||
if (v1 op v2) return NULL; \
|
||||
else return MakeCheckOpString(v1, v2, names); \
|
||||
}
|
||||
DEFINE_DCHECK_OP_IMPL(EQ, ==)
|
||||
DEFINE_DCHECK_OP_IMPL(NE, !=)
|
||||
DEFINE_DCHECK_OP_IMPL(LE, <=)
|
||||
DEFINE_DCHECK_OP_IMPL(LT, < )
|
||||
DEFINE_DCHECK_OP_IMPL(GE, >=)
|
||||
DEFINE_DCHECK_OP_IMPL(GT, > )
|
||||
#undef DEFINE_DCHECK_OP_IMPL
|
||||
|
||||
// Equality/Inequality checks - compare two values, and log a LOG_FATAL message
|
||||
// including the two values when the result is not as expected. The values
|
||||
// must have operator<<(ostream, ...) defined.
|
||||
//
|
||||
// You may append to the error message like so:
|
||||
// DCHECK_NE(1, 2) << ": The world must be ending!";
|
||||
//
|
||||
// We are very careful to ensure that each argument is evaluated exactly
|
||||
// once, and that anything which is legal to pass as a function argument is
|
||||
// legal here. In particular, the arguments may be temporary expressions
|
||||
// which will end up being destroyed at the end of the apparent statement,
|
||||
// for example:
|
||||
// DCHECK_EQ(string("abc")[1], 'b');
|
||||
//
|
||||
// WARNING: These may not compile correctly if one of the arguments is a pointer
|
||||
// and the other is NULL. To work around this, simply static_cast NULL to the
|
||||
// type of the desired pointer.
|
||||
|
||||
#define DCHECK_EQ(val1, val2) DCHECK_OP(EQ, ==, val1, val2)
|
||||
#define DCHECK_NE(val1, val2) DCHECK_OP(NE, !=, val1, val2)
|
||||
#define DCHECK_LE(val1, val2) DCHECK_OP(LE, <=, val1, val2)
|
||||
#define DCHECK_LT(val1, val2) DCHECK_OP(LT, < , val1, val2)
|
||||
#define DCHECK_GE(val1, val2) DCHECK_OP(GE, >=, val1, val2)
|
||||
#define DCHECK_GT(val1, val2) DCHECK_OP(GT, > , val1, val2)
|
||||
|
||||
#endif // OFFICIAL_BUILD
|
||||
|
||||
#define NOTREACHED() DCHECK(false)
|
||||
|
||||
// Redefine the standard assert to use our nice log files
|
||||
#undef assert
|
||||
#define assert(x) DLOG_ASSERT(x)
|
||||
|
||||
// This class more or less represents a particular log message. You
|
||||
// create an instance of LogMessage and then stream stuff to it.
|
||||
// When you finish streaming to it, ~LogMessage is called and the
|
||||
// full message gets streamed to the appropriate destination.
|
||||
//
|
||||
// You shouldn't actually use LogMessage's constructor to log things,
|
||||
// though. You should use the LOG() macro (and variants thereof)
|
||||
// above.
|
||||
class LogMessage {
|
||||
public:
|
||||
LogMessage(const char* file, int line, LogSeverity severity, int ctr);
|
||||
|
||||
// Two special constructors that generate reduced amounts of code at
|
||||
// LOG call sites for common cases.
|
||||
//
|
||||
// Used for LOG(INFO): Implied are:
|
||||
// severity = LOG_INFO, ctr = 0
|
||||
//
|
||||
// Using this constructor instead of the more complex constructor above
|
||||
// saves a couple of bytes per call site.
|
||||
LogMessage(const char* file, int line);
|
||||
|
||||
// Used for LOG(severity) where severity != INFO. Implied
|
||||
// are: ctr = 0
|
||||
//
|
||||
// Using this constructor instead of the more complex constructor above
|
||||
// saves a couple of bytes per call site.
|
||||
LogMessage(const char* file, int line, LogSeverity severity);
|
||||
|
||||
// A special constructor used for check failures.
|
||||
// Implied severity = LOG_FATAL
|
||||
LogMessage(const char* file, int line, const CheckOpString& result);
|
||||
|
||||
// A special constructor used for check failures, with the option to
|
||||
// specify severity.
|
||||
LogMessage(const char* file, int line, LogSeverity severity,
|
||||
const CheckOpString& result);
|
||||
|
||||
~LogMessage();
|
||||
|
||||
std::ostream& stream() { return stream_; }
|
||||
|
||||
private:
|
||||
void Init(const char* file, int line);
|
||||
|
||||
LogSeverity severity_;
|
||||
std::ostringstream stream_;
|
||||
size_t message_start_; // Offset of the start of the message (past prefix
|
||||
// info).
|
||||
#if defined(OS_WIN)
|
||||
// Stores the current value of GetLastError in the constructor and restores
|
||||
// it in the destructor by calling SetLastError.
|
||||
// This is useful since the LogMessage class uses a lot of Win32 calls
|
||||
// that will lose the value of GLE and the code that called the log function
|
||||
// will have lost the thread error value when the log call returns.
|
||||
class SaveLastError {
|
||||
public:
|
||||
SaveLastError();
|
||||
~SaveLastError();
|
||||
|
||||
unsigned long get_error() const { return last_error_; }
|
||||
|
||||
protected:
|
||||
unsigned long last_error_;
|
||||
};
|
||||
|
||||
SaveLastError last_error_;
|
||||
#endif
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(LogMessage);
|
||||
};
|
||||
|
||||
// A non-macro interface to the log facility; (useful
|
||||
// when the logging level is not a compile-time constant).
|
||||
inline void LogAtLevel(int const log_level, std::string const &msg) {
|
||||
LogMessage(__FILE__, __LINE__, log_level).stream() << msg;
|
||||
}
|
||||
|
||||
// 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&) { }
|
||||
};
|
||||
|
||||
// Closes the log file explicitly if open.
|
||||
// NOTE: Since the log file is opened as necessary by the action of logging
|
||||
// statements, there's no guarantee that it will stay closed
|
||||
// after this call.
|
||||
void CloseLogFile();
|
||||
|
||||
} // namespace logging
|
||||
|
||||
// These functions are provided as a convenience for logging, which is where we
|
||||
// use streams (it is against Google style to use streams in other places). It
|
||||
// is designed to allow you to emit non-ASCII Unicode strings to the log file,
|
||||
// which is normally ASCII. It is relatively slow, so try not to use it for
|
||||
// common cases. Non-ASCII characters will be converted to UTF-8 by these
|
||||
// operators.
|
||||
std::ostream& operator<<(std::ostream& out, const wchar_t* wstr);
|
||||
inline std::ostream& operator<<(std::ostream& out, const std::wstring& wstr) {
|
||||
return out << wstr.c_str();
|
||||
}
|
||||
|
||||
// The NOTIMPLEMENTED() macro annotates codepaths which have
|
||||
// not been implemented yet.
|
||||
//
|
||||
// The implementation of this macro is controlled by NOTIMPLEMENTED_POLICY:
|
||||
// 0 -- Do nothing (stripped by compiler)
|
||||
// 1 -- Warn at compile time
|
||||
// 2 -- Fail at compile time
|
||||
// 3 -- Fail at runtime (DCHECK)
|
||||
// 4 -- [default] LOG(ERROR) at runtime
|
||||
// 5 -- LOG(ERROR) at runtime, only once per call-site
|
||||
|
||||
#ifndef NOTIMPLEMENTED_POLICY
|
||||
// Select default policy: LOG(ERROR)
|
||||
#define NOTIMPLEMENTED_POLICY 4
|
||||
#endif
|
||||
|
||||
#if defined(COMPILER_GCC)
|
||||
// On Linux, with GCC, we can use __PRETTY_FUNCTION__ to get the demangled name
|
||||
// of the current function in the NOTIMPLEMENTED message.
|
||||
#define NOTIMPLEMENTED_MSG "Not implemented reached in " << __PRETTY_FUNCTION__
|
||||
#else
|
||||
#define NOTIMPLEMENTED_MSG "NOT IMPLEMENTED"
|
||||
#endif
|
||||
|
||||
#if NOTIMPLEMENTED_POLICY == 0
|
||||
#define NOTIMPLEMENTED() ;
|
||||
#elif NOTIMPLEMENTED_POLICY == 1
|
||||
// TODO, figure out how to generate a warning
|
||||
#define NOTIMPLEMENTED() COMPILE_ASSERT(false, NOT_IMPLEMENTED)
|
||||
#elif NOTIMPLEMENTED_POLICY == 2
|
||||
#define NOTIMPLEMENTED() COMPILE_ASSERT(false, NOT_IMPLEMENTED)
|
||||
#elif NOTIMPLEMENTED_POLICY == 3
|
||||
#define NOTIMPLEMENTED() NOTREACHED()
|
||||
#elif NOTIMPLEMENTED_POLICY == 4
|
||||
#define NOTIMPLEMENTED() LOG(ERROR) << NOTIMPLEMENTED_MSG
|
||||
#elif NOTIMPLEMENTED_POLICY == 5
|
||||
#define NOTIMPLEMENTED() do {\
|
||||
static int count = 0;\
|
||||
LOG_IF(ERROR, 0 == count++) << NOTIMPLEMENTED_MSG;\
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
#endif // CHROMIUM_MOZILLA_BUILD
|
||||
|
||||
#endif // BASE_LOGGING_H_
|
||||
|
|
|
@ -31,9 +31,7 @@
|
|||
#include "base/message_pump_android.h"
|
||||
#endif
|
||||
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
#include "MessagePump.h"
|
||||
#endif
|
||||
|
||||
using base::Time;
|
||||
using base::TimeDelta;
|
||||
|
@ -98,8 +96,6 @@ MessageLoop::MessageLoop(Type type)
|
|||
next_sequence_num_(0) {
|
||||
DCHECK(!current()) << "should only have one message loop per thread";
|
||||
lazy_tls_ptr.Pointer()->Set(this);
|
||||
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
if (type_ == TYPE_MOZILLA_UI) {
|
||||
pump_ = new mozilla::ipc::MessagePump();
|
||||
return;
|
||||
|
@ -108,7 +104,7 @@ MessageLoop::MessageLoop(Type type)
|
|||
pump_ = new mozilla::ipc::MessagePumpForChildProcess();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(OS_WIN)
|
||||
// TODO(rvargas): Get rid of the OS guards.
|
||||
if (type_ == TYPE_DEFAULT) {
|
||||
|
@ -209,15 +205,6 @@ void MessageLoop::RunHandler() {
|
|||
|
||||
void MessageLoop::RunInternal() {
|
||||
DCHECK(this == current());
|
||||
#if !defined(CHROMIUM_MOZILLA_BUILD)
|
||||
StartHistogrammer();
|
||||
#if defined(OS_WIN)
|
||||
if (state_->dispatcher) {
|
||||
pump_win()->RunWithDispatcher(this, state_->dispatcher);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
pump_->Run(this);
|
||||
}
|
||||
|
||||
|
@ -291,16 +278,7 @@ void MessageLoop::PostTask_Helper(
|
|||
scoped_refptr<base::MessagePump> pump;
|
||||
{
|
||||
AutoLock locked(incoming_queue_lock_);
|
||||
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
incoming_queue_.push(pending_task);
|
||||
#else
|
||||
bool was_empty = incoming_queue_.empty();
|
||||
incoming_queue_.push(pending_task);
|
||||
if (!was_empty)
|
||||
return; // Someone else should have started the sub-pump.
|
||||
#endif
|
||||
|
||||
pump = pump_;
|
||||
}
|
||||
// Since the incoming_queue_ may contain a task that destroys this message
|
||||
|
@ -317,11 +295,7 @@ void MessageLoop::SetNestableTasksAllowed(bool allowed) {
|
|||
if (!nestable_tasks_allowed_)
|
||||
return;
|
||||
// Start the native pump if we are not already pumping.
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
pump_->ScheduleWork();
|
||||
#else
|
||||
pump_->ScheduleWorkForNestedLoop();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -537,40 +511,14 @@ bool MessageLoop::PendingTask::operator<(const PendingTask& other) const {
|
|||
// Method and data for histogramming events and actions taken by each instance
|
||||
// on each thread.
|
||||
|
||||
#if !defined(CHROMIUM_MOZILLA_BUILD)
|
||||
// static
|
||||
bool MessageLoop::enable_histogrammer_ = false;
|
||||
#endif
|
||||
|
||||
// static
|
||||
void MessageLoop::EnableHistogrammer(bool enable) {
|
||||
#if !defined(CHROMIUM_MOZILLA_BUILD)
|
||||
enable_histogrammer_ = enable;
|
||||
#endif
|
||||
}
|
||||
|
||||
void MessageLoop::StartHistogrammer() {
|
||||
#if !defined(CHROMIUM_MOZILLA_BUILD)
|
||||
if (enable_histogrammer_ && !message_histogram_.get()
|
||||
&& base::StatisticsRecorder::IsActive()) {
|
||||
DCHECK(!thread_name_.empty());
|
||||
message_histogram_.reset(static_cast<base::LinearHistogram*>(
|
||||
base::LinearHistogram::FactoryGet(("MsgLoop:" + thread_name_).c_str(),
|
||||
kLeastNonZeroMessageId,
|
||||
kMaxMessageId,
|
||||
kNumberOfDistinctMessagesDisplayed,
|
||||
base::Histogram::kNoFlags)));
|
||||
message_histogram_->SetFlags(message_histogram_->kHexRangePrintingFlag);
|
||||
message_histogram_->SetRangeDescriptions(event_descriptions_);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void MessageLoop::HistogramEvent(int event) {
|
||||
#if !defined(CHROMIUM_MOZILLA_BUILD)
|
||||
if (message_histogram_.get())
|
||||
message_histogram_->Add(event);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Provide a macro that takes an expression (such as a constant, or macro
|
||||
|
@ -589,20 +537,6 @@ void MessageLoop::HistogramEvent(int event) {
|
|||
// in the pair (i.e., the quoted string) when printing out a histogram.
|
||||
#define VALUE_TO_NUMBER_AND_NAME(name) {name, #name},
|
||||
|
||||
#if !defined(CHROMIUM_MOZILLA_BUILD)
|
||||
// static
|
||||
const base::LinearHistogram::DescriptionPair MessageLoop::event_descriptions_[] = {
|
||||
// Provide some pretty print capability in our histogram for our internal
|
||||
// messages.
|
||||
|
||||
// A few events we handle (kindred to messages), and used to profile actions.
|
||||
VALUE_TO_NUMBER_AND_NAME(kTaskRunEvent)
|
||||
VALUE_TO_NUMBER_AND_NAME(kTimerEvent)
|
||||
|
||||
{-1, NULL} // The list must be null terminated, per API to histogram.
|
||||
};
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// MessageLoopForUI
|
||||
|
||||
|
@ -662,7 +596,6 @@ bool MessageLoopForIO::WatchFileDescriptor(int fd,
|
|||
delegate);
|
||||
}
|
||||
|
||||
#if defined(CHROMIUM_MOZILLA_BUILD)
|
||||
bool
|
||||
MessageLoopForIO::CatchSignal(int sig,
|
||||
SignalEvent* sigevent,
|
||||
|
@ -670,6 +603,5 @@ MessageLoopForIO::CatchSignal(int sig,
|
|||
{
|
||||
return pump_libevent()->CatchSignal(sig, sigevent, delegate);
|
||||
}
|
||||
#endif // defined(CHROMIUM_MOZILLA_BUILD)
|
||||
|
||||
#endif
|
||||
|
|
|
@ -10,12 +10,8 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#if defined(CHROMIUM_MOZILLA_BUILD)
|
||||
#include <map>
|
||||
#include "base/lock.h"
|
||||
#else
|
||||
#include "base/histogram.h"
|
||||
#endif
|
||||
#include "base/message_pump.h"
|
||||
#include "base/observer_list.h"
|
||||
#include "base/ref_counted.h"
|
||||
|
@ -31,7 +27,6 @@
|
|||
#include "base/message_pump_libevent.h"
|
||||
#endif
|
||||
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
namespace mozilla {
|
||||
namespace ipc {
|
||||
|
||||
|
@ -39,7 +34,6 @@ class DoWorkRunnable;
|
|||
|
||||
} /* namespace ipc */
|
||||
} /* namespace mozilla */
|
||||
#endif
|
||||
|
||||
// A MessageLoop is used to process events for a particular thread. There is
|
||||
// at most one MessageLoop instance per thread.
|
||||
|
@ -73,9 +67,7 @@ class DoWorkRunnable;
|
|||
//
|
||||
class MessageLoop : public base::MessagePump::Delegate {
|
||||
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
friend class mozilla::ipc::DoWorkRunnable;
|
||||
#endif
|
||||
|
||||
public:
|
||||
static void EnableHistogrammer(bool enable_histogrammer);
|
||||
|
@ -212,11 +204,9 @@ public:
|
|||
enum Type {
|
||||
TYPE_DEFAULT,
|
||||
TYPE_UI,
|
||||
TYPE_IO
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
, TYPE_MOZILLA_CHILD
|
||||
, TYPE_MOZILLA_UI
|
||||
#endif
|
||||
TYPE_IO,
|
||||
TYPE_MOZILLA_CHILD,
|
||||
TYPE_MOZILLA_UI
|
||||
};
|
||||
|
||||
// Normally, it is not necessary to instantiate a MessageLoop. Instead, it
|
||||
|
@ -390,11 +380,6 @@ public:
|
|||
// If message_histogram_ is NULL, this is a no-op.
|
||||
void HistogramEvent(int event);
|
||||
|
||||
#if !defined(CHROMIUM_MOZILLA_BUILD)
|
||||
static const base::LinearHistogram::DescriptionPair event_descriptions_[];
|
||||
static bool enable_histogrammer_;
|
||||
#endif
|
||||
|
||||
Type type_;
|
||||
|
||||
// A list of tasks that need to be processed by this instance. Note that
|
||||
|
@ -420,10 +405,7 @@ public:
|
|||
bool exception_restoration_;
|
||||
|
||||
std::string thread_name_;
|
||||
#if !defined(CHROMIUM_MOZILLA_BUILD)
|
||||
// A profiling histogram showing the counts of various messages and events.
|
||||
scoped_ptr<base::LinearHistogram> message_histogram_;
|
||||
#endif
|
||||
|
||||
// A null terminated list which creates an incoming_queue of tasks that are
|
||||
// aquired under a mutex for processing on this instance's thread. These tasks
|
||||
// have not yet been sorted out into items for our work_queue_ vs items that
|
||||
|
@ -463,14 +445,10 @@ class MessageLoopForUI : public MessageLoop {
|
|||
MessageLoop* loop = MessageLoop::current();
|
||||
if (!loop)
|
||||
return NULL;
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
Type type = loop->type();
|
||||
DCHECK(type == MessageLoop::TYPE_UI ||
|
||||
type == MessageLoop::TYPE_MOZILLA_UI ||
|
||||
type == MessageLoop::TYPE_MOZILLA_CHILD);
|
||||
#else
|
||||
DCHECK_EQ(MessageLoop::TYPE_UI, loop->type());
|
||||
#endif
|
||||
return static_cast<MessageLoopForUI*>(loop);
|
||||
}
|
||||
|
||||
|
@ -551,13 +529,11 @@ class MessageLoopForIO : public MessageLoop {
|
|||
FileDescriptorWatcher *controller,
|
||||
Watcher *delegate);
|
||||
|
||||
#if defined(CHROMIUM_MOZILLA_BUILD)
|
||||
typedef base::MessagePumpLibevent::SignalEvent SignalEvent;
|
||||
typedef base::MessagePumpLibevent::SignalWatcher SignalWatcher;
|
||||
bool CatchSignal(int sig,
|
||||
SignalEvent* sigevent,
|
||||
SignalWatcher* delegate);
|
||||
#endif // defined(CHROMIUM_MOZILLA_BUILD)
|
||||
|
||||
#endif // defined(OS_POSIX)
|
||||
};
|
||||
|
|
|
@ -111,7 +111,6 @@ class MessagePump : public RefCountedThreadSafe<MessagePump> {
|
|||
// until it returns a value of false.
|
||||
virtual void ScheduleWork() = 0;
|
||||
|
||||
#if defined(CHROMIUM_MOZILLA_BUILD)
|
||||
// This method may only called from the thread that called Run.
|
||||
//
|
||||
// Ensure that DoWork will be called if a nested loop is entered.
|
||||
|
@ -119,7 +118,6 @@ class MessagePump : public RefCountedThreadSafe<MessagePump> {
|
|||
// "reasonably soon", this method can be a no-op to avoid expensive
|
||||
// atomic tests and/or syscalls required for ScheduleWork().
|
||||
virtual void ScheduleWorkForNestedLoop() { ScheduleWork(); };
|
||||
#endif // defined(CHROMIUM_MOZILLA_BUILD)
|
||||
|
||||
// Schedule a DoDelayedWork callback to happen at the specified time,
|
||||
// cancelling any pending DoDelayedWork callback. This method may only be
|
||||
|
|
|
@ -22,11 +22,7 @@ class MessagePumpDefault : public MessagePump {
|
|||
virtual void ScheduleWork();
|
||||
virtual void ScheduleDelayedWork(const Time& delayed_work_time);
|
||||
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
protected:
|
||||
#else
|
||||
private:
|
||||
#endif
|
||||
// This flag is set to false when Run should return.
|
||||
bool keep_running_;
|
||||
|
||||
|
@ -36,9 +32,7 @@ class MessagePumpDefault : public MessagePump {
|
|||
// The time at which we should call DoDelayedWork.
|
||||
Time delayed_work_time_;
|
||||
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
private:
|
||||
#endif
|
||||
DISALLOW_COPY_AND_ASSIGN(MessagePumpDefault);
|
||||
};
|
||||
|
||||
|
|
|
@ -212,7 +212,6 @@ void MessagePumpLibevent::OnLibeventNotification(int fd, short flags,
|
|||
}
|
||||
|
||||
|
||||
#if defined(CHROMIUM_MOZILLA_BUILD)
|
||||
MessagePumpLibevent::SignalEvent::SignalEvent() :
|
||||
event_(NULL)
|
||||
{
|
||||
|
@ -293,7 +292,6 @@ MessagePumpLibevent::OnLibeventSignalNotification(int sig, short flags,
|
|||
DCHECK(context);
|
||||
reinterpret_cast<SignalWatcher*>(context)->OnSignal(sig);
|
||||
}
|
||||
#endif // defined(CHROMIUM_MOZILLA_BUILD)
|
||||
|
||||
|
||||
// Reentrant!
|
||||
|
|
|
@ -85,7 +85,6 @@ class MessagePumpLibevent : public MessagePump {
|
|||
Watcher *delegate);
|
||||
|
||||
|
||||
#if defined(CHROMIUM_MOZILLA_BUILD)
|
||||
// This is analagous to FileDescriptorWatcher above, which really is
|
||||
// just a wrapper around libevent's |struct event|. This class acts
|
||||
// as a sort of "scoped event watcher" in that it guarantees that
|
||||
|
@ -129,7 +128,6 @@ class MessagePumpLibevent : public MessagePump {
|
|||
bool CatchSignal(int sig,
|
||||
SignalEvent* sigevent,
|
||||
SignalWatcher* delegate);
|
||||
#endif // defined(CHROMIUM_MOZILLA_BUILD)
|
||||
|
||||
|
||||
// MessagePump methods:
|
||||
|
@ -160,11 +158,9 @@ class MessagePumpLibevent : public MessagePump {
|
|||
static void OnLibeventNotification(int fd, short flags,
|
||||
void* context);
|
||||
|
||||
#if defined(CHROMIUM_MOZILLA_BUILD)
|
||||
// Called by libevent upon receiving a signal
|
||||
static void OnLibeventSignalNotification(int sig, short flags,
|
||||
void* context);
|
||||
#endif
|
||||
|
||||
// Unix pipe used to implement ScheduleWork()
|
||||
// ... callback; called by libevent inside Run() when pipe is ready to read
|
||||
|
|
|
@ -15,11 +15,7 @@
|
|||
const int Pickle::kPayloadUnit = 64;
|
||||
|
||||
// We mark a read only pickle with a special capacity_.
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
static const uint32 kCapacityReadOnly = (uint32) -1;
|
||||
#else
|
||||
static const size_t kCapacityReadOnly = (size_t) -1;
|
||||
#endif
|
||||
|
||||
// Payload is uint32 aligned.
|
||||
|
||||
|
@ -37,11 +33,7 @@ Pickle::Pickle(int header_size)
|
|||
header_size_(AlignInt(header_size, sizeof(uint32))),
|
||||
capacity_(0),
|
||||
variable_buffer_offset_(0) {
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
DCHECK(static_cast<uint32>(header_size) >= sizeof(Header));
|
||||
#else
|
||||
DCHECK(static_cast<size_t>(header_size) >= sizeof(Header));
|
||||
#endif
|
||||
DCHECK(header_size <= kPayloadUnit);
|
||||
Resize(kPayloadUnit);
|
||||
header_->payload_size = 0;
|
||||
|
@ -61,11 +53,7 @@ Pickle::Pickle(const Pickle& other)
|
|||
header_size_(other.header_size_),
|
||||
capacity_(0),
|
||||
variable_buffer_offset_(other.variable_buffer_offset_) {
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
uint32 payload_size = header_size_ + other.header_->payload_size;
|
||||
#else
|
||||
size_t payload_size = header_size_ + other.header_->payload_size;
|
||||
#endif
|
||||
bool resized = Resize(payload_size);
|
||||
CHECK(resized); // Realloc failed.
|
||||
memcpy(header_, other.header_, payload_size);
|
||||
|
@ -399,21 +387,12 @@ bool Pickle::ReadData(void** iter, const char** data, int* length) const {
|
|||
return ReadBytes(iter, data, *length);
|
||||
}
|
||||
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
char* Pickle::BeginWrite(uint32 length) {
|
||||
#else
|
||||
char* Pickle::BeginWrite(size_t length) {
|
||||
#endif
|
||||
// write at a uint32-aligned offset from the beginning of the header
|
||||
uint32 offset = AlignInt(header_->payload_size, sizeof(uint32));
|
||||
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
uint32 new_size = offset + AlignInt(length, sizeof(uint32));
|
||||
uint32 needed_size = header_size_ + new_size;
|
||||
#else
|
||||
size_t new_size = offset + length;
|
||||
size_t needed_size = header_size_ + new_size;
|
||||
#endif
|
||||
|
||||
if (needed_size > capacity_ && !Resize(std::max(capacity_ * 2, needed_size)))
|
||||
return NULL;
|
||||
|
||||
|
@ -509,11 +488,7 @@ void Pickle::TrimWriteData(int new_length) {
|
|||
*cur_length = new_length;
|
||||
}
|
||||
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
bool Pickle::Resize(uint32 new_capacity) {
|
||||
#else
|
||||
bool Pickle::Resize(size_t new_capacity) {
|
||||
#endif
|
||||
new_capacity = AlignInt(new_capacity, kPayloadUnit);
|
||||
|
||||
void* p = realloc(header_, new_capacity);
|
||||
|
@ -526,19 +501,11 @@ bool Pickle::Resize(size_t new_capacity) {
|
|||
}
|
||||
|
||||
// static
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
const char* Pickle::FindNext(uint32 header_size,
|
||||
#else
|
||||
const char* Pickle::FindNext(size_t header_size,
|
||||
#endif
|
||||
const char* start,
|
||||
const char* end) {
|
||||
DCHECK(header_size == AlignInt(header_size, sizeof(uint32)));
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
DCHECK(header_size <= static_cast<uint32>(kPayloadUnit));
|
||||
#else
|
||||
DCHECK(header_size <= static_cast<size_t>(kPayloadUnit));
|
||||
#endif
|
||||
|
||||
const Header* hdr = reinterpret_cast<const Header*>(start);
|
||||
const char* payload_base = start + header_size;
|
||||
|
|
|
@ -170,11 +170,9 @@ class Pickle {
|
|||
// not been changed.
|
||||
void TrimWriteData(int length);
|
||||
|
||||
#if defined(CHROMIUM_MOZILLA_BUILD)
|
||||
void EndRead(void* iter) const {
|
||||
DCHECK(iter == end_of_payload());
|
||||
}
|
||||
#endif
|
||||
|
||||
// Payload follows after allocation of Header (header size is customizable).
|
||||
struct Header {
|
||||
|
@ -207,11 +205,7 @@ class Pickle {
|
|||
}
|
||||
|
||||
protected:
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
uint32 payload_size() const { return header_->payload_size; }
|
||||
#else
|
||||
size_t payload_size() const { return header_->payload_size; }
|
||||
#endif
|
||||
|
||||
char* payload() {
|
||||
return reinterpret_cast<char*>(header_) + header_size_;
|
||||
|
@ -229,11 +223,7 @@ class Pickle {
|
|||
return payload() + payload_size();
|
||||
}
|
||||
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
uint32 capacity() const {
|
||||
#else
|
||||
size_t capacity() const {
|
||||
#endif
|
||||
return capacity_;
|
||||
}
|
||||
|
||||
|
@ -241,11 +231,7 @@ class Pickle {
|
|||
// location that the data should be written at is returned, or NULL if there
|
||||
// was an error. Call EndWrite with the returned offset and the given length
|
||||
// to pad out for the next write.
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
char* BeginWrite(uint32 length);
|
||||
#else
|
||||
char* BeginWrite(size_t length);
|
||||
#endif
|
||||
|
||||
// Completes the write operation by padding the data with NULL bytes until it
|
||||
// is padded. Should be paired with BeginWrite, but it does not necessarily
|
||||
|
@ -256,18 +242,10 @@ class Pickle {
|
|||
// the header: new_capacity = sizeof(Header) + desired_payload_capacity.
|
||||
// A realloc() failure will cause a Resize failure... and caller should check
|
||||
// the return result for true (i.e., successful resizing).
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
bool Resize(uint32 new_capacity);
|
||||
#else
|
||||
bool Resize(size_t new_capacity);
|
||||
#endif
|
||||
|
||||
// Aligns 'i' by rounding it up to the next multiple of 'alignment'
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
static uint32 AlignInt(uint32 i, int alignment) {
|
||||
#else
|
||||
static size_t AlignInt(size_t i, int alignment) {
|
||||
#endif
|
||||
return i + (alignment - (i % alignment)) % alignment;
|
||||
}
|
||||
|
||||
|
@ -280,11 +258,7 @@ class Pickle {
|
|||
|
||||
// Find the end of the pickled data that starts at range_start. Returns NULL
|
||||
// if the entire Pickle is not found in the given data range.
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
static const char* FindNext(uint32 header_size,
|
||||
#else
|
||||
static const char* FindNext(size_t header_size,
|
||||
#endif
|
||||
const char* range_start,
|
||||
const char* range_end);
|
||||
|
||||
|
@ -293,17 +267,9 @@ class Pickle {
|
|||
|
||||
private:
|
||||
Header* header_;
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
uint32 header_size_;
|
||||
uint32 capacity_;
|
||||
uint32 variable_buffer_offset_;
|
||||
#else
|
||||
size_t header_size_; // Supports extra data between header and payload.
|
||||
// Allocation size of payload (or -1 if allocation is const).
|
||||
size_t capacity_;
|
||||
size_t variable_buffer_offset_; // IF non-zero, then offset to a buffer.
|
||||
#endif
|
||||
|
||||
FRIEND_TEST(PickleTest, Resize);
|
||||
FRIEND_TEST(PickleTest, FindNext);
|
||||
FRIEND_TEST(PickleTest, IteratorHasRoom);
|
||||
|
|
|
@ -40,16 +40,7 @@ namespace base {
|
|||
// for this purpose. MSVC does not provide va_copy, so define an
|
||||
// implementation here. It is not guaranteed that assignment is a copy, so the
|
||||
// StringUtil.VariableArgsFunc unit test tests this capability.
|
||||
#if !defined(CHROMIUM_MOZILLA_BUILD)
|
||||
inline void va_copy(va_list& a, va_list& b) {
|
||||
#if defined(COMPILER_GCC)
|
||||
::va_copy(a, b);
|
||||
#elif defined(COMPILER_MSVC)
|
||||
a = b;
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
// The C standard says that va_copy is a "macro", not a function. Trying to
|
||||
// use va_list as ref args to a function, as above, breaks some machines.
|
||||
# if defined(COMPILER_GCC)
|
||||
|
@ -60,8 +51,6 @@ inline void va_copy(va_list& a, va_list& b) {
|
|||
# error No va_copy for your compiler
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace base
|
||||
|
||||
// Define an OS-neutral wrapper for shared library entry points
|
||||
|
|
|
@ -32,20 +32,16 @@ static mozilla::EnvironmentLog gProcessLog("MOZ_PROCESS_LOG");
|
|||
|
||||
namespace base {
|
||||
|
||||
#if defined(CHROMIUM_MOZILLA_BUILD)
|
||||
bool LaunchApp(const std::vector<std::string>& argv,
|
||||
const file_handle_mapping_vector& fds_to_remap,
|
||||
bool wait, ProcessHandle* process_handle) {
|
||||
return LaunchApp(argv, fds_to_remap, environment_map(),
|
||||
wait, process_handle);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool LaunchApp(const std::vector<std::string>& argv,
|
||||
const file_handle_mapping_vector& fds_to_remap,
|
||||
#if defined(CHROMIUM_MOZILLA_BUILD)
|
||||
const environment_map& env_vars_to_set,
|
||||
#endif
|
||||
bool wait, ProcessHandle* process_handle,
|
||||
ProcessArchitecture arch) {
|
||||
pid_t pid = fork();
|
||||
|
@ -64,23 +60,19 @@ bool LaunchApp(const std::vector<std::string>& argv,
|
|||
|
||||
CloseSuperfluousFds(fd_shuffle);
|
||||
|
||||
#if defined(CHROMIUM_MOZILLA_BUILD)
|
||||
for (environment_map::const_iterator it = env_vars_to_set.begin();
|
||||
it != env_vars_to_set.end(); ++it) {
|
||||
if (setenv(it->first.c_str(), it->second.c_str(), 1/*overwrite*/))
|
||||
exit(127);
|
||||
}
|
||||
#endif
|
||||
|
||||
scoped_array<char*> argv_cstr(new char*[argv.size() + 1]);
|
||||
for (size_t i = 0; i < argv.size(); i++)
|
||||
argv_cstr[i] = const_cast<char*>(argv[i].c_str());
|
||||
argv_cstr[argv.size()] = NULL;
|
||||
execvp(argv_cstr[0], argv_cstr.get());
|
||||
#if defined(CHROMIUM_MOZILLA_BUILD)
|
||||
// if we get here, we're in serious trouble and should complain loudly
|
||||
DLOG(ERROR) << "FAILED TO exec() CHILD PROCESS, path: " << argv_cstr[0];
|
||||
#endif
|
||||
exit(127);
|
||||
} else {
|
||||
gProcessLog.print("==> process %d launched child process %d\n",
|
||||
|
|
|
@ -321,36 +321,6 @@ bool DidProcessCrash(bool* child_exited, ProcessHandle handle) {
|
|||
return false;
|
||||
}
|
||||
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
// All other exit codes indicate crashes.
|
||||
|
||||
// TODO(jar): Remove histogramming code when UMA stats are consistent with
|
||||
// other crash metrics.
|
||||
// Histogram the low order 3 nibbles for UMA
|
||||
const int kLeastValue = 0;
|
||||
const int kMaxValue = 0xFFF;
|
||||
const int kBucketCount = kMaxValue - kLeastValue + 1;
|
||||
static LinearHistogram least_significant_histogram("ExitCodes.LSNibbles",
|
||||
kLeastValue + 1, kMaxValue, kBucketCount);
|
||||
least_significant_histogram.SetFlags(kUmaTargetedHistogramFlag |
|
||||
LinearHistogram::kHexRangePrintingFlag);
|
||||
least_significant_histogram.Add(exitcode & 0xFFF);
|
||||
|
||||
// Histogram the high order 3 nibbles
|
||||
static LinearHistogram most_significant_histogram("ExitCodes.MSNibbles",
|
||||
kLeastValue + 1, kMaxValue, kBucketCount);
|
||||
most_significant_histogram.SetFlags(kUmaTargetedHistogramFlag |
|
||||
LinearHistogram::kHexRangePrintingFlag);
|
||||
// Avoid passing in negative numbers by shifting data into low end of dword.
|
||||
most_significant_histogram.Add((exitcode >> 20) & 0xFFF);
|
||||
|
||||
// Histogram the middle order 2 nibbles
|
||||
static LinearHistogram mid_significant_histogram("ExitCodes.MidNibbles",
|
||||
1, 0xFF, 0x100);
|
||||
mid_significant_histogram.SetFlags(kUmaTargetedHistogramFlag |
|
||||
LinearHistogram::kHexRangePrintingFlag);
|
||||
mid_significant_histogram.Add((exitcode >> 12) & 0xFF);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -67,11 +67,7 @@ class SharedMemory {
|
|||
// opens the existing shared memory and ignores the size parameter.
|
||||
// If name is the empty string, use a unique name.
|
||||
// Returns true on success, false on failure.
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
bool Create(const std::string& name, bool read_only, bool open_existing,
|
||||
#else
|
||||
bool Create(const std::wstring& name, bool read_only, bool open_existing,
|
||||
#endif
|
||||
size_t size);
|
||||
|
||||
// Deletes resources associated with a shared memory segment based on name.
|
||||
|
|
|
@ -70,17 +70,11 @@ SharedMemoryHandle SharedMemory::NULLHandle() {
|
|||
return SharedMemoryHandle();
|
||||
}
|
||||
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
bool SharedMemory::Create(const std::string &cname, bool read_only,
|
||||
#else
|
||||
bool SharedMemory::Create(const std::wstring &name, bool read_only,
|
||||
#endif
|
||||
bool open_existing, size_t size) {
|
||||
read_only_ = read_only;
|
||||
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
std::wstring name = UTF8ToWide(cname);
|
||||
#endif
|
||||
|
||||
int posix_flags = 0;
|
||||
posix_flags |= read_only ? O_RDONLY : O_RDWR;
|
||||
|
|
|
@ -6,9 +6,7 @@
|
|||
|
||||
#include "base/logging.h"
|
||||
#include "base/win_util.h"
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
# include "base/string_util.h"
|
||||
#endif
|
||||
#include "base/string_util.h"
|
||||
|
||||
namespace base {
|
||||
|
||||
|
@ -58,18 +56,10 @@ SharedMemoryHandle SharedMemory::NULLHandle() {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
bool SharedMemory::Create(const std::string &cname, bool read_only,
|
||||
#else
|
||||
bool SharedMemory::Create(const std::wstring &name, bool read_only,
|
||||
#endif
|
||||
bool open_existing, size_t size) {
|
||||
DCHECK(mapped_file_ == NULL);
|
||||
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
std::wstring name = UTF8ToWide(cname);
|
||||
#endif
|
||||
|
||||
name_ = name;
|
||||
read_only_ = read_only;
|
||||
mapped_file_ = CreateFileMapping(INVALID_HANDLE_VALUE, NULL,
|
||||
|
|
|
@ -170,12 +170,7 @@ StatsTablePrivate* StatsTablePrivate::New(const std::string& name,
|
|||
int max_threads,
|
||||
int max_counters) {
|
||||
scoped_ptr<StatsTablePrivate> priv(new StatsTablePrivate());
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
if (!priv->shared_memory_.Create(name, false, true,
|
||||
#else
|
||||
if (!priv->shared_memory_.Create(base::SysUTF8ToWide(name), false, true,
|
||||
#endif
|
||||
size))
|
||||
if (!priv->shared_memory_.Create(name, false, true, size))
|
||||
return NULL;
|
||||
if (!priv->shared_memory_.Map(size))
|
||||
return NULL;
|
||||
|
|
|
@ -69,10 +69,4 @@ char16* c16memset(char16* s, char16 c, size_t n) {
|
|||
|
||||
template class std::basic_string<char16, base::string16_char_traits>;
|
||||
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
std::ostream& operator<<(std::ostream& out, const string16& str) {
|
||||
return out << UTF16ToUTF8(str);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // WCHAR_T_IS_UTF32
|
||||
|
|
|
@ -23,9 +23,6 @@
|
|||
#include "base/basictypes.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/singleton.h"
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
#include "base/third_party/dmg_fp/dmg_fp.h"
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -249,47 +246,6 @@ class HexString16ToLongTraits {
|
|||
}
|
||||
};
|
||||
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
class StringToDoubleTraits {
|
||||
public:
|
||||
typedef std::string string_type;
|
||||
typedef double value_type;
|
||||
static inline value_type convert_func(const string_type::value_type* str,
|
||||
string_type::value_type** endptr) {
|
||||
return dmg_fp::strtod(str, endptr);
|
||||
}
|
||||
static inline bool valid_func(const string_type& str) {
|
||||
return !str.empty() && !isspace(str[0]);
|
||||
}
|
||||
};
|
||||
|
||||
class String16ToDoubleTraits {
|
||||
public:
|
||||
typedef string16 string_type;
|
||||
typedef double value_type;
|
||||
static inline value_type convert_func(const string_type::value_type* str,
|
||||
string_type::value_type** endptr) {
|
||||
// Because dmg_fp::strtod does not like char16, we convert it to ASCII.
|
||||
// In theory, this should be safe, but it's possible that 16-bit chars
|
||||
// might get ignored by accident causing something to be parsed when it
|
||||
// shouldn't.
|
||||
std::string ascii_string = UTF16ToASCII(string16(str));
|
||||
char* ascii_end = NULL;
|
||||
value_type ret = dmg_fp::strtod(ascii_string.c_str(), &ascii_end);
|
||||
if (ascii_string.c_str() + ascii_string.length() == ascii_end) {
|
||||
// Put endptr at end of input string, so it's not recognized as an error.
|
||||
*endptr =
|
||||
const_cast<string_type::value_type*>(str) + ascii_string.length();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
static inline bool valid_func(const string_type& str) {
|
||||
return !str.empty() && !iswspace(str[0]);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
|
@ -335,9 +291,7 @@ bool IsWprintfFormatPortable(const wchar_t* format) {
|
|||
|
||||
} // namespace base
|
||||
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
namespace base {
|
||||
#endif
|
||||
|
||||
const std::string& EmptyString() {
|
||||
return Singleton<EmptyStrings>::get()->s;
|
||||
|
@ -351,9 +305,7 @@ const string16& EmptyString16() {
|
|||
return Singleton<EmptyStrings>::get()->s16;
|
||||
}
|
||||
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
}
|
||||
#endif
|
||||
|
||||
const wchar_t kWhitespaceWide[] = {
|
||||
0x0009, // <control-0009> to <control-000D>
|
||||
|
@ -765,11 +717,7 @@ bool StartsWith(const std::wstring& str,
|
|||
if (search.size() > str.size())
|
||||
return false;
|
||||
return std::equal(search.begin(), search.end(), str.begin(),
|
||||
#if defined(CHROMIUM_MOZILLA_BUILD)
|
||||
chromium_CaseInsensitiveCompare<wchar_t>());
|
||||
#else
|
||||
CaseInsensitiveCompare<wchar_t>());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -944,11 +892,7 @@ static void StringAppendVT(StringType* dst,
|
|||
typename StringType::value_type stack_buf[1024];
|
||||
|
||||
va_list backup_ap;
|
||||
#if !defined(CHROMIUM_MOZILLA_BUILD)
|
||||
base::va_copy(backup_ap, ap);
|
||||
#else
|
||||
base_va_copy(backup_ap, ap);
|
||||
#endif // !defined(CHROMIUM_MOZILLA_BUILD)
|
||||
|
||||
#if !defined(OS_WIN)
|
||||
errno = 0;
|
||||
|
@ -995,11 +939,7 @@ static void StringAppendVT(StringType* dst,
|
|||
std::vector<typename StringType::value_type> mem_buf(mem_length);
|
||||
|
||||
// Restore the va_list before we use it again.
|
||||
#if !defined(CHROMIUM_MOZILLA_BUILD)
|
||||
base::va_copy(backup_ap, ap);
|
||||
#else
|
||||
base_va_copy(backup_ap, ap);
|
||||
#endif // !defined(CHROMIUM_MOZILLA_BUILD)
|
||||
|
||||
result = vsnprintfT(&mem_buf[0], mem_length, format, ap);
|
||||
va_end(backup_ap);
|
||||
|
@ -1111,19 +1051,6 @@ std::wstring Uint64ToWString(uint64 value) {
|
|||
IntToString(value);
|
||||
}
|
||||
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
std::string DoubleToString(double value) {
|
||||
// According to g_fmt.cc, it is sufficient to declare a buffer of size 32.
|
||||
char buffer[32];
|
||||
dmg_fp::g_fmt(buffer, value);
|
||||
return std::string(buffer);
|
||||
}
|
||||
|
||||
std::wstring DoubleToWString(double value) {
|
||||
return ASCIIToWide(DoubleToString(value));
|
||||
}
|
||||
#endif
|
||||
|
||||
void StringAppendV(std::string* dst, const char* format, va_list ap) {
|
||||
StringAppendVT(dst, format, ap);
|
||||
}
|
||||
|
@ -1495,7 +1422,7 @@ bool MatchPattern(const std::string& eval, const std::string& pattern) {
|
|||
|
||||
// XXX Sigh.
|
||||
|
||||
#if !defined(ARCH_CPU_64_BITS) || !defined(CHROMIUM_MOZILLA_BUILD)
|
||||
#if !defined(ARCH_CPU_64_BITS)
|
||||
bool StringToInt(const std::string& input, int* output) {
|
||||
COMPILE_ASSERT(sizeof(int) == sizeof(long), cannot_strtol_to_int);
|
||||
return StringToNumber<StringToLongTraits>(input,
|
||||
|
@ -1528,7 +1455,7 @@ bool StringToInt(const string16& input, int* output) {
|
|||
*output = static_cast<int>(tmp);
|
||||
return true;
|
||||
}
|
||||
#endif // !defined(ARCH_CPU_64_BITS) || !defined(CHROMIUM_MOZILLA_BUILD)
|
||||
#endif // !defined(ARCH_CPU_64_BITS)
|
||||
|
||||
bool StringToInt64(const std::string& input, int64* output) {
|
||||
return StringToNumber<StringToInt64Traits>(input, output);
|
||||
|
@ -1538,7 +1465,7 @@ bool StringToInt64(const string16& input, int64* output) {
|
|||
return StringToNumber<String16ToInt64Traits>(input, output);
|
||||
}
|
||||
|
||||
#if !defined(ARCH_CPU_64_BITS) || !defined(CHROMIUM_MOZILLA_BUILD)
|
||||
#if !defined(ARCH_CPU_64_BITS)
|
||||
bool HexStringToInt(const std::string& input, int* output) {
|
||||
COMPILE_ASSERT(sizeof(int) == sizeof(long), cannot_strtol_to_int);
|
||||
return StringToNumber<HexStringToLongTraits>(input,
|
||||
|
@ -1572,7 +1499,7 @@ bool HexStringToInt(const string16& input, int* output) {
|
|||
return true;
|
||||
}
|
||||
|
||||
#endif // !defined(ARCH_CPU_64_BITS) || !defined(CHROMIUM_MOZILLA_BUILD)
|
||||
#endif // !defined(ARCH_CPU_64_BITS)
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -1652,28 +1579,6 @@ int HexStringToInt(const string16& value) {
|
|||
return result;
|
||||
}
|
||||
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
bool StringToDouble(const std::string& input, double* output) {
|
||||
return StringToNumber<StringToDoubleTraits>(input, output);
|
||||
}
|
||||
|
||||
bool StringToDouble(const string16& input, double* output) {
|
||||
return StringToNumber<String16ToDoubleTraits>(input, output);
|
||||
}
|
||||
|
||||
double StringToDouble(const std::string& value) {
|
||||
double result;
|
||||
StringToDouble(value, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
double StringToDouble(const string16& value) {
|
||||
double result;
|
||||
StringToDouble(value, &result);
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
// The following code is compatible with the OpenBSD lcpy interface. See:
|
||||
// http://www.gratisoft.us/todd/papers/strlcpy.html
|
||||
// ftp://ftp.openbsd.org/pub/OpenBSD/src/lib/libc/string/{wcs,str}lcpy.c
|
||||
|
|
|
@ -108,9 +108,7 @@ bool IsWprintfFormatPortable(const wchar_t* format);
|
|||
#error Define string operations appropriately for your platform
|
||||
#endif
|
||||
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
namespace base {
|
||||
#endif
|
||||
// Returns a reference to a globally unique empty string that functions can
|
||||
// return. Use this to avoid static construction of strings, not to replace
|
||||
// any and all uses of "std::string()" as nicer-looking sugar.
|
||||
|
@ -118,9 +116,7 @@ namespace base {
|
|||
const std::string& EmptyString();
|
||||
const std::wstring& EmptyWString();
|
||||
const string16& EmptyString16();
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
}
|
||||
#endif
|
||||
|
||||
extern const wchar_t kWhitespaceWide[];
|
||||
extern const char kWhitespaceASCII[];
|
||||
|
@ -509,11 +505,7 @@ inline typename string_type::value_type* WriteInto(string_type* str,
|
|||
|
||||
// Function objects to aid in comparing/searching strings.
|
||||
|
||||
#if defined(CHROMIUM_MOZILLA_BUILD)
|
||||
template<typename Char> struct chromium_CaseInsensitiveCompare {
|
||||
#else
|
||||
template<typename Char> struct CaseInsensitiveCompare {
|
||||
#endif
|
||||
public:
|
||||
bool operator()(Char x, Char y) const {
|
||||
return tolower(x) == tolower(y);
|
||||
|
|
|
@ -55,13 +55,7 @@
|
|||
#include "base/logging.h"
|
||||
#include "base/third_party/nspr/prtypes.h"
|
||||
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
PR_BEGIN_EXTERN_C
|
||||
#endif
|
||||
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
#define PR_ASSERT DCHECK
|
||||
#endif
|
||||
|
||||
#define LL_I2L(l, i) ((l) = (PRInt64)(i))
|
||||
#define LL_MUL(r, a, b) ((r) = (a) * (b))
|
||||
|
@ -171,9 +165,7 @@ typedef struct PRExplodedTime {
|
|||
|
||||
typedef PRTimeParameters (PR_CALLBACK *PRTimeParamFn)(const PRExplodedTime *gmt);
|
||||
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
PR_END_EXTERN_C
|
||||
#endif
|
||||
|
||||
namespace nspr {
|
||||
|
||||
|
|
|
@ -65,26 +65,10 @@
|
|||
#endif
|
||||
|
||||
// Type detection for wchar_t.
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#define WCHAR_T_IS_UTF16
|
||||
#elif defined(OS_POSIX) && defined(COMPILER_GCC) && \
|
||||
defined(__WCHAR_MAX__) && \
|
||||
(__WCHAR_MAX__ == 0x7fffffff || __WCHAR_MAX__ == 0xffffffff)
|
||||
#define WCHAR_T_IS_UTF32
|
||||
#else
|
||||
#error Please add support for your compiler in build/build_config.h
|
||||
#endif
|
||||
|
||||
#else // CHROMIUM_MOZILLA_BUILD
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#define WCHAR_T_IS_UTF16
|
||||
#else
|
||||
#define WCHAR_T_IS_UTF32
|
||||
#endif
|
||||
|
||||
#endif // CHROMIUM_MOZILLA_BUILD
|
||||
|
||||
#endif // BUILD_BUILD_CONFIG_H_
|
||||
|
|
|
@ -10,19 +10,12 @@
|
|||
#include "base/process_util.h"
|
||||
#include "base/singleton.h"
|
||||
#include "base/waitable_event.h"
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
#include "mozilla/ipc/ProcessChild.h"
|
||||
#include "mozilla/ipc/BrowserProcessSubThread.h"
|
||||
typedef mozilla::ipc::BrowserProcessSubThread ChromeThread;
|
||||
#else
|
||||
#include "chrome/browser/chrome_thread.h"
|
||||
#endif
|
||||
#include "chrome/common/ipc_logging.h"
|
||||
#include "chrome/common/notification_service.h"
|
||||
#include "chrome/common/notification_type.h"
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
#include "chrome/common/plugin_messages.h"
|
||||
#endif
|
||||
#include "chrome/common/process_watcher.h"
|
||||
#include "chrome/common/result_codes.h"
|
||||
|
||||
|
@ -57,11 +50,7 @@ class ChildNotificationTask : public Task {
|
|||
ChildProcessHost::ChildProcessHost(
|
||||
ProcessType type, ResourceDispatcherHost* resource_dispatcher_host)
|
||||
:
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
ChildProcessInfo(type),
|
||||
#else
|
||||
Receiver(type),
|
||||
#endif
|
||||
ALLOW_THIS_IN_INITIALIZER_LIST(listener_(this)),
|
||||
resource_dispatcher_host_(resource_dispatcher_host),
|
||||
opening_channel_(false),
|
||||
|
@ -120,16 +109,12 @@ bool ChildProcessHost::Send(IPC::Message* msg) {
|
|||
}
|
||||
|
||||
void ChildProcessHost::Notify(NotificationType type) {
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
MessageLoop* loop = ChromeThread::GetMessageLoop(ChromeThread::IO);
|
||||
if (!loop)
|
||||
loop = mozilla::ipc::ProcessChild::message_loop();
|
||||
if (!loop)
|
||||
loop = MessageLoop::current();
|
||||
loop->PostTask(
|
||||
#else
|
||||
resource_dispatcher_host_->ui_loop()->PostTask(
|
||||
#endif
|
||||
FROM_HERE, new ChildNotificationTask(type, this));
|
||||
}
|
||||
|
||||
|
@ -147,10 +132,6 @@ void ChildProcessHost::OnWaitableEventSignaled(base::WaitableEvent *event) {
|
|||
// Notify in the main loop of the disconnection.
|
||||
Notify(NotificationType::CHILD_PROCESS_HOST_DISCONNECTED);
|
||||
#endif
|
||||
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
delete this;
|
||||
#endif
|
||||
}
|
||||
|
||||
ChildProcessHost::ListenerHook::ListenerHook(ChildProcessHost* host)
|
||||
|
@ -171,27 +152,10 @@ void ChildProcessHost::ListenerHook::OnMessageReceived(
|
|||
#endif
|
||||
|
||||
bool msg_is_ok = true;
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
bool handled = false;
|
||||
#else
|
||||
bool handled = host_->resource_dispatcher_host_->OnMessageReceived(
|
||||
msg, host_, &msg_is_ok);
|
||||
#endif
|
||||
|
||||
if (!handled) {
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
if (0) {
|
||||
#else
|
||||
if (msg.type() == PluginProcessHostMsg_ShutdownRequest::ID) {
|
||||
// Must remove the process from the list now, in case it gets used for a
|
||||
// new instance before our watcher tells us that the process terminated.
|
||||
Singleton<ChildProcessList>::get()->remove(host_);
|
||||
if (host_->CanShutdown())
|
||||
host_->Send(new PluginProcessMsg_Shutdown());
|
||||
#endif
|
||||
} else {
|
||||
host_->OnMessageReceived(msg);
|
||||
}
|
||||
}
|
||||
|
||||
if (!msg_is_ok)
|
||||
|
@ -206,9 +170,6 @@ void ChildProcessHost::ListenerHook::OnMessageReceived(
|
|||
void ChildProcessHost::ListenerHook::OnChannelConnected(int32 peer_pid) {
|
||||
host_->opening_channel_ = false;
|
||||
host_->OnChannelConnected(peer_pid);
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
host_->Send(new PluginProcessMsg_AskBeforeShutdown());
|
||||
#endif
|
||||
|
||||
// Notify in the main loop of the connection.
|
||||
host_->Notify(NotificationType::CHILD_PROCESS_HOST_CONNECTED);
|
||||
|
@ -221,21 +182,11 @@ void ChildProcessHost::ListenerHook::OnChannelError() {
|
|||
|
||||
|
||||
ChildProcessHost::Iterator::Iterator() : all_(true) {
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
DCHECK(MessageLoop::current() ==
|
||||
ChromeThread::GetMessageLoop(ChromeThread::IO)) <<
|
||||
"ChildProcessInfo::Iterator must be used on the IO thread.";
|
||||
#endif
|
||||
iterator_ = Singleton<ChildProcessList>::get()->begin();
|
||||
}
|
||||
|
||||
ChildProcessHost::Iterator::Iterator(ProcessType type)
|
||||
: all_(false), type_(type) {
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
DCHECK(MessageLoop::current() ==
|
||||
ChromeThread::GetMessageLoop(ChromeThread::IO)) <<
|
||||
"ChildProcessInfo::Iterator must be used on the IO thread.";
|
||||
#endif
|
||||
iterator_ = Singleton<ChildProcessList>::get()->begin();
|
||||
if (!Done() && (*iterator_)->type() != type_)
|
||||
++(*this);
|
||||
|
|
|
@ -12,11 +12,7 @@
|
|||
#include "base/basictypes.h"
|
||||
#include "base/scoped_ptr.h"
|
||||
#include "base/waitable_event_watcher.h"
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
class ResourceDispatcherHost;
|
||||
#else
|
||||
#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
|
||||
#endif
|
||||
#include "chrome/common/child_process_info.h"
|
||||
#include "chrome/common/ipc_channel.h"
|
||||
|
||||
|
@ -25,12 +21,8 @@ class NotificationType;
|
|||
// Plugins/workers and other child processes that live on the IO thread should
|
||||
// derive from this class.
|
||||
class ChildProcessHost :
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
public IPC::Message::Sender,
|
||||
public ChildProcessInfo,
|
||||
#else
|
||||
public ResourceDispatcherHost::Receiver,
|
||||
#endif
|
||||
public base::WaitableEventWatcher::Delegate,
|
||||
public IPC::Channel::Listener {
|
||||
public:
|
||||
|
@ -84,28 +76,20 @@ class ChildProcessHost :
|
|||
bool opening_channel() { return opening_channel_; }
|
||||
const std::wstring& channel_id() { return channel_id_; }
|
||||
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
base::WaitableEvent* GetProcessEvent() { return process_event_.get(); }
|
||||
#endif
|
||||
|
||||
const IPC::Channel& channel() const { return *channel_; }
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
IPC::Channel* channelp() const { return channel_.get(); }
|
||||
#endif
|
||||
|
||||
private:
|
||||
// Sends the given notification to the notification service on the UI thread.
|
||||
void Notify(NotificationType type);
|
||||
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
protected:
|
||||
#endif
|
||||
// WaitableEventWatcher::Delegate implementation:
|
||||
virtual void OnWaitableEventSignaled(base::WaitableEvent *event);
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
private:
|
||||
#endif
|
||||
|
||||
private:
|
||||
// By using an internal class as the IPC::Channel::Listener, we can intercept
|
||||
// OnMessageReceived/OnChannelConnected and do our own processing before
|
||||
// calling the subclass' implementation.
|
||||
|
|
|
@ -6,16 +6,10 @@
|
|||
|
||||
#include <limits>
|
||||
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
#include "app/l10n_util.h"
|
||||
#endif
|
||||
#include "base/logging.h"
|
||||
#include "base/process_util.h"
|
||||
#include "base/rand_util.h"
|
||||
#include "base/string_util.h"
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
#include "grit/generated_resources.h"
|
||||
#endif
|
||||
|
||||
std::wstring ChildProcessInfo::GetTypeNameInEnglish(
|
||||
ChildProcessInfo::ProcessType type) {
|
||||
|
@ -36,30 +30,7 @@ std::wstring ChildProcessInfo::GetTypeNameInEnglish(
|
|||
}
|
||||
|
||||
std::wstring ChildProcessInfo::GetLocalizedTitle() const {
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
return name_;
|
||||
#else
|
||||
std::wstring title = name_;
|
||||
if (type_ == ChildProcessInfo::PLUGIN_PROCESS && title.empty())
|
||||
title = l10n_util::GetString(IDS_TASK_MANAGER_UNKNOWN_PLUGIN_NAME);
|
||||
|
||||
int message_id;
|
||||
if (type_ == ChildProcessInfo::PLUGIN_PROCESS) {
|
||||
message_id = IDS_TASK_MANAGER_PLUGIN_PREFIX;
|
||||
} else if (type_ == ChildProcessInfo::WORKER_PROCESS) {
|
||||
message_id = IDS_TASK_MANAGER_WORKER_PREFIX;
|
||||
} else {
|
||||
DCHECK(false) << "Need localized name for child process type.";
|
||||
return title;
|
||||
}
|
||||
|
||||
// Explicitly mark name as LTR if there is no strong RTL character,
|
||||
// to avoid the wrong concatenation result similar to "!Yahoo! Mail: the
|
||||
// best web-based Email: NIGULP", in which "NIGULP" stands for the Hebrew
|
||||
// or Arabic word for "plugin".
|
||||
l10n_util::AdjustStringForLocaleDirection(title, &title);
|
||||
return l10n_util::GetStringF(message_id, title);
|
||||
#endif
|
||||
}
|
||||
|
||||
ChildProcessInfo::ChildProcessInfo(ProcessType type) {
|
||||
|
|
|
@ -9,10 +9,6 @@
|
|||
#include "chrome/common/child_process.h"
|
||||
#include "chrome/common/chrome_switches.h"
|
||||
#include "chrome/common/ipc_logging.h"
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
#include "chrome/common/plugin_messages.h"
|
||||
#include "webkit/glue/webkit_glue.h"
|
||||
#endif
|
||||
|
||||
// V8 needs a 1MB stack size.
|
||||
const size_t ChildThread::kV8StackSize = 1024 * 1024;
|
||||
|
@ -25,14 +21,6 @@ ChildThread::ChildThread(Thread::Options options)
|
|||
DCHECK(owner_loop_);
|
||||
channel_name_ = CommandLine::ForCurrentProcess()->GetSwitchValue(
|
||||
switches::kProcessChannelID);
|
||||
|
||||
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUserAgent)) {
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
webkit_glue::SetUserAgent(WideToUTF8(
|
||||
CommandLine::ForCurrentProcess()->GetSwitchValue(
|
||||
switches::kUserAgent)));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
ChildThread::~ChildThread() {
|
||||
|
@ -68,22 +56,6 @@ void ChildThread::RemoveRoute(int32 routing_id) {
|
|||
}
|
||||
|
||||
void ChildThread::OnMessageReceived(const IPC::Message& msg) {
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
// Resource responses are sent to the resource dispatcher.
|
||||
if (resource_dispatcher_->OnMessageReceived(msg))
|
||||
return;
|
||||
|
||||
if (msg.type() == PluginProcessMsg_AskBeforeShutdown::ID) {
|
||||
check_with_browser_before_shutdown_ = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg.type() == PluginProcessMsg_Shutdown::ID) {
|
||||
owner_loop_->PostTask(FROM_HERE, new MessageLoop::QuitTask());
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (msg.routing_id() == MSG_ROUTING_CONTROL) {
|
||||
OnControlMessageReceived(msg);
|
||||
} else {
|
||||
|
@ -96,23 +68,13 @@ ChildThread* ChildThread::current() {
|
|||
}
|
||||
|
||||
void ChildThread::Init() {
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
channel_.reset(new IPC::SyncChannel(channel_name_,
|
||||
IPC::Channel::MODE_CLIENT, this, NULL, owner_loop_, true,
|
||||
ChildProcess::current()->GetShutDownEvent()));
|
||||
#else
|
||||
channel_.reset(new IPC::Channel(channel_name_,
|
||||
IPC::Channel::MODE_CLIENT,
|
||||
this));
|
||||
#endif
|
||||
|
||||
#ifdef IPC_MESSAGE_LOG_ENABLED
|
||||
IPC::Logging::current()->SetIPCSender(this);
|
||||
#endif
|
||||
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
resource_dispatcher_.reset(new ResourceDispatcher(this));
|
||||
#endif
|
||||
}
|
||||
|
||||
void ChildThread::CleanUp() {
|
||||
|
@ -122,9 +84,6 @@ void ChildThread::CleanUp() {
|
|||
// Need to destruct the SyncChannel to the browser before we go away because
|
||||
// it caches a pointer to this thread.
|
||||
channel_.reset();
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
resource_dispatcher_.reset();
|
||||
#endif
|
||||
}
|
||||
|
||||
void ChildThread::OnProcessFinalRelease() {
|
||||
|
@ -132,12 +91,4 @@ void ChildThread::OnProcessFinalRelease() {
|
|||
owner_loop_->PostTask(FROM_HERE, new MessageLoop::QuitTask());
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
// The child process shutdown sequence is a request response based mechanism,
|
||||
// where we send out an initial feeler request to the child process host
|
||||
// instance in the browser to verify if it's ok to shutdown the child process.
|
||||
// The browser then sends back a response if it's ok to shutdown.
|
||||
Send(new PluginProcessHostMsg_ShutdownRequest);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -9,11 +9,7 @@
|
|||
#include "chrome/common/ipc_sync_channel.h"
|
||||
#include "chrome/common/message_router.h"
|
||||
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
class ResourceDispatcher;
|
||||
#else
|
||||
#include "chrome/common/resource_dispatcher.h"
|
||||
#endif
|
||||
|
||||
// Child processes's background thread should derive from this class.
|
||||
class ChildThread : public IPC::Channel::Listener,
|
||||
|
@ -33,12 +29,6 @@ class ChildThread : public IPC::Channel::Listener,
|
|||
|
||||
MessageLoop* owner_loop() { return owner_loop_; }
|
||||
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
ResourceDispatcher* resource_dispatcher() {
|
||||
return resource_dispatcher_.get();
|
||||
}
|
||||
#endif
|
||||
|
||||
protected:
|
||||
friend class ChildProcess;
|
||||
|
||||
|
@ -60,11 +50,7 @@ class ChildThread : public IPC::Channel::Listener,
|
|||
// Returns the one child thread.
|
||||
static ChildThread* current();
|
||||
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
IPC::SyncChannel* channel() { return channel_.get(); }
|
||||
#else
|
||||
IPC::Channel* channel() { return channel_.get(); }
|
||||
#endif
|
||||
|
||||
// Thread implementation.
|
||||
virtual void Init();
|
||||
|
@ -79,11 +65,7 @@ class ChildThread : public IPC::Channel::Listener,
|
|||
MessageLoop* owner_loop_;
|
||||
|
||||
std::wstring channel_name_;
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
scoped_ptr<IPC::SyncChannel> channel_;
|
||||
#else
|
||||
scoped_ptr<IPC::Channel> channel_;
|
||||
#endif
|
||||
|
||||
// Used only on the background render thread to implement message routing
|
||||
// functionality to the consumers of the ChildThread.
|
||||
|
@ -91,12 +73,6 @@ class ChildThread : public IPC::Channel::Listener,
|
|||
|
||||
Thread::Options options_;
|
||||
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
// Handles resource loads for this process.
|
||||
// NOTE: this object lives on the owner thread.
|
||||
scoped_ptr<ResourceDispatcher> resource_dispatcher_;
|
||||
#endif
|
||||
|
||||
// If true, checks with the browser process before shutdown. This avoids race
|
||||
// conditions if the process refcount is 0 but there's an IPC message inflight
|
||||
// that would addref it.
|
||||
|
|
|
@ -32,187 +32,6 @@ bool GetGearsPluginPathFromCommandLine(FilePath* path) {
|
|||
}
|
||||
|
||||
bool PathProvider(int key, FilePath* result) {
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
// Some keys are just aliases...
|
||||
switch (key) {
|
||||
case chrome::DIR_APP:
|
||||
return PathService::Get(base::DIR_MODULE, result);
|
||||
case chrome::DIR_LOGS:
|
||||
#ifndef NDEBUG
|
||||
return PathService::Get(chrome::DIR_USER_DATA, result);
|
||||
#else
|
||||
return PathService::Get(base::DIR_EXE, result);
|
||||
#endif
|
||||
case chrome::FILE_RESOURCE_MODULE:
|
||||
return PathService::Get(base::FILE_MODULE, result);
|
||||
}
|
||||
|
||||
// Assume that we will not need to create the directory if it does not exist.
|
||||
// This flag can be set to true for the cases where we want to create it.
|
||||
bool create_dir = false;
|
||||
|
||||
FilePath cur;
|
||||
switch (key) {
|
||||
case chrome::DIR_USER_DATA:
|
||||
if (!GetDefaultUserDataDirectory(&cur))
|
||||
return false;
|
||||
create_dir = true;
|
||||
break;
|
||||
case chrome::DIR_USER_DOCUMENTS:
|
||||
if (!GetUserDocumentsDirectory(&cur))
|
||||
return false;
|
||||
create_dir = true;
|
||||
break;
|
||||
case chrome::DIR_DEFAULT_DOWNLOADS:
|
||||
if (!GetUserDownloadsDirectory(&cur))
|
||||
return false;
|
||||
break;
|
||||
case chrome::DIR_CRASH_DUMPS:
|
||||
// The crash reports are always stored relative to the default user data
|
||||
// directory. This avoids the problem of having to re-initialize the
|
||||
// exception handler after parsing command line options, which may
|
||||
// override the location of the app's profile directory.
|
||||
if (!GetDefaultUserDataDirectory(&cur))
|
||||
return false;
|
||||
cur = cur.Append(FILE_PATH_LITERAL("Crash Reports"));
|
||||
create_dir = true;
|
||||
break;
|
||||
case chrome::DIR_USER_DESKTOP:
|
||||
if (!GetUserDesktop(&cur))
|
||||
return false;
|
||||
break;
|
||||
case chrome::DIR_RESOURCES:
|
||||
if (!PathService::Get(chrome::DIR_APP, &cur))
|
||||
return false;
|
||||
cur = cur.Append(FILE_PATH_LITERAL("resources"));
|
||||
create_dir = true;
|
||||
break;
|
||||
case chrome::DIR_INSPECTOR:
|
||||
if (!PathService::Get(chrome::DIR_APP, &cur))
|
||||
return false;
|
||||
cur = cur.Append(FILE_PATH_LITERAL("resources"));
|
||||
cur = cur.Append(FILE_PATH_LITERAL("inspector"));
|
||||
break;
|
||||
case chrome::DIR_THEMES:
|
||||
if (!PathService::Get(chrome::DIR_APP, &cur))
|
||||
return false;
|
||||
cur = cur.Append(FILE_PATH_LITERAL("themes"));
|
||||
create_dir = true;
|
||||
break;
|
||||
case chrome::DIR_LOCALES:
|
||||
if (!PathService::Get(chrome::DIR_APP, &cur))
|
||||
return false;
|
||||
#if defined(OS_MACOSX)
|
||||
// On Mac, locale files are in Contents/Resources, a sibling of the
|
||||
// App dir.
|
||||
cur = cur.DirName();
|
||||
cur = cur.Append(FILE_PATH_LITERAL("Resources"));
|
||||
#else
|
||||
cur = cur.Append(FILE_PATH_LITERAL("locales"));
|
||||
#endif
|
||||
create_dir = true;
|
||||
break;
|
||||
case chrome::DIR_APP_DICTIONARIES:
|
||||
#if defined(OS_LINUX)
|
||||
// We can't write into the EXE dir on Linux, so keep dictionaries
|
||||
// alongside the safe browsing database in the user data dir.
|
||||
if (!PathService::Get(chrome::DIR_USER_DATA, &cur))
|
||||
return false;
|
||||
#else
|
||||
if (!PathService::Get(base::DIR_EXE, &cur))
|
||||
return false;
|
||||
#endif
|
||||
cur = cur.Append(FILE_PATH_LITERAL("Dictionaries"));
|
||||
create_dir = true;
|
||||
break;
|
||||
case chrome::FILE_LOCAL_STATE:
|
||||
if (!PathService::Get(chrome::DIR_USER_DATA, &cur))
|
||||
return false;
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
cur = cur.Append(FILE_PATH_LITERAL("Local State"));
|
||||
#else
|
||||
cur = cur.Append(chrome::kLocalStateFilename);
|
||||
#endif
|
||||
break;
|
||||
case chrome::FILE_RECORDED_SCRIPT:
|
||||
if (!PathService::Get(chrome::DIR_USER_DATA, &cur))
|
||||
return false;
|
||||
cur = cur.Append(FILE_PATH_LITERAL("script.log"));
|
||||
break;
|
||||
case chrome::FILE_GEARS_PLUGIN:
|
||||
if (!GetGearsPluginPathFromCommandLine(&cur)) {
|
||||
#if defined(OS_WIN)
|
||||
// Search for gears.dll alongside chrome.dll first. This new model
|
||||
// allows us to package gears.dll with the Chrome installer and update
|
||||
// it while Chrome is running.
|
||||
if (!PathService::Get(base::DIR_MODULE, &cur))
|
||||
return false;
|
||||
cur = cur.Append(FILE_PATH_LITERAL("gears.dll"));
|
||||
|
||||
if (!file_util::PathExists(cur)) {
|
||||
if (!PathService::Get(base::DIR_EXE, &cur))
|
||||
return false;
|
||||
cur = cur.Append(FILE_PATH_LITERAL("plugins"));
|
||||
cur = cur.Append(FILE_PATH_LITERAL("gears"));
|
||||
cur = cur.Append(FILE_PATH_LITERAL("gears.dll"));
|
||||
}
|
||||
#else
|
||||
// No gears.dll on non-Windows systems.
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
// The following are only valid in the development environment, and
|
||||
// will fail if executed from an installed executable (because the
|
||||
// generated path won't exist).
|
||||
case chrome::DIR_TEST_DATA:
|
||||
if (!PathService::Get(base::DIR_SOURCE_ROOT, &cur))
|
||||
return false;
|
||||
cur = cur.Append(FILE_PATH_LITERAL("chrome"));
|
||||
cur = cur.Append(FILE_PATH_LITERAL("test"));
|
||||
cur = cur.Append(FILE_PATH_LITERAL("data"));
|
||||
if (!file_util::PathExists(cur)) // we don't want to create this
|
||||
return false;
|
||||
break;
|
||||
case chrome::DIR_TEST_TOOLS:
|
||||
if (!PathService::Get(base::DIR_SOURCE_ROOT, &cur))
|
||||
return false;
|
||||
cur = cur.Append(FILE_PATH_LITERAL("chrome"));
|
||||
cur = cur.Append(FILE_PATH_LITERAL("tools"));
|
||||
cur = cur.Append(FILE_PATH_LITERAL("test"));
|
||||
if (!file_util::PathExists(cur)) // we don't want to create this
|
||||
return false;
|
||||
break;
|
||||
case chrome::FILE_PYTHON_RUNTIME:
|
||||
if (!PathService::Get(base::DIR_SOURCE_ROOT, &cur))
|
||||
return false;
|
||||
cur = cur.Append(FILE_PATH_LITERAL("third_party"));
|
||||
cur = cur.Append(FILE_PATH_LITERAL("python_24"));
|
||||
cur = cur.Append(FILE_PATH_LITERAL("python.exe"));
|
||||
if (!file_util::PathExists(cur)) // we don't want to create this
|
||||
return false;
|
||||
break;
|
||||
case chrome::FILE_TEST_SERVER:
|
||||
if (!PathService::Get(base::DIR_SOURCE_ROOT, &cur))
|
||||
return false;
|
||||
cur = cur.Append(FILE_PATH_LITERAL("net"));
|
||||
cur = cur.Append(FILE_PATH_LITERAL("tools"));
|
||||
cur = cur.Append(FILE_PATH_LITERAL("test"));
|
||||
cur = cur.Append(FILE_PATH_LITERAL("testserver"));
|
||||
cur = cur.Append(FILE_PATH_LITERAL("testserver.py"));
|
||||
if (!file_util::PathExists(cur)) // we don't want to create this
|
||||
return false;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
if (create_dir && !file_util::PathExists(cur) &&
|
||||
!file_util::CreateDirectory(cur))
|
||||
return false;
|
||||
|
||||
*result = cur;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,9 +9,6 @@
|
|||
|
||||
#include "base/file_path.h"
|
||||
#include "base/path_service.h"
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
#include "chrome/third_party/xdg_user_dirs/xdg_user_dir_lookup.h"
|
||||
#endif // ifndef CHROMIUM_MOZILLA_BUILD
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -36,14 +33,6 @@ FilePath GetHomeDir() {
|
|||
// Wrapper around xdg_user_dir_lookup() from
|
||||
// src/chrome/third_party/xdg-user-dirs
|
||||
FilePath GetXDGUserDirectory(const char* env_name, const char* fallback_dir) {
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
char* xdg_dir = xdg_user_dir_lookup(env_name);
|
||||
if (xdg_dir) {
|
||||
FilePath rv(xdg_dir);
|
||||
free(xdg_dir);
|
||||
return rv;
|
||||
}
|
||||
#endif // ifndef CHROMIUM_MOZILLA_BUILD
|
||||
return GetHomeDir().Append(fallback_dir);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#ifndef CHROME_COMMON_ENV_VARS_H__
|
||||
#define CHROME_COMMON_ENV_VARS_H__
|
||||
|
||||
#if defined(CHROMIUM_MOZILLA_BUILD) && defined(COMPILER_MSVC)
|
||||
#if defined(COMPILER_MSVC)
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
|
|
|
@ -59,7 +59,6 @@ class Channel : public Message::Sender {
|
|||
//
|
||||
Channel(const std::wstring& channel_id, Mode mode, Listener* listener);
|
||||
|
||||
#if defined(CHROMIUM_MOZILLA_BUILD)
|
||||
// XXX it would nice not to have yet more platform-specific code in
|
||||
// here but it's just not worth the trouble.
|
||||
# if defined(OS_POSIX)
|
||||
|
@ -71,7 +70,6 @@ class Channel : public Message::Sender {
|
|||
Channel(const std::wstring& channel_id, void* server_pipe,
|
||||
Mode mode, Listener* listener);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
~Channel();
|
||||
|
||||
|
@ -86,11 +84,7 @@ class Channel : public Message::Sender {
|
|||
void Close();
|
||||
|
||||
// Modify the Channel's listener.
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
Listener* set_listener(Listener* listener);
|
||||
#else
|
||||
void set_listener(Listener* listener);
|
||||
#endif
|
||||
|
||||
// Send a message over the Channel to the listener on the other end.
|
||||
//
|
||||
|
@ -114,15 +108,11 @@ class Channel : public Message::Sender {
|
|||
// socketpair() in which case this method returns -1 for both parameters.
|
||||
void GetClientFileDescriptorMapping(int *src_fd, int *dest_fd) const;
|
||||
|
||||
# if defined(CHROMIUM_MOZILLA_BUILD)
|
||||
// Return the server side of the socketpair.
|
||||
int GetServerFileDescriptor() const;
|
||||
# endif
|
||||
#elif defined(OS_WIN)
|
||||
# if defined(CHROMIUM_MOZILLA_BUILD)
|
||||
// Return the server pipe handle.
|
||||
void* GetServerPipeHandle() const;
|
||||
# endif
|
||||
#endif // defined(OS_POSIX)
|
||||
|
||||
private:
|
||||
|
|
|
@ -238,7 +238,6 @@ bool ClientConnectToFifo(const std::string &pipe_name, int* client_socket) {
|
|||
return true;
|
||||
}
|
||||
|
||||
#if defined(CHROMIUM_MOZILLA_BUILD)
|
||||
bool SetCloseOnExec(int fd) {
|
||||
int flags = fcntl(fd, F_GETFD);
|
||||
if (flags == -1)
|
||||
|
@ -250,7 +249,6 @@ bool SetCloseOnExec(int fd) {
|
|||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace
|
||||
//------------------------------------------------------------------------------
|
||||
|
@ -327,14 +325,12 @@ bool Channel::ChannelImpl::CreatePipe(const std::wstring& channel_id,
|
|||
return false;
|
||||
}
|
||||
|
||||
#if defined(CHROMIUM_MOZILLA_BUILD)
|
||||
if (!SetCloseOnExec(pipe_fds[0]) ||
|
||||
!SetCloseOnExec(pipe_fds[1])) {
|
||||
HANDLE_EINTR(close(pipe_fds[0]));
|
||||
HANDLE_EINTR(close(pipe_fds[1]));
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
pipe_ = pipe_fds[0];
|
||||
client_pipe_ = pipe_fds[1];
|
||||
|
@ -688,9 +684,6 @@ bool Channel::ChannelImpl::ProcessOutgoingMessages() {
|
|||
}
|
||||
|
||||
bool Channel::ChannelImpl::Send(Message* message) {
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
chrome::Counters::ipc_send_counter().Increment();
|
||||
#endif
|
||||
#ifdef IPC_MESSAGE_DEBUG_EXTRA
|
||||
DLOG(INFO) << "sending message @" << message << " on channel @" << this
|
||||
<< " with type " << message->type()
|
||||
|
@ -824,11 +817,9 @@ Channel::Channel(const std::wstring& channel_id, Mode mode,
|
|||
: channel_impl_(new ChannelImpl(channel_id, mode, listener)) {
|
||||
}
|
||||
|
||||
#if defined(CHROMIUM_MOZILLA_BUILD)
|
||||
Channel::Channel(int fd, Mode mode, Listener* listener)
|
||||
: channel_impl_(new ChannelImpl(fd, mode, listener)) {
|
||||
}
|
||||
#endif
|
||||
|
||||
Channel::~Channel() {
|
||||
delete channel_impl_;
|
||||
|
@ -842,15 +833,9 @@ void Channel::Close() {
|
|||
channel_impl_->Close();
|
||||
}
|
||||
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
Channel::Listener* Channel::set_listener(Listener* listener) {
|
||||
return channel_impl_->set_listener(listener);
|
||||
}
|
||||
#else
|
||||
void Channel::set_listener(Listener* listener) {
|
||||
channel_impl_->set_listener(listener);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool Channel::Send(Message* message) {
|
||||
return channel_impl_->Send(message);
|
||||
|
@ -860,10 +845,8 @@ void Channel::GetClientFileDescriptorMapping(int *src_fd, int *dest_fd) const {
|
|||
return channel_impl_->GetClientFileDescriptorMapping(src_fd, dest_fd);
|
||||
}
|
||||
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
int Channel::GetServerFileDescriptor() const {
|
||||
return channel_impl_->GetServerFileDescriptor();
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace IPC
|
||||
|
|
|
@ -28,23 +28,17 @@ class Channel::ChannelImpl : public MessageLoopForIO::Watcher {
|
|||
~ChannelImpl() { Close(); }
|
||||
bool Connect();
|
||||
void Close();
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
Listener* set_listener(Listener* listener) {
|
||||
Listener* old = listener_;
|
||||
listener_ = listener;
|
||||
return old;
|
||||
}
|
||||
#else
|
||||
void set_listener(Listener* listener) { listener_ = listener; }
|
||||
#endif
|
||||
bool Send(Message* message);
|
||||
void GetClientFileDescriptorMapping(int *src_fd, int *dest_fd) const;
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
int GetServerFileDescriptor() const {
|
||||
DCHECK(mode_ == MODE_SERVER);
|
||||
return pipe_;
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
void Init(Mode mode, Listener* listener);
|
||||
|
|
|
@ -45,7 +45,6 @@ Channel::ChannelImpl::ChannelImpl(const std::wstring& channel_id, Mode mode,
|
|||
}
|
||||
}
|
||||
|
||||
#if defined(CHROMIUM_MOZILLA_BUILD)
|
||||
Channel::ChannelImpl::ChannelImpl(const std::wstring& channel_id,
|
||||
HANDLE server_pipe,
|
||||
Mode mode, Listener* listener)
|
||||
|
@ -74,7 +73,6 @@ void Channel::ChannelImpl::Init(Mode mode, Listener* listener) {
|
|||
HANDLE Channel::ChannelImpl::GetServerPipeHandle() const {
|
||||
return pipe_;
|
||||
}
|
||||
#endif
|
||||
|
||||
void Channel::ChannelImpl::Close() {
|
||||
if (thread_check_.get()) {
|
||||
|
@ -94,19 +92,10 @@ void Channel::ChannelImpl::Close() {
|
|||
pipe_ = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
// Make sure all IO has completed.
|
||||
base::Time start = base::Time::Now();
|
||||
#endif
|
||||
while (input_state_.is_pending || output_state_.is_pending) {
|
||||
MessageLoopForIO::current()->WaitForIOCompletion(INFINITE, this);
|
||||
}
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
if (waited) {
|
||||
// We want to see if we block the message loop for too long.
|
||||
UMA_HISTOGRAM_TIMES("AsyncIO.IPCChannelClose", base::Time::Now() - start);
|
||||
}
|
||||
#endif
|
||||
|
||||
while (!output_queue_.empty()) {
|
||||
Message* m = output_queue_.front();
|
||||
output_queue_.pop();
|
||||
|
@ -211,10 +200,6 @@ bool Channel::ChannelImpl::EnqueueHelloMessage() {
|
|||
}
|
||||
|
||||
bool Channel::ChannelImpl::Connect() {
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
DLOG(WARNING) << "Connect called twice";
|
||||
#endif
|
||||
|
||||
if (!thread_check_.get())
|
||||
thread_check_.reset(new NonThreadSafe());
|
||||
|
||||
|
@ -459,12 +444,10 @@ Channel::Channel(const std::wstring& channel_id, Mode mode,
|
|||
: channel_impl_(new ChannelImpl(channel_id, mode, listener)) {
|
||||
}
|
||||
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
Channel::Channel(const std::wstring& channel_id, void* server_pipe,
|
||||
Mode mode, Listener* listener)
|
||||
: channel_impl_(new ChannelImpl(channel_id, server_pipe, mode, listener)) {
|
||||
}
|
||||
#endif
|
||||
|
||||
Channel::~Channel() {
|
||||
delete channel_impl_;
|
||||
|
@ -478,7 +461,6 @@ void Channel::Close() {
|
|||
channel_impl_->Close();
|
||||
}
|
||||
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
void* Channel::GetServerPipeHandle() const {
|
||||
return channel_impl_->GetServerPipeHandle();
|
||||
}
|
||||
|
@ -486,11 +468,6 @@ void* Channel::GetServerPipeHandle() const {
|
|||
Channel::Listener* Channel::set_listener(Listener* listener) {
|
||||
return channel_impl_->set_listener(listener);
|
||||
}
|
||||
#else
|
||||
void Channel::set_listener(Listener* listener) {
|
||||
channel_impl_->set_listener(listener);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool Channel::Send(Message* message) {
|
||||
return channel_impl_->Send(message);
|
||||
|
|
|
@ -29,17 +29,12 @@ class Channel::ChannelImpl : public MessageLoopForIO::IOHandler {
|
|||
}
|
||||
bool Connect();
|
||||
void Close();
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
HANDLE GetServerPipeHandle() const;
|
||||
|
||||
Listener* set_listener(Listener* listener) {
|
||||
Listener* old = listener_;
|
||||
listener_ = listener;
|
||||
return old;
|
||||
}
|
||||
#else
|
||||
void set_listener(Listener* listener) { listener_ = listener; }
|
||||
#endif
|
||||
bool Send(Message* message);
|
||||
private:
|
||||
void Init(Mode mode, Listener* listener);
|
||||
|
|
|
@ -23,21 +23,6 @@
|
|||
#include "chrome/common/ipc_sync_message.h"
|
||||
#include "chrome/common/ipc_message_utils.h"
|
||||
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
// This include list should contain all _messages.h header files so that they
|
||||
// can get *MsgLog function etc. This makes ipc logs much more informative.
|
||||
#include "chrome/common/render_messages.h"
|
||||
#include "chrome/test/automation/automation_messages.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
// Pulling this file in Mac/Linux causes a lot of binaries to need to bring in
|
||||
// WebKit and all the dependencies, which results in a very large number of
|
||||
// linker errors.
|
||||
#include "chrome/common/plugin_messages.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(OS_POSIX)
|
||||
#include "base/string_util.h"
|
||||
#include <unistd.h>
|
||||
|
@ -101,10 +86,6 @@ Logging::Logging()
|
|||
CreateEvent(NULL, TRUE, FALSE, event_name.c_str())));
|
||||
|
||||
RegisterWaitForEvent(true);
|
||||
#elif (!defined(CHROMIUM_MOZILLA_BUILD) && defined(OS_POSIX))
|
||||
if (getenv("CHROME_IPC_LOGGING"))
|
||||
enabled_ = true;
|
||||
SetLoggerFunctions(g_log_function_mapping);
|
||||
#endif
|
||||
|
||||
MessageLoop::current()->AddDestructionObserver(this);
|
||||
|
|
|
@ -27,12 +27,8 @@ Message::Message()
|
|||
InitLoggingVariables();
|
||||
}
|
||||
|
||||
#if !defined(CHROMIUM_MOZILLA_BUILD)
|
||||
Message::Message(int32 routing_id, msgid_t type, PriorityValue priority)
|
||||
#else
|
||||
Message::Message(int32 routing_id, msgid_t type, PriorityValue priority,
|
||||
const char* const name)
|
||||
#endif
|
||||
: Pickle(sizeof(Header)) {
|
||||
header()->routing = routing_id;
|
||||
header()->type = type;
|
||||
|
@ -40,14 +36,10 @@ Message::Message(int32 routing_id, msgid_t type, PriorityValue priority,
|
|||
#if defined(OS_POSIX)
|
||||
header()->num_fds = 0;
|
||||
#endif
|
||||
#if defined(CHROMIUM_MOZILLA_BUILD)
|
||||
header()->rpc_remote_stack_depth_guess = static_cast<uint32>(-1);
|
||||
header()->rpc_local_stack_depth = static_cast<uint32>(-1);
|
||||
header()->seqno = 0;
|
||||
InitLoggingVariables(name);
|
||||
#else
|
||||
InitLoggingVariables();
|
||||
#endif
|
||||
}
|
||||
|
||||
Message::Message(const char* data, int data_len) : Pickle(data, data_len) {
|
||||
|
@ -55,22 +47,14 @@ Message::Message(const char* data, int data_len) : Pickle(data, data_len) {
|
|||
}
|
||||
|
||||
Message::Message(const Message& other) : Pickle(other) {
|
||||
#if !defined(CHROMIUM_MOZILLA_BUILD)
|
||||
InitLoggingVariables();
|
||||
#else
|
||||
InitLoggingVariables(other.name_);
|
||||
#endif
|
||||
#if defined(OS_POSIX)
|
||||
file_descriptor_set_ = other.file_descriptor_set_;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !defined(CHROMIUM_MOZILLA_BUILD)
|
||||
void Message::InitLoggingVariables() {
|
||||
#else
|
||||
void Message::InitLoggingVariables(const char* const name) {
|
||||
name_ = name;
|
||||
#endif
|
||||
#ifdef IPC_MESSAGE_LOG_ENABLED
|
||||
received_time_ = 0;
|
||||
dont_log_ = false;
|
||||
|
@ -80,9 +64,7 @@ void Message::InitLoggingVariables(const char* const name) {
|
|||
|
||||
Message& Message::operator=(const Message& other) {
|
||||
*static_cast<Pickle*>(this) = other;
|
||||
#if defined(CHROMIUM_MOZILLA_BUILD)
|
||||
InitLoggingVariables(other.name_);
|
||||
#endif
|
||||
#if defined(OS_POSIX)
|
||||
file_descriptor_set_ = other.file_descriptor_set_;
|
||||
#endif
|
||||
|
|
|
@ -18,9 +18,7 @@
|
|||
#include "base/ref_counted.h"
|
||||
#endif
|
||||
|
||||
#if defined(CHROMIUM_MOZILLA_BUILD)
|
||||
#define IPC_MESSAGE_ENABLE_RPC
|
||||
#endif
|
||||
|
||||
namespace base {
|
||||
class FileDescriptor;
|
||||
|
@ -38,11 +36,7 @@ struct LogData;
|
|||
|
||||
class Message : public Pickle {
|
||||
public:
|
||||
#if defined(CHROMIUM_MOZILLA_BUILD)
|
||||
typedef uint32 msgid_t;
|
||||
#else
|
||||
typedef uint16 msgid_t;
|
||||
#endif
|
||||
|
||||
// Implemented by objects that can send IPC messages across a channel.
|
||||
class Sender {
|
||||
|
@ -68,12 +62,8 @@ class Message : public Pickle {
|
|||
|
||||
// Initialize a message with a user-defined type, priority value, and
|
||||
// destination WebView ID.
|
||||
#if !defined(CHROMIUM_MOZILLA_BUILD)
|
||||
Message(int32 routing_id, msgid_t type, PriorityValue priority);
|
||||
#else
|
||||
Message(int32 routing_id, msgid_t type, PriorityValue priority,
|
||||
const char* const name="???");
|
||||
#endif
|
||||
|
||||
// Initializes a message from a const block of data. The data is not copied;
|
||||
// instead the data is merely referenced by this message. Only const methods
|
||||
|
@ -151,7 +141,6 @@ class Message : public Pickle {
|
|||
header()->routing = new_id;
|
||||
}
|
||||
|
||||
#if defined(CHROMIUM_MOZILLA_BUILD)
|
||||
uint32 rpc_remote_stack_depth_guess() const {
|
||||
return header()->rpc_remote_stack_depth_guess;
|
||||
}
|
||||
|
@ -185,7 +174,6 @@ class Message : public Pickle {
|
|||
void set_name(const char* const name) {
|
||||
name_ = name;
|
||||
}
|
||||
#endif
|
||||
|
||||
template<class T>
|
||||
static bool Dispatch(const Message* msg, T* obj, void (T::*func)()) {
|
||||
|
@ -254,9 +242,6 @@ class Message : public Pickle {
|
|||
bool dont_log() const { return dont_log_; }
|
||||
#endif
|
||||
|
||||
#if !defined(CHROMIUM_MOZILLA_BUILD)
|
||||
protected:
|
||||
#endif
|
||||
friend class Channel;
|
||||
friend class MessageReplyDeserializer;
|
||||
friend class SyncMessage;
|
||||
|
@ -271,7 +256,7 @@ class Message : public Pickle {
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(CHROMIUM_MOZILLA_BUILD) && !defined(OS_MACOSX)
|
||||
#if !defined(OS_MACOSX)
|
||||
protected:
|
||||
#endif
|
||||
|
||||
|
@ -293,22 +278,16 @@ class Message : public Pickle {
|
|||
struct Header : Pickle::Header {
|
||||
int32 routing; // ID of the view that this message is destined for
|
||||
msgid_t type; // specifies the user-defined message type
|
||||
#if defined(CHROMIUM_MOZILLA_BUILD)
|
||||
uint32 flags; // specifies control flags for the message
|
||||
#else
|
||||
uint16 flags; // specifies control flags for the message
|
||||
#endif
|
||||
#if defined(OS_POSIX)
|
||||
uint32 num_fds; // the number of descriptors included with this message
|
||||
#endif
|
||||
#if defined(CHROMIUM_MOZILLA_BUILD)
|
||||
// For RPC messages, a guess at what the *other* side's stack depth is.
|
||||
uint32 rpc_remote_stack_depth_guess;
|
||||
// The actual local stack depth.
|
||||
uint32 rpc_local_stack_depth;
|
||||
// Sequence number
|
||||
int32 seqno;
|
||||
#endif
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
|
@ -319,11 +298,7 @@ class Message : public Pickle {
|
|||
return headerT<Header>();
|
||||
}
|
||||
|
||||
#if !defined(CHROMIUM_MOZILLA_BUILD)
|
||||
void InitLoggingVariables();
|
||||
#else
|
||||
void InitLoggingVariables(const char* const name="???");
|
||||
#endif
|
||||
|
||||
#if defined(OS_POSIX)
|
||||
// The set of file descriptors associated with this message.
|
||||
|
@ -341,9 +316,7 @@ class Message : public Pickle {
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(CHROMIUM_MOZILLA_BUILD)
|
||||
const char* name_;
|
||||
#endif
|
||||
|
||||
#ifdef IPC_MESSAGE_LOG_ENABLED
|
||||
// Used for logging.
|
||||
|
|
|
@ -40,12 +40,7 @@
|
|||
// ViewHostMsg_SyncMessageName::WriteReplyParams(reply_msg, out1, out2);
|
||||
// Send(reply_msg);
|
||||
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
#include "IPC/IPCMessageUtils.h"
|
||||
#else
|
||||
#include "chrome/common/ipc_message_utils.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef MESSAGES_INTERNAL_FILE
|
||||
#error This file should only be included by X_messages.h, which needs to define MESSAGES_INTERNAL_FILE first.
|
||||
|
|
|
@ -5,15 +5,9 @@
|
|||
#include "chrome/common/ipc_message_utils.h"
|
||||
|
||||
#include "base/gfx/rect.h"
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
#include "googleurl/src/gurl.h"
|
||||
#endif
|
||||
#ifndef EXCLUDE_SKIA_DEPENDENCIES
|
||||
#include "SkBitmap.h"
|
||||
#endif
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
#include "webkit/glue/dom_operations.h"
|
||||
#endif
|
||||
|
||||
namespace IPC {
|
||||
|
||||
|
@ -100,132 +94,4 @@ void ParamTraits<SkBitmap>::Log(const SkBitmap& p, std::wstring* l) {
|
|||
|
||||
#endif // EXCLUDE_SKIA_DEPENDENCIES
|
||||
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
void ParamTraits<GURL>::Write(Message* m, const GURL& p) {
|
||||
m->WriteString(p.possibly_invalid_spec());
|
||||
// TODO(brettw) bug 684583: Add encoding for query params.
|
||||
}
|
||||
|
||||
bool ParamTraits<GURL>::Read(const Message* m, void** iter, GURL* p) {
|
||||
std::string s;
|
||||
if (!m->ReadString(iter, &s)) {
|
||||
*p = GURL();
|
||||
return false;
|
||||
}
|
||||
*p = GURL(s);
|
||||
return true;
|
||||
}
|
||||
|
||||
void ParamTraits<GURL>::Log(const GURL& p, std::wstring* l) {
|
||||
l->append(UTF8ToWide(p.spec()));
|
||||
}
|
||||
|
||||
void ParamTraits<gfx::Point>::Write(Message* m, const gfx::Point& p) {
|
||||
m->WriteInt(p.x());
|
||||
m->WriteInt(p.y());
|
||||
}
|
||||
|
||||
bool ParamTraits<gfx::Point>::Read(const Message* m, void** iter,
|
||||
gfx::Point* r) {
|
||||
int x, y;
|
||||
if (!m->ReadInt(iter, &x) ||
|
||||
!m->ReadInt(iter, &y))
|
||||
return false;
|
||||
r->set_x(x);
|
||||
r->set_y(y);
|
||||
return true;
|
||||
}
|
||||
|
||||
void ParamTraits<gfx::Point>::Log(const gfx::Point& p, std::wstring* l) {
|
||||
l->append(StringPrintf(L"(%d, %d)", p.x(), p.y()));
|
||||
}
|
||||
|
||||
|
||||
void ParamTraits<gfx::Rect>::Write(Message* m, const gfx::Rect& p) {
|
||||
m->WriteInt(p.x());
|
||||
m->WriteInt(p.y());
|
||||
m->WriteInt(p.width());
|
||||
m->WriteInt(p.height());
|
||||
}
|
||||
|
||||
bool ParamTraits<gfx::Rect>::Read(const Message* m, void** iter, gfx::Rect* r) {
|
||||
int x, y, w, h;
|
||||
if (!m->ReadInt(iter, &x) ||
|
||||
!m->ReadInt(iter, &y) ||
|
||||
!m->ReadInt(iter, &w) ||
|
||||
!m->ReadInt(iter, &h))
|
||||
return false;
|
||||
r->set_x(x);
|
||||
r->set_y(y);
|
||||
r->set_width(w);
|
||||
r->set_height(h);
|
||||
return true;
|
||||
}
|
||||
|
||||
void ParamTraits<gfx::Rect>::Log(const gfx::Rect& p, std::wstring* l) {
|
||||
l->append(StringPrintf(L"(%d, %d, %d, %d)", p.x(), p.y(),
|
||||
p.width(), p.height()));
|
||||
}
|
||||
|
||||
|
||||
void ParamTraits<gfx::Size>::Write(Message* m, const gfx::Size& p) {
|
||||
m->WriteInt(p.width());
|
||||
m->WriteInt(p.height());
|
||||
}
|
||||
|
||||
bool ParamTraits<gfx::Size>::Read(const Message* m, void** iter, gfx::Size* r) {
|
||||
int w, h;
|
||||
if (!m->ReadInt(iter, &w) ||
|
||||
!m->ReadInt(iter, &h))
|
||||
return false;
|
||||
r->set_width(w);
|
||||
r->set_height(h);
|
||||
return true;
|
||||
}
|
||||
|
||||
void ParamTraits<gfx::Size>::Log(const gfx::Size& p, std::wstring* l) {
|
||||
l->append(StringPrintf(L"(%d, %d)", p.width(), p.height()));
|
||||
}
|
||||
|
||||
void ParamTraits<webkit_glue::WebApplicationInfo>::Write(
|
||||
Message* m, const webkit_glue::WebApplicationInfo& p) {
|
||||
WriteParam(m, p.title);
|
||||
WriteParam(m, p.description);
|
||||
WriteParam(m, p.app_url);
|
||||
WriteParam(m, p.icons.size());
|
||||
for (size_t i = 0; i < p.icons.size(); ++i) {
|
||||
WriteParam(m, p.icons[i].url);
|
||||
WriteParam(m, p.icons[i].width);
|
||||
WriteParam(m, p.icons[i].height);
|
||||
}
|
||||
}
|
||||
|
||||
bool ParamTraits<webkit_glue::WebApplicationInfo>::Read(
|
||||
const Message* m, void** iter, webkit_glue::WebApplicationInfo* r) {
|
||||
size_t icon_count;
|
||||
bool result =
|
||||
ReadParam(m, iter, &r->title) &&
|
||||
ReadParam(m, iter, &r->description) &&
|
||||
ReadParam(m, iter, &r->app_url) &&
|
||||
ReadParam(m, iter, &icon_count);
|
||||
if (!result)
|
||||
return false;
|
||||
for (size_t i = 0; i < icon_count && result; ++i) {
|
||||
param_type::IconInfo icon_info;
|
||||
result =
|
||||
ReadParam(m, iter, &icon_info.url) &&
|
||||
ReadParam(m, iter, &icon_info.width) &&
|
||||
ReadParam(m, iter, &icon_info.height);
|
||||
r->icons.push_back(icon_info);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void ParamTraits<webkit_glue::WebApplicationInfo>::Log(
|
||||
const webkit_glue::WebApplicationInfo& p, std::wstring* l) {
|
||||
l->append(L"<WebApplicationInfo>");
|
||||
}
|
||||
|
||||
#endif // CHROMIUM_MOZILLA_BUILD
|
||||
|
||||
} // namespace IPC
|
||||
|
|
|
@ -20,56 +20,6 @@
|
|||
#include "chrome/common/ipc_sync_message.h"
|
||||
#include "chrome/common/thumbnail_score.h"
|
||||
#include "chrome/common/transport_dib.h"
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
#include "webkit/glue/webcursor.h"
|
||||
#include "webkit/glue/window_open_disposition.h"
|
||||
|
||||
// Forward declarations.
|
||||
class GURL;
|
||||
class SkBitmap;
|
||||
|
||||
namespace gfx {
|
||||
class Point;
|
||||
class Rect;
|
||||
class Size;
|
||||
} // namespace gfx
|
||||
|
||||
namespace webkit_glue {
|
||||
struct WebApplicationInfo;
|
||||
} // namespace webkit_glue
|
||||
|
||||
// Used by IPC_BEGIN_MESSAGES so that each message class starts from a unique
|
||||
// base. Messages have unique IDs across channels in order for the IPC logging
|
||||
// code to figure out the message class from its ID.
|
||||
enum IPCMessageStart {
|
||||
// By using a start value of 0 for automation messages, we keep backward
|
||||
// compatibility with old builds.
|
||||
AutomationMsgStart = 0,
|
||||
ViewMsgStart,
|
||||
ViewHostMsgStart,
|
||||
PluginProcessMsgStart,
|
||||
PluginProcessHostMsgStart,
|
||||
PluginMsgStart,
|
||||
PluginHostMsgStart,
|
||||
NPObjectMsgStart,
|
||||
TestMsgStart,
|
||||
DevToolsAgentMsgStart,
|
||||
DevToolsClientMsgStart,
|
||||
WorkerProcessMsgStart,
|
||||
WorkerProcessHostMsgStart,
|
||||
WorkerMsgStart,
|
||||
WorkerHostMsgStart,
|
||||
// NOTE: When you add a new message class, also update
|
||||
// IPCStatusView::IPCStatusView to ensure logging works.
|
||||
// NOTE: this enum is used by IPC_MESSAGE_MACRO to generate a unique message
|
||||
// id. Only 4 bits are used for the message type, so if this enum needs more
|
||||
// than 16 entries, that code needs to be updated.
|
||||
LastMsgIndex
|
||||
};
|
||||
|
||||
COMPILE_ASSERT(LastMsgIndex <= 16, need_to_update_IPC_MESSAGE_MACRO);
|
||||
|
||||
#endif /* CHROMIUM_MOZILLA_BUILD */
|
||||
|
||||
namespace IPC {
|
||||
|
||||
|
@ -219,7 +169,7 @@ struct ParamTraits<unsigned long> {
|
|||
}
|
||||
};
|
||||
|
||||
#if !(defined(OS_MACOSX) || defined(OS_WIN) || (defined(CHROMIUM_MOZILLA_BUILD) && defined(OS_LINUX) && defined(ARCH_CPU_64_BITS)))
|
||||
#if !(defined(OS_MACOSX) || defined(OS_WIN) || (defined(OS_LINUX) && defined(ARCH_CPU_64_BITS)))
|
||||
// There size_t is a synonym for |unsigned long| ...
|
||||
template <>
|
||||
struct ParamTraits<size_t> {
|
||||
|
@ -272,7 +222,7 @@ struct ParamTraits<uint32> {
|
|||
};
|
||||
#endif // defined(OS_MACOSX)
|
||||
|
||||
#if !(defined(CHROMIUM_MOZILLA_BUILD) && defined(OS_LINUX) && defined(ARCH_CPU_64_BITS))
|
||||
#if !(defined(OS_LINUX) && defined(ARCH_CPU_64_BITS))
|
||||
// int64 is |long int| on 64-bit systems, uint64 is |unsigned long|
|
||||
template <>
|
||||
struct ParamTraits<int64> {
|
||||
|
@ -284,11 +234,7 @@ struct ParamTraits<int64> {
|
|||
return m->ReadInt64(iter, r);
|
||||
}
|
||||
static void Log(const param_type& p, std::wstring* l) {
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
l->append(StringPrintf(L"%I64d", p));
|
||||
#else
|
||||
l->append(StringPrintf(L"%" PRId64L, p));
|
||||
#endif // ifndef CHROMIUM_MOZILLA_BUILD
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -302,14 +248,10 @@ struct ParamTraits<uint64> {
|
|||
return m->ReadInt64(iter, reinterpret_cast<int64*>(r));
|
||||
}
|
||||
static void Log(const param_type& p, std::wstring* l) {
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
l->append(StringPrintf(L"%I64u", p));
|
||||
#else
|
||||
l->append(StringPrintf(L"%" PRIu64L, p));
|
||||
#endif // ifndef CHROMIUM_MOZILLA_BUILD
|
||||
}
|
||||
};
|
||||
#endif // if !(defined(CHROMIUM_MOZILLA_BUILD) && defined(OS_LINUX) && defined(ARCH_CPU_64_BITS))
|
||||
#endif // if !(defined(OS_LINUX) && defined(ARCH_CPU_64_BITS))
|
||||
|
||||
template <>
|
||||
struct ParamTraits<double> {
|
||||
|
@ -335,32 +277,6 @@ struct ParamTraits<double> {
|
|||
}
|
||||
};
|
||||
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
template <>
|
||||
struct ParamTraits<wchar_t> {
|
||||
typedef wchar_t param_type;
|
||||
static void Write(Message* m, const param_type& p) {
|
||||
m->WriteData(reinterpret_cast<const char*>(&p), sizeof(param_type));
|
||||
}
|
||||
static bool Read(const Message* m, void** iter, param_type* r) {
|
||||
const char *data;
|
||||
int data_size = 0;
|
||||
bool result = m->ReadData(iter, &data, &data_size);
|
||||
if (result && data_size == sizeof(param_type)) {
|
||||
memcpy(r, data, sizeof(param_type));
|
||||
} else {
|
||||
result = false;
|
||||
NOTREACHED();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
static void Log(const param_type& p, std::wstring* l) {
|
||||
l->append(StringPrintf(L"%lc", p));
|
||||
}
|
||||
};
|
||||
#endif /* CHROMIUM_MOZILLA_BUILD */
|
||||
|
||||
template <>
|
||||
struct ParamTraits<base::Time> {
|
||||
typedef base::Time param_type;
|
||||
|
@ -426,20 +342,6 @@ struct ParamTraits<MSG> {
|
|||
};
|
||||
#endif // defined(OS_WIN)
|
||||
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
template <>
|
||||
struct ParamTraits<SkBitmap> {
|
||||
typedef SkBitmap param_type;
|
||||
static void Write(Message* m, const param_type& p);
|
||||
|
||||
// Note: This function expects parameter |r| to be of type &SkBitmap since
|
||||
// r->SetConfig() and r->SetPixels() are called.
|
||||
static bool Read(const Message* m, void** iter, param_type* r);
|
||||
|
||||
static void Log(const param_type& p, std::wstring* l);
|
||||
};
|
||||
#endif /* CHROMIUM_MOZILLA_BUILD */
|
||||
|
||||
template <>
|
||||
struct ParamTraits<std::string> {
|
||||
typedef std::string param_type;
|
||||
|
@ -609,16 +511,6 @@ struct ParamTraits<string16> {
|
|||
};
|
||||
#endif
|
||||
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
template <>
|
||||
struct ParamTraits<GURL> {
|
||||
typedef GURL param_type;
|
||||
static void Write(Message* m, const param_type& p);
|
||||
static bool Read(const Message* m, void** iter, param_type* p);
|
||||
static void Log(const param_type& p, std::wstring* l);
|
||||
};
|
||||
#endif /* CHROMIUM_MOZILLA_BUILD */
|
||||
|
||||
// and, a few more useful types...
|
||||
#if defined(OS_WIN)
|
||||
template <>
|
||||
|
@ -717,32 +609,6 @@ struct ParamTraits<FilePath> {
|
|||
}
|
||||
};
|
||||
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
template <>
|
||||
struct ParamTraits<gfx::Point> {
|
||||
typedef gfx::Point param_type;
|
||||
static void Write(Message* m, const param_type& p);
|
||||
static bool Read(const Message* m, void** iter, param_type* r);
|
||||
static void Log(const param_type& p, std::wstring* l);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<gfx::Rect> {
|
||||
typedef gfx::Rect param_type;
|
||||
static void Write(Message* m, const param_type& p);
|
||||
static bool Read(const Message* m, void** iter, param_type* r);
|
||||
static void Log(const param_type& p, std::wstring* l);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<gfx::Size> {
|
||||
typedef gfx::Size param_type;
|
||||
static void Write(Message* m, const param_type& p);
|
||||
static bool Read(const Message* m, void** iter, param_type* r);
|
||||
static void Log(const param_type& p, std::wstring* l);
|
||||
};
|
||||
#endif /* CHROMIUM_MOZILLA_BUILD */
|
||||
|
||||
#if defined(OS_POSIX)
|
||||
// FileDescriptors may be serialised over IPC channels on POSIX. On the
|
||||
// receiving side, the FileDescriptor is a valid duplicate of the file
|
||||
|
@ -825,25 +691,6 @@ struct ParamTraits<ThumbnailScore> {
|
|||
}
|
||||
};
|
||||
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
template <>
|
||||
struct ParamTraits<WindowOpenDisposition> {
|
||||
typedef WindowOpenDisposition param_type;
|
||||
static void Write(Message* m, const param_type& p) {
|
||||
m->WriteInt(p);
|
||||
}
|
||||
static bool Read(const Message* m, void** iter, param_type* r) {
|
||||
int temp;
|
||||
bool res = m->ReadInt(iter, &temp);
|
||||
*r = static_cast<WindowOpenDisposition>(temp);
|
||||
return res;
|
||||
}
|
||||
static void Log(const param_type& p, std::wstring* l) {
|
||||
l->append(StringPrintf(L"%d", p));
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(OS_WIN)
|
||||
template <>
|
||||
struct ParamTraits<XFORM> {
|
||||
|
@ -870,22 +717,6 @@ struct ParamTraits<XFORM> {
|
|||
};
|
||||
#endif // defined(OS_WIN)
|
||||
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
template <>
|
||||
struct ParamTraits<WebCursor> {
|
||||
typedef WebCursor param_type;
|
||||
static void Write(Message* m, const param_type& p) {
|
||||
p.Serialize(m);
|
||||
}
|
||||
static bool Read(const Message* m, void** iter, param_type* r) {
|
||||
return r->Deserialize(m, iter);
|
||||
}
|
||||
static void Log(const param_type& p, std::wstring* l) {
|
||||
l->append(L"<WebCursor>");
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
struct LogData {
|
||||
std::wstring channel;
|
||||
int32 routing_id;
|
||||
|
@ -932,16 +763,6 @@ struct ParamTraits<LogData> {
|
|||
}
|
||||
};
|
||||
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
template <>
|
||||
struct ParamTraits<webkit_glue::WebApplicationInfo> {
|
||||
typedef webkit_glue::WebApplicationInfo param_type;
|
||||
static void Write(Message* m, const param_type& p);
|
||||
static bool Read(const Message* m, void** iter, param_type* r);
|
||||
static void Log(const param_type& p, std::wstring* l);
|
||||
};
|
||||
#endif /* CHROMIUM_MOZILLA_BUILD */
|
||||
|
||||
#if defined(OS_WIN)
|
||||
template<>
|
||||
struct ParamTraits<TransportDIB::Id> {
|
||||
|
|
|
@ -3,9 +3,6 @@
|
|||
// found in the LICENSE file.
|
||||
|
||||
#include "chrome/common/message_router.h"
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
#include "chrome/common/render_messages.h"
|
||||
#endif
|
||||
|
||||
void MessageRouter::OnControlMessageReceived(const IPC::Message& msg) {
|
||||
NOTREACHED() <<
|
||||
|
|
|
@ -6,16 +6,9 @@
|
|||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
#include "app/l10n_util.h"
|
||||
#endif
|
||||
#include "base/file_path.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/sys_string_conversions.h"
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
#include "chrome/browser/cocoa/tab_window_controller.h"
|
||||
#include "grit/generated_resources.h"
|
||||
#endif
|
||||
|
||||
namespace platform_util {
|
||||
|
||||
|
@ -30,22 +23,8 @@ gfx::NativeWindow GetTopLevel(gfx::NativeView view) {
|
|||
}
|
||||
|
||||
string16 GetWindowTitle(gfx::NativeWindow window) {
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
std::string str("Untitled");
|
||||
return string16(str.begin(), str.end());
|
||||
#else
|
||||
NSString* title = nil;
|
||||
if ([[window delegate] isKindOfClass:[TabWindowController class]])
|
||||
title = [[window delegate] selectedTabTitle];
|
||||
else
|
||||
title = [window title];
|
||||
// If we don't yet have a title, use "Untitled".
|
||||
if (![title length])
|
||||
return WideToUTF16(l10n_util::GetString(
|
||||
IDS_BROWSER_WINDOW_MAC_TAB_UNTITLED));
|
||||
|
||||
return base::SysNSStringToUTF16(title);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool IsWindowActive(gfx::NativeWindow window) {
|
||||
|
|
|
@ -24,9 +24,7 @@ class ProcessWatcher {
|
|||
// and SYNCHRONIZE permissions.
|
||||
//
|
||||
static void EnsureProcessTerminated(base::ProcessHandle process_handle
|
||||
#if defined(CHROMIUM_MOZILLA_BUILD)
|
||||
, bool force=true
|
||||
#endif
|
||||
);
|
||||
|
||||
private:
|
||||
|
|
|
@ -79,19 +79,15 @@ class TimerExpiredTask : public Task, public base::ObjectWatcher::Delegate {
|
|||
|
||||
// static
|
||||
void ProcessWatcher::EnsureProcessTerminated(base::ProcessHandle process
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
, bool force
|
||||
#endif
|
||||
) {
|
||||
DCHECK(process != GetCurrentProcess());
|
||||
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
if (!force) {
|
||||
WaitForSingleObject(process, INFINITE);
|
||||
CloseHandle(process);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
// If already signaled, then we are done!
|
||||
if (WaitForSingleObject(process, 0) == WAIT_OBJECT_0) {
|
||||
|
|
|
@ -25,11 +25,7 @@ TransportDIB::~TransportDIB() {
|
|||
// static
|
||||
TransportDIB* TransportDIB::Create(size_t size, uint32 sequence_num) {
|
||||
TransportDIB* dib = new TransportDIB;
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
if (!dib->shared_memory_.Create("", false /* read write */,
|
||||
#else
|
||||
if (!dib->shared_memory_.Create(L"", false /* read write */,
|
||||
#endif
|
||||
false /* do not open existing */, size)) {
|
||||
delete dib;
|
||||
return NULL;
|
||||
|
|
|
@ -27,11 +27,7 @@ TransportDIB* TransportDIB::Create(size_t size, uint32 sequence_num) {
|
|||
|
||||
TransportDIB* dib = new TransportDIB;
|
||||
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
if (!dib->shared_memory_.Create("", false /* read write */,
|
||||
#else
|
||||
if (!dib->shared_memory_.Create(L"", false /* read write */,
|
||||
#endif
|
||||
true /* open existing */, size)) {
|
||||
delete dib;
|
||||
return NULL;
|
||||
|
|
Загрузка…
Ссылка в новой задаче