mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1258905: Remove a bunch of dead IPC code. r=jld
This commit is contained in:
parent
16d757c28e
commit
20daca1a98
@ -7,7 +7,6 @@
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "base/string_util.h"
|
||||
#include "chrome/common/chrome_switches.h"
|
||||
#include "mozilla/ipc/IOThreadChild.h"
|
||||
#include "mozilla/BackgroundHangMonitor.h"
|
||||
|
||||
|
@ -11,7 +11,6 @@
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "base/string_util.h"
|
||||
#include "chrome/common/chrome_switches.h"
|
||||
#include "nsDebugImpl.h"
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
|
@ -33,7 +33,6 @@
|
||||
#include <vector>
|
||||
|
||||
#include "base/basictypes.h"
|
||||
#include "base/cpu.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "skia/include/core/SkTypes.h"
|
||||
|
||||
|
@ -9,7 +9,6 @@ include(libevent_path_prefix + '/libeventcommon.mozbuild')
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
'src/base/at_exit.cc',
|
||||
'src/base/base_switches.cc',
|
||||
'src/base/command_line.cc',
|
||||
'src/base/file_path.cc',
|
||||
'src/base/file_util.cc',
|
||||
@ -25,7 +24,6 @@ UNIFIED_SOURCES += [
|
||||
'src/base/string_piece.cc',
|
||||
'src/base/string_util.cc',
|
||||
'src/base/thread.cc',
|
||||
'src/base/thread_collision_warner.cc',
|
||||
'src/base/time.cc',
|
||||
'src/base/timer.cc',
|
||||
'src/base/tracked.cc',
|
||||
@ -35,7 +33,6 @@ UNIFIED_SOURCES += [
|
||||
'src/chrome/common/child_process_info.cc',
|
||||
'src/chrome/common/child_thread.cc',
|
||||
'src/chrome/common/chrome_switches.cc',
|
||||
'src/chrome/common/env_vars.cc',
|
||||
'src/chrome/common/ipc_channel.cc',
|
||||
'src/chrome/common/ipc_channel_proxy.cc',
|
||||
'src/chrome/common/ipc_message.cc',
|
||||
@ -50,7 +47,6 @@ if os_win:
|
||||
'src/base/condition_variable_win.cc',
|
||||
'src/base/cpu.cc',
|
||||
'src/base/file_util_win.cc',
|
||||
'src/base/idle_timer.cc',
|
||||
'src/base/lock_impl_win.cc',
|
||||
'src/base/message_pump_win.cc',
|
||||
'src/base/object_watcher.cc',
|
||||
@ -59,7 +55,6 @@ if os_win:
|
||||
'src/base/process_util_win.cc',
|
||||
'src/base/process_win.cc',
|
||||
'src/base/rand_util_win.cc',
|
||||
'src/base/registry.cc',
|
||||
'src/base/shared_memory_win.cc',
|
||||
'src/base/sys_info_win.cc',
|
||||
'src/base/sys_string_conversions_win.cc',
|
||||
@ -104,7 +99,6 @@ if os_macosx:
|
||||
UNIFIED_SOURCES += [
|
||||
'src/base/chrome_application_mac.mm',
|
||||
'src/base/file_util_mac.mm',
|
||||
'src/base/idle_timer.cc',
|
||||
'src/base/mac_util.mm',
|
||||
'src/base/message_pump_mac.mm',
|
||||
'src/base/process_util_mac.mm',
|
||||
@ -139,7 +133,6 @@ if os_bsd:
|
||||
if os_linux:
|
||||
SOURCES += [
|
||||
'src/base/atomicops_internals_x86_gcc.cc',
|
||||
'src/base/idle_timer_none.cc',
|
||||
'src/base/process_util_linux.cc',
|
||||
'src/base/time_posix.cc',
|
||||
]
|
||||
|
@ -1,43 +0,0 @@
|
||||
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "base/base_switches.h"
|
||||
|
||||
namespace switches {
|
||||
|
||||
// If the program includes chrome/common/debug_on_start.h, the process will
|
||||
// start the JIT system-registered debugger on itself and will wait for 60
|
||||
// seconds for the debugger to attach to itself. Then a break point will be hit.
|
||||
const wchar_t kDebugOnStart[] = L"debug-on-start";
|
||||
|
||||
// Will wait for 60 seconds for a debugger to come to attach to the process.
|
||||
const wchar_t kWaitForDebugger[] = L"wait-for-debugger";
|
||||
|
||||
// Suppresses all error dialogs when present.
|
||||
const wchar_t kNoErrorDialogs[] = L"noerrdialogs";
|
||||
|
||||
// Disables the crash reporting.
|
||||
const wchar_t kDisableBreakpad[] = L"disable-breakpad";
|
||||
|
||||
// Generates full memory crash dump.
|
||||
const wchar_t kFullMemoryCrashReport[] = L"full-memory-crash-report";
|
||||
|
||||
// The value of this switch determines whether the process is started as a
|
||||
// renderer or plugin host. If it's empty, it's the browser.
|
||||
const wchar_t kProcessType[] = L"type";
|
||||
|
||||
// Enable DCHECKs in release mode.
|
||||
const wchar_t kEnableDCHECK[] = L"enable-dcheck";
|
||||
|
||||
// Refuse to make HTTP connections and refuse to accept certificate errors.
|
||||
// For more information about the design of this feature, please see
|
||||
//
|
||||
// ForceHTTPS: Protecting High-Security Web Sites from Network Attacks
|
||||
// Collin Jackson and Adam Barth
|
||||
// In Proc. of the 17th International World Wide Web Conference (WWW 2008)
|
||||
//
|
||||
// Available at http://www.adambarth.com/papers/2008/jackson-barth.pdf
|
||||
const wchar_t kForceHTTPS[] = L"force-https";
|
||||
|
||||
} // namespace switches
|
@ -1,27 +0,0 @@
|
||||
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Defines all the "base" command-line switches.
|
||||
|
||||
#ifndef BASE_BASE_SWITCHES_H_
|
||||
#define BASE_BASE_SWITCHES_H_
|
||||
|
||||
#if defined(COMPILER_MSVC)
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
namespace switches {
|
||||
|
||||
extern const wchar_t kDebugOnStart[];
|
||||
extern const wchar_t kWaitForDebugger[];
|
||||
extern const wchar_t kDisableBreakpad[];
|
||||
extern const wchar_t kFullMemoryCrashReport[];
|
||||
extern const wchar_t kNoErrorDialogs[];
|
||||
extern const wchar_t kProcessType[];
|
||||
extern const wchar_t kEnableDCHECK[];
|
||||
extern const wchar_t kForceHTTPS[];
|
||||
|
||||
} // namespace switches
|
||||
|
||||
#endif // BASE_BASE_SWITCHES_H_
|
@ -1,159 +0,0 @@
|
||||
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "base/idle_timer.h"
|
||||
|
||||
// We may not want to port idle_timer to Linux, but we have implemented it
|
||||
// anyway. Define this to 1 to enable the Linux idle timer and then add the
|
||||
// libs that need to be linked (Xss).
|
||||
#define ENABLE_XSS_SUPPORT 0
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
#include <ApplicationServices/ApplicationServices.h>
|
||||
#endif
|
||||
|
||||
#if defined(OS_LINUX) && ENABLE_XSS_SUPPORT
|
||||
// We may not want to port idle_timer to Linux, but we have implemented it
|
||||
// anyway. Remove the 0 above if we want it.
|
||||
#include <gdk/gdkx.h>
|
||||
#include <X11/extensions/scrnsaver.h>
|
||||
#include "base/thread_local.h"
|
||||
#endif
|
||||
|
||||
#include "base/message_loop.h"
|
||||
#include "base/time.h"
|
||||
|
||||
namespace base {
|
||||
|
||||
#if defined(OS_WIN)
|
||||
bool OSIdleTimeSource(int32_t *milliseconds_interval_since_last_event) {
|
||||
LASTINPUTINFO lastInputInfo;
|
||||
lastInputInfo.cbSize = sizeof(lastInputInfo);
|
||||
if (GetLastInputInfo(&lastInputInfo) == 0) {
|
||||
return false;
|
||||
}
|
||||
int32_t last_input_time = lastInputInfo.dwTime;
|
||||
|
||||
// Note: On Windows GetLastInputInfo returns a 32bit value which rolls over
|
||||
// ~49days.
|
||||
int32_t current_time = GetTickCount();
|
||||
int32_t delta = current_time - last_input_time;
|
||||
// delta will go negative if we've been idle for 2GB of ticks.
|
||||
if (delta < 0)
|
||||
delta = -delta;
|
||||
*milliseconds_interval_since_last_event = delta;
|
||||
return true;
|
||||
}
|
||||
#elif defined(OS_MACOSX)
|
||||
bool OSIdleTimeSource(int32_t *milliseconds_interval_since_last_event) {
|
||||
*milliseconds_interval_since_last_event =
|
||||
CGEventSourceSecondsSinceLastEventType(
|
||||
kCGEventSourceStateCombinedSessionState,
|
||||
kCGAnyInputEventType) * 1000.0;
|
||||
return true;
|
||||
}
|
||||
#elif defined(OS_LINUX) && ENABLE_XSS_SUPPORT
|
||||
class IdleState {
|
||||
public:
|
||||
IdleState() {
|
||||
int event_base, error_base;
|
||||
have_idle_info_ = XScreenSaverQueryExtension(GDK_DISPLAY(), &event_base,
|
||||
&error_base);
|
||||
if (have_idle_info_)
|
||||
idle_info_.Set(XScreenSaverAllocInfo());
|
||||
}
|
||||
|
||||
~IdleState() {
|
||||
if (idle_info_.Get()) {
|
||||
XFree(idle_info_.Get());
|
||||
idle_info_.~ThreadLocalPointer();
|
||||
}
|
||||
}
|
||||
|
||||
int32_t IdleTime() {
|
||||
if (have_idle_info_ && idle_info_.Get()) {
|
||||
XScreenSaverQueryInfo(GDK_DISPLAY(), GDK_ROOT_WINDOW(),
|
||||
idle_info_.Get());
|
||||
return idle_info_.Get()->idle;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private:
|
||||
bool have_idle_info_;
|
||||
ThreadLocalPointer<XScreenSaverInfo> idle_info_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(IdleState);
|
||||
};
|
||||
|
||||
bool OSIdleTimeSource(int32_t* milliseconds_interval_since_last_event) {
|
||||
static IdleState state;
|
||||
int32_t idle_time = state.IdleTime();
|
||||
if (0 < idle_time) {
|
||||
*milliseconds_interval_since_last_event = idle_time;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
IdleTimer::IdleTimer(TimeDelta idle_time, bool repeat)
|
||||
: idle_interval_(idle_time),
|
||||
repeat_(repeat),
|
||||
idle_time_source_(OSIdleTimeSource) {
|
||||
DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()) <<
|
||||
"Requires a thread that processes Windows UI events";
|
||||
}
|
||||
|
||||
IdleTimer::~IdleTimer() {
|
||||
Stop();
|
||||
}
|
||||
|
||||
void IdleTimer::Start() {
|
||||
StartTimer();
|
||||
}
|
||||
|
||||
void IdleTimer::Stop() {
|
||||
timer_.Stop();
|
||||
}
|
||||
|
||||
void IdleTimer::Run() {
|
||||
// Verify we can fire the idle timer.
|
||||
if (TimeUntilIdle().InMilliseconds() <= 0) {
|
||||
OnIdle();
|
||||
last_time_fired_ = Time::Now();
|
||||
}
|
||||
Stop();
|
||||
StartTimer(); // Restart the timer for next run.
|
||||
}
|
||||
|
||||
void IdleTimer::StartTimer() {
|
||||
DCHECK(!timer_.IsRunning());
|
||||
TimeDelta delay = TimeUntilIdle();
|
||||
if (delay.InMilliseconds() < 0)
|
||||
delay = TimeDelta();
|
||||
timer_.Start(delay, this, &IdleTimer::Run);
|
||||
}
|
||||
|
||||
TimeDelta IdleTimer::CurrentIdleTime() {
|
||||
int32_t interval = 0;
|
||||
if (idle_time_source_(&interval)) {
|
||||
return TimeDelta::FromMilliseconds(interval);
|
||||
}
|
||||
NOTREACHED();
|
||||
return TimeDelta::FromMilliseconds(0);
|
||||
}
|
||||
|
||||
TimeDelta IdleTimer::TimeUntilIdle() {
|
||||
TimeDelta time_since_last_fire = Time::Now() - last_time_fired_;
|
||||
TimeDelta current_idle_time = CurrentIdleTime();
|
||||
if (current_idle_time > time_since_last_fire) {
|
||||
if (repeat_)
|
||||
return idle_interval_ - time_since_last_fire;
|
||||
return idle_interval_;
|
||||
}
|
||||
return idle_interval_ - current_idle_time;
|
||||
}
|
||||
|
||||
} // namespace base
|
@ -1,97 +0,0 @@
|
||||
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// IdleTimer is a recurring Timer which runs only when the system is idle.
|
||||
// System Idle time is defined as not having any user keyboard or mouse
|
||||
// activity for some period of time. Because the timer is user dependant, it
|
||||
// is possible for the timer to never fire.
|
||||
//
|
||||
// Usage should be for low-priority work, and may look like this:
|
||||
//
|
||||
// class MyIdleTimer : public IdleTimer {
|
||||
// public:
|
||||
// // This timer will run repeatedly after 5 seconds of idle time
|
||||
// MyIdleTimer() : IdleTimer(TimeDelta::FromSeconds(5), true) {};
|
||||
// virtual void OnIdle() { do something };
|
||||
// }
|
||||
//
|
||||
// MyIdleTimer *timer = new MyIdleTimer();
|
||||
// timer->Start();
|
||||
//
|
||||
// // As with all Timers, the caller must dispose the object.
|
||||
// delete timer; // Will Stop the timer and cleanup.
|
||||
//
|
||||
// NOTE: An IdleTimer can only be used on a thread that processes UI events.
|
||||
// Such a thread should be running a MessageLoopForUI.
|
||||
|
||||
#ifndef BASE_IDLE_TIMER_H_
|
||||
#define BASE_IDLE_TIMER_H_
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "base/basictypes.h"
|
||||
#include "base/task.h"
|
||||
#include "base/timer.h"
|
||||
|
||||
namespace base {
|
||||
|
||||
// Function prototype - Get the number of milliseconds that the user has been
|
||||
// idle.
|
||||
typedef bool (*IdleTimeSource)(int32_t *milliseconds_interval_since_last_event);
|
||||
|
||||
class IdleTimer {
|
||||
public:
|
||||
// Create an IdleTimer.
|
||||
// idle_time: idle time required before this timer can run.
|
||||
// repeat: true if the timer should fire multiple times per idle,
|
||||
// false to fire once per idle.
|
||||
IdleTimer(TimeDelta idle_time, bool repeat);
|
||||
|
||||
// On destruction, the IdleTimer will Stop itself.
|
||||
virtual ~IdleTimer();
|
||||
|
||||
// Start the IdleTimer.
|
||||
void Start();
|
||||
|
||||
// Stop the IdleTimer.
|
||||
void Stop();
|
||||
|
||||
// The method to run when the timer elapses.
|
||||
virtual void OnIdle() = 0;
|
||||
|
||||
protected:
|
||||
// Override the IdleTimeSource.
|
||||
void set_idle_time_source(IdleTimeSource idle_time_source) {
|
||||
idle_time_source_ = idle_time_source;
|
||||
}
|
||||
|
||||
private:
|
||||
// Called when timer_ expires.
|
||||
void Run();
|
||||
|
||||
// Start the timer.
|
||||
void StartTimer();
|
||||
|
||||
// Gets the number of milliseconds since the last input event.
|
||||
TimeDelta CurrentIdleTime();
|
||||
|
||||
// Compute time until idle. Returns 0 if we are now idle.
|
||||
TimeDelta TimeUntilIdle();
|
||||
|
||||
TimeDelta idle_interval_;
|
||||
bool repeat_;
|
||||
Time last_time_fired_; // The last time the idle timer fired.
|
||||
// will be 0 until the timer fires the first time.
|
||||
OneShotTimer<IdleTimer> timer_;
|
||||
|
||||
IdleTimeSource idle_time_source_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(IdleTimer);
|
||||
};
|
||||
|
||||
} // namespace base
|
||||
|
||||
#endif // BASE_IDLE_TIMER_H_
|
@ -1,25 +0,0 @@
|
||||
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// A stub implementation of IdleTimer used to provide symbols needed by Chrome.
|
||||
// It's unclear whether we need the idle timer in the linux port, so we're
|
||||
// leaving it unported for now.
|
||||
|
||||
#include "base/idle_timer.h"
|
||||
|
||||
namespace base {
|
||||
|
||||
IdleTimer::IdleTimer(TimeDelta idle_time, bool repeat) {
|
||||
}
|
||||
|
||||
IdleTimer::~IdleTimer() {
|
||||
}
|
||||
|
||||
void IdleTimer::Start() {
|
||||
}
|
||||
|
||||
void IdleTimer::Stop() {
|
||||
}
|
||||
|
||||
} // namespace base
|
@ -1,19 +0,0 @@
|
||||
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef BASE_LINUX_UTIL_H__
|
||||
#define BASE_LINUX_UTIL_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace base {
|
||||
|
||||
// Makes a copy of |pixels| with the ordering changed from BGRA to RGBA.
|
||||
// The caller is responsible for free()ing the data. If |stride| is 0,
|
||||
// it's assumed to be 4 * |width|.
|
||||
uint8_t* BGRAToRGBA(const uint8_t* pixels, int width, int height, int stride);
|
||||
|
||||
} // namespace base
|
||||
|
||||
#endif // BASE_LINUX_UTIL_H__
|
@ -17,7 +17,6 @@
|
||||
#include "base/eintr_wrapper.h"
|
||||
#include "base/file_util.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/string_tokenizer.h"
|
||||
#include "base/string_util.h"
|
||||
#include "nsLiteralString.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
@ -1,417 +0,0 @@
|
||||
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
// All Rights Reserved.
|
||||
|
||||
#include "base/registry.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <shlwapi.h>
|
||||
#include <windows.h>
|
||||
|
||||
#pragma comment(lib, "shlwapi.lib") // for SHDeleteKey
|
||||
|
||||
// local types (see the same declarations in the header file)
|
||||
#define tchar TCHAR
|
||||
#define CTP const tchar*
|
||||
#define tstr std::basic_string<tchar>
|
||||
|
||||
//
|
||||
// RegistryValueIterator
|
||||
//
|
||||
|
||||
RegistryValueIterator::RegistryValueIterator(HKEY root_key,
|
||||
LPCTSTR folder_key) {
|
||||
LONG result = RegOpenKeyEx(root_key, folder_key, 0, KEY_READ, &key_);
|
||||
if (result != ERROR_SUCCESS) {
|
||||
key_ = NULL;
|
||||
} else {
|
||||
DWORD count = 0;
|
||||
result = ::RegQueryInfoKey(key_, NULL, 0, NULL, NULL, NULL, NULL, &count,
|
||||
NULL, NULL, NULL, NULL);
|
||||
|
||||
if (result != ERROR_SUCCESS) {
|
||||
::RegCloseKey(key_);
|
||||
key_ = NULL;
|
||||
} else {
|
||||
index_ = count - 1;
|
||||
}
|
||||
}
|
||||
|
||||
Read();
|
||||
}
|
||||
|
||||
RegistryValueIterator::~RegistryValueIterator() {
|
||||
if (key_)
|
||||
::RegCloseKey(key_);
|
||||
}
|
||||
|
||||
bool RegistryValueIterator::Valid() const {
|
||||
// true while the iterator is valid
|
||||
return key_ != NULL && index_ >= 0;
|
||||
}
|
||||
|
||||
void RegistryValueIterator::operator ++ () {
|
||||
// advance to the next entry in the folder
|
||||
--index_;
|
||||
Read();
|
||||
}
|
||||
|
||||
bool RegistryValueIterator::Read() {
|
||||
if (Valid()) {
|
||||
DWORD ncount = sizeof(name_)/sizeof(*name_);
|
||||
value_size_ = sizeof(value_);
|
||||
LRESULT r = ::RegEnumValue(key_, index_, name_, &ncount, NULL, &type_,
|
||||
reinterpret_cast<BYTE*>(value_), &value_size_);
|
||||
if (ERROR_SUCCESS == r)
|
||||
return true;
|
||||
}
|
||||
|
||||
name_[0] = '\0';
|
||||
value_[0] = '\0';
|
||||
value_size_ = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
DWORD RegistryValueIterator::ValueCount() const {
|
||||
|
||||
DWORD count = 0;
|
||||
HRESULT result = ::RegQueryInfoKey(key_, NULL, 0, NULL, NULL, NULL, NULL,
|
||||
&count, NULL, NULL, NULL, NULL);
|
||||
|
||||
if (result != ERROR_SUCCESS)
|
||||
return 0;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
//
|
||||
// RegistryKeyIterator
|
||||
//
|
||||
|
||||
RegistryKeyIterator::RegistryKeyIterator(HKEY root_key,
|
||||
LPCTSTR folder_key) {
|
||||
LONG result = RegOpenKeyEx(root_key, folder_key, 0, KEY_READ, &key_);
|
||||
if (result != ERROR_SUCCESS) {
|
||||
key_ = NULL;
|
||||
} else {
|
||||
DWORD count = 0;
|
||||
HRESULT result = ::RegQueryInfoKey(key_, NULL, 0, NULL, &count, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
if (result != ERROR_SUCCESS) {
|
||||
::RegCloseKey(key_);
|
||||
key_ = NULL;
|
||||
} else {
|
||||
index_ = count - 1;
|
||||
}
|
||||
}
|
||||
|
||||
Read();
|
||||
}
|
||||
|
||||
RegistryKeyIterator::~RegistryKeyIterator() {
|
||||
if (key_)
|
||||
::RegCloseKey(key_);
|
||||
}
|
||||
|
||||
bool RegistryKeyIterator::Valid() const {
|
||||
// true while the iterator is valid
|
||||
return key_ != NULL && index_ >= 0;
|
||||
}
|
||||
|
||||
void RegistryKeyIterator::operator ++ () {
|
||||
// advance to the next entry in the folder
|
||||
--index_;
|
||||
Read();
|
||||
}
|
||||
|
||||
bool RegistryKeyIterator::Read() {
|
||||
if (Valid()) {
|
||||
DWORD ncount = sizeof(name_)/sizeof(*name_);
|
||||
FILETIME written;
|
||||
LRESULT r = ::RegEnumKeyEx(key_, index_, name_, &ncount, NULL, NULL,
|
||||
NULL, &written);
|
||||
if (ERROR_SUCCESS == r)
|
||||
return true;
|
||||
}
|
||||
|
||||
name_[0] = '\0';
|
||||
return false;
|
||||
}
|
||||
|
||||
DWORD RegistryKeyIterator::SubkeyCount() const {
|
||||
|
||||
DWORD count = 0;
|
||||
HRESULT result = ::RegQueryInfoKey(key_, NULL, 0, NULL, &count, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
if (result != ERROR_SUCCESS)
|
||||
return 0;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
//
|
||||
// RegKey
|
||||
//
|
||||
|
||||
RegKey::RegKey(HKEY rootkey, const tchar* subkey, REGSAM access)
|
||||
: key_(NULL), watch_event_(0) {
|
||||
if (rootkey) {
|
||||
if (access & (KEY_SET_VALUE | KEY_CREATE_SUB_KEY | KEY_CREATE_LINK))
|
||||
this->Create(rootkey, subkey, access);
|
||||
else
|
||||
this->Open(rootkey, subkey, access);
|
||||
}
|
||||
else assert(!subkey);
|
||||
}
|
||||
|
||||
void RegKey::Close() {
|
||||
StopWatching();
|
||||
if (key_) {
|
||||
::RegCloseKey(key_);
|
||||
key_ = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool RegKey::Create(HKEY rootkey, const tchar* subkey, REGSAM access) {
|
||||
DWORD disposition_value;
|
||||
return CreateWithDisposition(rootkey, subkey, &disposition_value, access);
|
||||
}
|
||||
|
||||
bool RegKey::CreateWithDisposition(HKEY rootkey, const tchar* subkey,
|
||||
DWORD* disposition, REGSAM access) {
|
||||
assert(rootkey && subkey && access && disposition);
|
||||
this->Close();
|
||||
|
||||
LONG const result = RegCreateKeyEx(rootkey,
|
||||
subkey,
|
||||
0,
|
||||
NULL,
|
||||
REG_OPTION_NON_VOLATILE,
|
||||
access,
|
||||
NULL,
|
||||
&key_,
|
||||
disposition );
|
||||
if (result != ERROR_SUCCESS) {
|
||||
key_ = NULL;
|
||||
return false;
|
||||
}
|
||||
else return true;
|
||||
}
|
||||
|
||||
bool RegKey::Open(HKEY rootkey, const tchar* subkey, REGSAM access) {
|
||||
assert(rootkey && subkey && access);
|
||||
this->Close();
|
||||
|
||||
LONG const result = RegOpenKeyEx(rootkey, subkey, 0,
|
||||
access, &key_ );
|
||||
if (result != ERROR_SUCCESS) {
|
||||
key_ = NULL;
|
||||
return false;
|
||||
}
|
||||
else return true;
|
||||
}
|
||||
|
||||
bool RegKey::CreateKey(const tchar* name, REGSAM access) {
|
||||
assert(name && access);
|
||||
|
||||
HKEY subkey = NULL;
|
||||
LONG const result = RegCreateKeyEx(key_, name, 0, NULL,
|
||||
REG_OPTION_NON_VOLATILE,
|
||||
access, NULL, &subkey, NULL);
|
||||
this->Close();
|
||||
|
||||
key_ = subkey;
|
||||
return (result == ERROR_SUCCESS);
|
||||
}
|
||||
|
||||
bool RegKey::OpenKey(const tchar* name, REGSAM access) {
|
||||
assert(name && access);
|
||||
|
||||
HKEY subkey = NULL;
|
||||
LONG const result = RegOpenKeyEx(key_, name, 0, access, &subkey);
|
||||
|
||||
this->Close();
|
||||
|
||||
key_ = subkey;
|
||||
return (result == ERROR_SUCCESS);
|
||||
}
|
||||
|
||||
DWORD RegKey::ValueCount() {
|
||||
DWORD count = 0;
|
||||
HRESULT const result = ::RegQueryInfoKey(key_, NULL, 0, NULL, NULL, NULL,
|
||||
NULL, &count, NULL, NULL, NULL, NULL);
|
||||
return (result != ERROR_SUCCESS) ? 0 : count;
|
||||
}
|
||||
|
||||
bool RegKey::ReadName(int index, tstr* name) {
|
||||
tchar buf[256];
|
||||
DWORD bufsize = sizeof(buf)/sizeof(*buf);
|
||||
LRESULT r = ::RegEnumValue(key_, index, buf, &bufsize, NULL, NULL,
|
||||
NULL, NULL);
|
||||
if (r != ERROR_SUCCESS)
|
||||
return false;
|
||||
if (name)
|
||||
*name = buf;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RegKey::ValueExists(const tchar* name) {
|
||||
if (!key_) return false;
|
||||
const HRESULT result = RegQueryValueEx(key_, name, 0, NULL, NULL, NULL);
|
||||
return (result == ERROR_SUCCESS);
|
||||
}
|
||||
|
||||
bool RegKey::ReadValue(const tchar* name, void* data,
|
||||
DWORD* dsize, DWORD* dtype) {
|
||||
if (!key_) return false;
|
||||
HRESULT const result = RegQueryValueEx(key_, name, 0, dtype,
|
||||
reinterpret_cast<LPBYTE>(data),
|
||||
dsize);
|
||||
return (result == ERROR_SUCCESS);
|
||||
}
|
||||
|
||||
bool RegKey::ReadValue(const tchar* name, tstr * value) {
|
||||
assert(value);
|
||||
static const size_t kMaxStringLength = 1024; // This is after expansion.
|
||||
// Use the one of the other forms of ReadValue if 1024 is too small for you.
|
||||
TCHAR raw_value[kMaxStringLength];
|
||||
DWORD type = REG_SZ, size = sizeof(raw_value);
|
||||
if (this->ReadValue(name, raw_value, &size, &type)) {
|
||||
if (type == REG_SZ) {
|
||||
*value = raw_value;
|
||||
} else if (type == REG_EXPAND_SZ) {
|
||||
TCHAR expanded[kMaxStringLength];
|
||||
size = ExpandEnvironmentStrings(raw_value, expanded, kMaxStringLength);
|
||||
// Success: returns the number of TCHARs copied
|
||||
// Fail: buffer too small, returns the size required
|
||||
// Fail: other, returns 0
|
||||
if (size == 0 || size > kMaxStringLength)
|
||||
return false;
|
||||
*value = expanded;
|
||||
} else {
|
||||
// Not a string. Oops.
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
bool RegKey::ReadValueDW(const tchar* name, DWORD * value) {
|
||||
assert(value);
|
||||
DWORD type = REG_DWORD, size = sizeof(DWORD), result = 0;
|
||||
if (this->ReadValue(name, &result, &size, &type)
|
||||
&& (type == REG_DWORD || type == REG_BINARY)
|
||||
&& size == sizeof(DWORD)) {
|
||||
*value = result;
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
bool RegKey::WriteValue(const tchar* name,
|
||||
const void * data,
|
||||
DWORD dsize,
|
||||
DWORD dtype) {
|
||||
assert(data);
|
||||
if (!key_) return false;
|
||||
HRESULT const result = RegSetValueEx(
|
||||
key_,
|
||||
name,
|
||||
0,
|
||||
dtype,
|
||||
reinterpret_cast<LPBYTE>(const_cast<void*>(data)),
|
||||
dsize);
|
||||
return (result == ERROR_SUCCESS);
|
||||
}
|
||||
|
||||
bool RegKey::WriteValue(const tchar * name, const tchar * value) {
|
||||
return this->WriteValue(name, value,
|
||||
static_cast<DWORD>(sizeof(*value) * (_tcslen(value) + 1)), REG_SZ);
|
||||
}
|
||||
|
||||
bool RegKey::WriteValue(const tchar * name, DWORD value) {
|
||||
return this->WriteValue(name, &value,
|
||||
static_cast<DWORD>(sizeof(value)), REG_DWORD);
|
||||
}
|
||||
|
||||
bool RegKey::DeleteKey(const tchar * name) {
|
||||
if (!key_) return false;
|
||||
return (ERROR_SUCCESS == SHDeleteKey(key_, name));
|
||||
}
|
||||
|
||||
|
||||
bool RegKey::DeleteValue(const tchar * value_name) {
|
||||
assert(value_name);
|
||||
HRESULT const result = RegDeleteValue(key_, value_name);
|
||||
return (result == ERROR_SUCCESS);
|
||||
}
|
||||
|
||||
bool RegKey::StartWatching() {
|
||||
if (!watch_event_)
|
||||
watch_event_ = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
|
||||
DWORD filter = REG_NOTIFY_CHANGE_NAME |
|
||||
REG_NOTIFY_CHANGE_ATTRIBUTES |
|
||||
REG_NOTIFY_CHANGE_LAST_SET |
|
||||
REG_NOTIFY_CHANGE_SECURITY;
|
||||
|
||||
// Watch the registry key for a change of value.
|
||||
HRESULT result = RegNotifyChangeKeyValue(key_, TRUE, filter,
|
||||
watch_event_, TRUE);
|
||||
if (SUCCEEDED(result)) {
|
||||
return true;
|
||||
} else {
|
||||
CloseHandle(watch_event_);
|
||||
watch_event_ = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool RegKey::StopWatching() {
|
||||
if (watch_event_) {
|
||||
CloseHandle(watch_event_);
|
||||
watch_event_ = 0;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool RegKey::HasChanged() {
|
||||
if (watch_event_) {
|
||||
if (WaitForSingleObject(watch_event_, 0) == WAIT_OBJECT_0) {
|
||||
StartWatching();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Register a COM object with the most usual properties.
|
||||
bool RegisterCOMServer(const tchar* guid,
|
||||
const tchar* name,
|
||||
const tchar* path) {
|
||||
RegKey key(HKEY_CLASSES_ROOT, _T("CLSID"), KEY_WRITE);
|
||||
key.CreateKey(guid, KEY_WRITE);
|
||||
key.WriteValue(NULL, name);
|
||||
key.CreateKey(_T("InprocServer32"), KEY_WRITE);
|
||||
key.WriteValue(NULL, path);
|
||||
key.WriteValue(_T("ThreadingModel"), _T("Apartment"));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RegisterCOMServer(const tchar* guid, const tchar* name, HINSTANCE module) {
|
||||
tchar module_path[MAX_PATH];
|
||||
::GetModuleFileName(module, module_path, MAX_PATH);
|
||||
_tcslwr_s(module_path, MAX_PATH);
|
||||
return RegisterCOMServer(guid, name, module_path);
|
||||
}
|
||||
|
||||
bool UnregisterCOMServer(const tchar* guid) {
|
||||
RegKey key(HKEY_CLASSES_ROOT, _T("CLSID"), KEY_WRITE);
|
||||
key.DeleteKey(guid);
|
||||
return true;
|
||||
}
|
@ -1,225 +0,0 @@
|
||||
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
// All Rights Reserved.
|
||||
|
||||
#ifndef BASE_REGISTRY_H__
|
||||
#define BASE_REGISTRY_H__
|
||||
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
#include <shlwapi.h>
|
||||
#include <string>
|
||||
|
||||
// The shared file uses a bunch of header files that define types that we don't.
|
||||
// To avoid changing much code from the standard version, and also to avoid
|
||||
// polluting our namespace with extra types we don't want, we define these types
|
||||
// here with the preprocessor and undefine them at the end of the file.
|
||||
#define tchar TCHAR
|
||||
#define CTP const tchar*
|
||||
#define tstr std::basic_string<tchar>
|
||||
|
||||
// RegKey
|
||||
// Utility class to read from and manipulate the registry.
|
||||
// Registry vocabulary primer: a "key" is like a folder, in which there
|
||||
// are "values", which are <name,data> pairs, with an associated data type.
|
||||
|
||||
class RegKey {
|
||||
public:
|
||||
RegKey(HKEY rootkey = NULL, CTP subkey = NULL, REGSAM access = KEY_READ);
|
||||
// start there
|
||||
|
||||
~RegKey() { this->Close(); }
|
||||
|
||||
bool Create(HKEY rootkey, CTP subkey, REGSAM access = KEY_READ);
|
||||
|
||||
bool CreateWithDisposition(HKEY rootkey, CTP subkey, DWORD* disposition,
|
||||
REGSAM access = KEY_READ);
|
||||
|
||||
bool Open(HKEY rootkey, CTP subkey, REGSAM access = KEY_READ);
|
||||
|
||||
// Create a subkey (or open if exists)
|
||||
bool CreateKey(CTP name, REGSAM access);
|
||||
|
||||
// Open a subkey
|
||||
bool OpenKey(CTP name, REGSAM access);
|
||||
|
||||
// all done, eh?
|
||||
void Close();
|
||||
|
||||
DWORD ValueCount(); // Count of the number of value extant
|
||||
|
||||
bool ReadName(int index, tstr* name); // Determine the Nth value's name
|
||||
|
||||
// True while the key is valid
|
||||
bool Valid() const { return NULL != key_; }
|
||||
|
||||
// Kill key and everything that liveth below it; please be careful out there
|
||||
bool DeleteKey(CTP name);
|
||||
|
||||
// Delete a single value within the key
|
||||
bool DeleteValue(CTP name);
|
||||
|
||||
bool ValueExists(CTP name);
|
||||
bool ReadValue(CTP name, void * data, DWORD * dsize, DWORD * dtype = NULL);
|
||||
bool ReadValue(CTP name, tstr * value);
|
||||
bool ReadValueDW(CTP name, DWORD * value); // Named to differ from tstr*
|
||||
|
||||
bool WriteValue(CTP name, const void * data, DWORD dsize,
|
||||
DWORD dtype = REG_BINARY);
|
||||
bool WriteValue(CTP name, CTP value);
|
||||
bool WriteValue(CTP name, DWORD value);
|
||||
|
||||
// StartWatching()
|
||||
// Start watching the key to see if any of its values have changed.
|
||||
// The key must have been opened with the KEY_NOTIFY access
|
||||
// privelege.
|
||||
bool StartWatching();
|
||||
|
||||
// HasChanged()
|
||||
// If StartWatching hasn't been called, always returns false.
|
||||
// Otherwise, returns true if anything under the key has changed.
|
||||
// This can't be const because the watch_event_ may be refreshed.
|
||||
bool HasChanged();
|
||||
|
||||
// StopWatching()
|
||||
// Will automatically be called by destructor if not manually called
|
||||
// beforehand. Returns true if it was watching, false otherwise.
|
||||
bool StopWatching();
|
||||
|
||||
inline bool IsWatching() const { return watch_event_ != 0; }
|
||||
HANDLE watch_event() const { return watch_event_; }
|
||||
HKEY Handle() const { return key_; }
|
||||
|
||||
private:
|
||||
HKEY key_; // the registry key being iterated
|
||||
HANDLE watch_event_;
|
||||
};
|
||||
|
||||
|
||||
// Standalone registry functions -- sorta deprecated, they now map to
|
||||
// using RegKey
|
||||
|
||||
|
||||
// Add a raw data to the registry -- you can pass NULL for the data if
|
||||
// you just want to create a key
|
||||
inline bool AddToRegistry(HKEY root_key, CTP key, CTP value_name,
|
||||
void const * data, DWORD dsize,
|
||||
DWORD dtype = REG_BINARY) {
|
||||
return RegKey(root_key, key, KEY_WRITE).WriteValue(value_name, data, dsize,
|
||||
dtype);
|
||||
}
|
||||
|
||||
// Convenience routine to add a string value to the registry
|
||||
inline bool AddToRegistry(HKEY root_key, CTP key, CTP value_name, CTP value) {
|
||||
return AddToRegistry(root_key, key, value_name, value,
|
||||
sizeof(*value) * (lstrlen(value) + 1), REG_SZ);
|
||||
}
|
||||
|
||||
// Read raw data from the registry -- pass something as the dtype
|
||||
// parameter if you care to learn what type the value was stored as
|
||||
inline bool ReadFromRegistry(HKEY root_key, CTP key, CTP value_name,
|
||||
void* data, DWORD* dsize, DWORD* dtype = NULL) {
|
||||
return RegKey(root_key, key).ReadValue(value_name, data, dsize, dtype);
|
||||
}
|
||||
|
||||
|
||||
// Delete a value or a key from the registry
|
||||
inline bool DeleteFromRegistry(HKEY root_key, CTP subkey, CTP value_name) {
|
||||
if (value_name)
|
||||
return ERROR_SUCCESS == ::SHDeleteValue(root_key, subkey, value_name);
|
||||
else
|
||||
return ERROR_SUCCESS == ::SHDeleteKey(root_key, subkey);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// delete a key and all subkeys from the registry
|
||||
inline bool DeleteKeyFromRegistry(HKEY root_key, CTP key_path, CTP key_name) {
|
||||
RegKey key;
|
||||
return key.Open(root_key, key_path, KEY_WRITE)
|
||||
&& key.DeleteKey(key_name);
|
||||
}
|
||||
|
||||
|
||||
// Iterates the entries found in a particular folder on the registry.
|
||||
// For this application I happen to know I wont need data size larger
|
||||
// than MAX_PATH, but in real life this wouldn't neccessarily be
|
||||
// adequate.
|
||||
class RegistryValueIterator {
|
||||
public:
|
||||
// Specify a key in construction
|
||||
RegistryValueIterator(HKEY root_key, LPCTSTR folder_key);
|
||||
|
||||
~RegistryValueIterator();
|
||||
|
||||
DWORD ValueCount() const; // count of the number of subkeys extant
|
||||
|
||||
bool Valid() const; // true while the iterator is valid
|
||||
|
||||
void operator++(); // advance to the next entry in the folder
|
||||
|
||||
// The pointers returned by these functions are statics owned by the
|
||||
// Name and Value functions
|
||||
CTP Name() const { return name_; }
|
||||
CTP Value() const { return value_; }
|
||||
DWORD ValueSize() const { return value_size_; }
|
||||
DWORD Type() const { return type_; }
|
||||
|
||||
int Index() const { return index_; }
|
||||
|
||||
private:
|
||||
bool Read(); // read in the current values
|
||||
|
||||
HKEY key_; // the registry key being iterated
|
||||
int index_; // current index of the iteration
|
||||
|
||||
// Current values
|
||||
TCHAR name_[MAX_PATH];
|
||||
TCHAR value_[MAX_PATH];
|
||||
DWORD value_size_;
|
||||
DWORD type_;
|
||||
};
|
||||
|
||||
|
||||
class RegistryKeyIterator {
|
||||
public:
|
||||
// Specify a parent key in construction
|
||||
RegistryKeyIterator(HKEY root_key, LPCTSTR folder_key);
|
||||
|
||||
~RegistryKeyIterator();
|
||||
|
||||
DWORD SubkeyCount() const; // count of the number of subkeys extant
|
||||
|
||||
bool Valid() const; // true while the iterator is valid
|
||||
|
||||
void operator++(); // advance to the next entry in the folder
|
||||
|
||||
// The pointer returned by Name() is a static owned by the function
|
||||
CTP Name() const { return name_; }
|
||||
|
||||
int Index() const { return index_; }
|
||||
|
||||
private:
|
||||
bool Read(); // read in the current values
|
||||
|
||||
HKEY key_; // the registry key being iterated
|
||||
int index_; // current index of the iteration
|
||||
|
||||
// Current values
|
||||
TCHAR name_[MAX_PATH];
|
||||
};
|
||||
|
||||
|
||||
// Register a COM object with the most usual properties.
|
||||
bool RegisterCOMServer(const tchar* guid, const tchar* name,
|
||||
const tchar* modulepath);
|
||||
bool RegisterCOMServer(const tchar* guid, const tchar* name, HINSTANCE module);
|
||||
bool UnregisterCOMServer(const tchar* guid);
|
||||
|
||||
// undo the local types defined above
|
||||
#undef tchar
|
||||
#undef CTP
|
||||
#undef tstr
|
||||
|
||||
#endif // BASE_REGISTRY_H__
|
@ -1,202 +0,0 @@
|
||||
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef BASE_STRING_TOKENIZER_H_
|
||||
#define BASE_STRING_TOKENIZER_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
// StringTokenizerT is a simple string tokenizer class. It works like an
|
||||
// iterator that with each step (see the Advance method) updates members that
|
||||
// refer to the next token in the input string. The user may optionally
|
||||
// configure the tokenizer to return delimiters.
|
||||
//
|
||||
//
|
||||
// EXAMPLE 1:
|
||||
//
|
||||
// StringTokenizer t("this is a test", " ");
|
||||
// while (t.GetNext()) {
|
||||
// printf("%s\n", t.token().c_str());
|
||||
// }
|
||||
//
|
||||
// Output:
|
||||
//
|
||||
// this
|
||||
// is
|
||||
// a
|
||||
// test
|
||||
//
|
||||
//
|
||||
// EXAMPLE 2:
|
||||
//
|
||||
// StringTokenizer t("no-cache=\"foo, bar\", private", ", ");
|
||||
// t.set_quote_chars("\"");
|
||||
// while (t.GetNext()) {
|
||||
// printf("%s\n", t.token().c_str());
|
||||
// }
|
||||
//
|
||||
// Output:
|
||||
//
|
||||
// no-cache="foo, bar"
|
||||
// private
|
||||
//
|
||||
//
|
||||
// EXAMPLE 3:
|
||||
//
|
||||
// bool next_is_option = false, next_is_value = false;
|
||||
// std::string input = "text/html; charset=UTF-8; foo=bar";
|
||||
// StringTokenizer t(input, "; =");
|
||||
// t.set_options(StringTokenizer::RETURN_DELIMS);
|
||||
// while (t.GetNext()) {
|
||||
// if (t.token_is_delim()) {
|
||||
// switch (*t.token_begin()) {
|
||||
// case ';':
|
||||
// next_is_option = true;
|
||||
// break;
|
||||
// case '=':
|
||||
// next_is_value = true;
|
||||
// break;
|
||||
// }
|
||||
// } else {
|
||||
// const char* label;
|
||||
// if (next_is_option) {
|
||||
// label = "option-name";
|
||||
// next_is_option = false;
|
||||
// } else if (next_is_value) {
|
||||
// label = "option-value";
|
||||
// next_is_value = false;
|
||||
// } else {
|
||||
// label = "mime-type";
|
||||
// }
|
||||
// printf("%s: %s\n", label, t.token().c_str());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
template <class str, class const_iterator>
|
||||
class StringTokenizerT {
|
||||
public:
|
||||
typedef typename str::value_type char_type;
|
||||
|
||||
// Options that may be pass to set_options()
|
||||
enum {
|
||||
// Specifies the delimiters should be returned as tokens
|
||||
RETURN_DELIMS = 1 << 0,
|
||||
};
|
||||
|
||||
StringTokenizerT(const str& string,
|
||||
const str& delims) {
|
||||
Init(string.begin(), string.end(), delims);
|
||||
}
|
||||
|
||||
StringTokenizerT(const_iterator string_begin,
|
||||
const_iterator string_end,
|
||||
const str& delims) {
|
||||
Init(string_begin, string_end, delims);
|
||||
}
|
||||
|
||||
// Set the options for this tokenizer. By default, this is 0.
|
||||
void set_options(int options) { options_ = options; }
|
||||
|
||||
// Set the characters to regard as quotes. By default, this is empty. When
|
||||
// a quote char is encountered, the tokenizer will switch into a mode where
|
||||
// it ignores delimiters that it finds. It switches out of this mode once it
|
||||
// finds another instance of the quote char. If a backslash is encountered
|
||||
// within a quoted string, then the next character is skipped.
|
||||
void set_quote_chars(const str& quotes) { quotes_ = quotes; }
|
||||
|
||||
// Call this method to advance the tokenizer to the next delimiter. This
|
||||
// returns false if the tokenizer is complete. This method must be called
|
||||
// before calling any of the token* methods.
|
||||
bool GetNext() {
|
||||
AdvanceState state;
|
||||
token_is_delim_ = false;
|
||||
for (;;) {
|
||||
token_begin_ = token_end_;
|
||||
if (token_end_ == end_)
|
||||
return false;
|
||||
++token_end_;
|
||||
if (AdvanceOne(&state, *token_begin_))
|
||||
break;
|
||||
if (options_ & RETURN_DELIMS) {
|
||||
token_is_delim_ = true;
|
||||
return true;
|
||||
}
|
||||
// else skip over delim
|
||||
}
|
||||
while (token_end_ != end_ && AdvanceOne(&state, *token_end_))
|
||||
++token_end_;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Returns true if token is a delimiter. When the tokenizer is constructed
|
||||
// with the RETURN_DELIMS option, this method can be used to check if the
|
||||
// returned token is actually a delimiter.
|
||||
bool token_is_delim() const { return token_is_delim_; }
|
||||
|
||||
// If GetNext() returned true, then these methods may be used to read the
|
||||
// value of the token.
|
||||
const_iterator token_begin() const { return token_begin_; }
|
||||
const_iterator token_end() const { return token_end_; }
|
||||
str token() const { return str(token_begin_, token_end_); }
|
||||
|
||||
private:
|
||||
void Init(const_iterator string_begin,
|
||||
const_iterator string_end,
|
||||
const str& delims) {
|
||||
token_end_ = string_begin;
|
||||
end_ = string_end;
|
||||
delims_ = delims;
|
||||
options_ = 0;
|
||||
}
|
||||
|
||||
bool IsDelim(char_type c) const {
|
||||
return delims_.find(c) != str::npos;
|
||||
}
|
||||
|
||||
bool IsQuote(char_type c) const {
|
||||
return quotes_.find(c) != str::npos;
|
||||
}
|
||||
|
||||
struct AdvanceState {
|
||||
bool in_quote;
|
||||
bool in_escape;
|
||||
char_type quote_char;
|
||||
AdvanceState() : in_quote(false), in_escape(false) {}
|
||||
};
|
||||
|
||||
// Returns true if a delimiter was not hit.
|
||||
bool AdvanceOne(AdvanceState* state, char_type c) {
|
||||
if (state->in_quote) {
|
||||
if (state->in_escape) {
|
||||
state->in_escape = false;
|
||||
} else if (c == '\\') {
|
||||
state->in_escape = true;
|
||||
} else if (c == state->quote_char) {
|
||||
state->in_quote = false;
|
||||
}
|
||||
} else {
|
||||
if (IsDelim(c))
|
||||
return false;
|
||||
state->in_quote = IsQuote(state->quote_char = c);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
const_iterator token_begin_;
|
||||
const_iterator token_end_;
|
||||
const_iterator end_;
|
||||
str delims_;
|
||||
str quotes_;
|
||||
int options_;
|
||||
bool token_is_delim_;
|
||||
};
|
||||
|
||||
typedef StringTokenizerT<std::string, std::string::const_iterator>
|
||||
StringTokenizer;
|
||||
typedef StringTokenizerT<std::wstring, std::wstring::const_iterator>
|
||||
WStringTokenizer;
|
||||
typedef StringTokenizerT<std::string, const char*> CStringTokenizer;
|
||||
|
||||
#endif // BASE_STRING_TOKENIZER_H_
|
@ -28,18 +28,6 @@ std::wstring SysUTF8ToWide(const StringPiece& utf8);
|
||||
std::string SysWideToNativeMB(const std::wstring& wide);
|
||||
std::wstring SysNativeMBToWide(const StringPiece& native_mb);
|
||||
|
||||
// Windows-specific ------------------------------------------------------------
|
||||
|
||||
#if defined(OS_WIN)
|
||||
|
||||
// Converts between 8-bit and wide strings, using the given code page. The
|
||||
// code page identifier is one accepted by the Windows function
|
||||
// MultiByteToWideChar().
|
||||
std::wstring SysMultiByteToWide(const StringPiece& mb, uint32_t code_page);
|
||||
std::string SysWideToMultiByte(const std::wstring& wide, uint32_t code_page);
|
||||
|
||||
#endif // defined(OS_WIN)
|
||||
|
||||
} // namespace base
|
||||
|
||||
#endif // BASE_SYS_STRING_CONVERSIONS_H_
|
||||
|
@ -10,24 +10,6 @@
|
||||
|
||||
namespace base {
|
||||
|
||||
// Do not assert in this function since it is used by the asssertion code!
|
||||
std::string SysWideToUTF8(const std::wstring& wide) {
|
||||
return SysWideToMultiByte(wide, CP_UTF8);
|
||||
}
|
||||
|
||||
// Do not assert in this function since it is used by the asssertion code!
|
||||
std::wstring SysUTF8ToWide(const StringPiece& utf8) {
|
||||
return SysMultiByteToWide(utf8, CP_UTF8);
|
||||
}
|
||||
|
||||
std::string SysWideToNativeMB(const std::wstring& wide) {
|
||||
return SysWideToMultiByte(wide, CP_ACP);
|
||||
}
|
||||
|
||||
std::wstring SysNativeMBToWide(const StringPiece& native_mb) {
|
||||
return SysMultiByteToWide(native_mb, CP_ACP);
|
||||
}
|
||||
|
||||
// Do not assert in this function since it is used by the asssertion code!
|
||||
std::wstring SysMultiByteToWide(const StringPiece& mb, uint32_t code_page) {
|
||||
if (mb.empty())
|
||||
@ -67,4 +49,22 @@ std::string SysWideToMultiByte(const std::wstring& wide, uint32_t code_page) {
|
||||
return mb;
|
||||
}
|
||||
|
||||
// Do not assert in this function since it is used by the asssertion code!
|
||||
std::string SysWideToUTF8(const std::wstring& wide) {
|
||||
return SysWideToMultiByte(wide, CP_UTF8);
|
||||
}
|
||||
|
||||
// Do not assert in this function since it is used by the asssertion code!
|
||||
std::wstring SysUTF8ToWide(const StringPiece& utf8) {
|
||||
return SysMultiByteToWide(utf8, CP_UTF8);
|
||||
}
|
||||
|
||||
std::string SysWideToNativeMB(const std::wstring& wide) {
|
||||
return SysWideToMultiByte(wide, CP_ACP);
|
||||
}
|
||||
|
||||
std::wstring SysNativeMBToWide(const StringPiece& native_mb) {
|
||||
return SysMultiByteToWide(native_mb, CP_ACP);
|
||||
}
|
||||
|
||||
} // namespace base
|
||||
|
@ -1,64 +0,0 @@
|
||||
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "base/thread_collision_warner.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/platform_thread.h"
|
||||
|
||||
namespace base {
|
||||
|
||||
void DCheckAsserter::warn() {
|
||||
NOTREACHED() << "Thread Collision";
|
||||
}
|
||||
|
||||
static subtle::Atomic32 CurrentThread() {
|
||||
const PlatformThreadId current_thread_id = PlatformThread::CurrentId();
|
||||
// We need to get the thread id into an atomic data type. This might be a
|
||||
// truncating conversion, but any loss-of-information just increases the
|
||||
// chance of a fault negative, not a false positive.
|
||||
const subtle::Atomic32 atomic_thread_id =
|
||||
static_cast<subtle::Atomic32>(current_thread_id);
|
||||
|
||||
return atomic_thread_id;
|
||||
}
|
||||
|
||||
void ThreadCollisionWarner::EnterSelf() {
|
||||
// If the active thread is 0 then I'll write the current thread ID
|
||||
// if two or more threads arrive here only one will succeed to
|
||||
// write on valid_thread_id_ the current thread ID.
|
||||
subtle::Atomic32 current_thread_id = CurrentThread();
|
||||
|
||||
int previous_value = subtle::NoBarrier_CompareAndSwap(&valid_thread_id_,
|
||||
0,
|
||||
current_thread_id);
|
||||
if (previous_value != 0 && previous_value != current_thread_id) {
|
||||
// gotcha! a thread is trying to use the same class and that is
|
||||
// not current thread.
|
||||
asserter_->warn();
|
||||
}
|
||||
|
||||
subtle::NoBarrier_AtomicIncrement(&counter_, 1);
|
||||
}
|
||||
|
||||
void ThreadCollisionWarner::Enter() {
|
||||
subtle::Atomic32 current_thread_id = CurrentThread();
|
||||
|
||||
if (subtle::NoBarrier_CompareAndSwap(&valid_thread_id_,
|
||||
0,
|
||||
current_thread_id) != 0) {
|
||||
// gotcha! another thread is trying to use the same class.
|
||||
asserter_->warn();
|
||||
}
|
||||
|
||||
subtle::NoBarrier_AtomicIncrement(&counter_, 1);
|
||||
}
|
||||
|
||||
void ThreadCollisionWarner::Leave() {
|
||||
if (subtle::Barrier_AtomicIncrement(&counter_, -1) == 0) {
|
||||
subtle::NoBarrier_Store(&valid_thread_id_, 0);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace base
|
@ -1,242 +0,0 @@
|
||||
// Copyright (c) 2008 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef BASE_THREAD_COLLISION_WARNER_H_
|
||||
#define BASE_THREAD_COLLISION_WARNER_H_
|
||||
|
||||
#include <memory.h>
|
||||
|
||||
#include "base/atomicops.h"
|
||||
|
||||
// A helper class alongside macros to be used to verify assumptions about thread
|
||||
// safety of a class.
|
||||
//
|
||||
// Example: Queue implementation non thread-safe but still usable if clients
|
||||
// are synchronized somehow.
|
||||
//
|
||||
// In this case the macro DFAKE_SCOPED_LOCK has to be
|
||||
// used, it checks that if a thread is inside the push/pop then
|
||||
// noone else is still inside the pop/push
|
||||
//
|
||||
// class NonThreadSafeQueue {
|
||||
// public:
|
||||
// ...
|
||||
// void push(int) { DFAKE_SCOPED_LOCK(push_pop_); ... }
|
||||
// int pop() { DFAKE_SCOPED_LOCK(push_pop_); ... }
|
||||
// ...
|
||||
// private:
|
||||
// DFAKE_MUTEX(push_pop_);
|
||||
// };
|
||||
//
|
||||
//
|
||||
// Example: Queue implementation non thread-safe but still usable if clients
|
||||
// are synchronized somehow, it calls a method to "protect" from
|
||||
// a "protected" method
|
||||
//
|
||||
// In this case the macro DFAKE_SCOPED_RECURSIVE_LOCK
|
||||
// has to be used, it checks that if a thread is inside the push/pop
|
||||
// then noone else is still inside the pop/push
|
||||
//
|
||||
// class NonThreadSafeQueue {
|
||||
// public:
|
||||
// void push(int) {
|
||||
// DFAKE_SCOPED_LOCK(push_pop_);
|
||||
// ...
|
||||
// }
|
||||
// int pop() {
|
||||
// DFAKE_SCOPED_RECURSIVE_LOCK(push_pop_);
|
||||
// bar();
|
||||
// ...
|
||||
// }
|
||||
// void bar() { DFAKE_SCOPED_RECURSIVE_LOCK(push_pop_); ... }
|
||||
// ...
|
||||
// private:
|
||||
// DFAKE_MUTEX(push_pop_);
|
||||
// };
|
||||
//
|
||||
//
|
||||
// Example: Queue implementation not usable even if clients are synchronized,
|
||||
// so only one thread in the class life cycle can use the two members
|
||||
// push/pop.
|
||||
//
|
||||
// In this case the macro DFAKE_SCOPED_LOCK_THREAD_LOCKED pins the
|
||||
// specified
|
||||
// critical section the first time a thread enters push or pop, from
|
||||
// that time on only that thread is allowed to execute push or pop.
|
||||
//
|
||||
// class NonThreadSafeQueue {
|
||||
// public:
|
||||
// ...
|
||||
// void push(int) { DFAKE_SCOPED_LOCK_THREAD_LOCKED(push_pop_); ... }
|
||||
// int pop() { DFAKE_SCOPED_LOCK_THREAD_LOCKED(push_pop_); ... }
|
||||
// ...
|
||||
// private:
|
||||
// DFAKE_MUTEX(push_pop_);
|
||||
// };
|
||||
//
|
||||
//
|
||||
// Example: Class that has to be contructed/destroyed on same thread, it has
|
||||
// a "shareable" method (with external syncronization) and a not
|
||||
// shareable method (even with external synchronization).
|
||||
//
|
||||
// In this case 3 Critical sections have to be defined
|
||||
//
|
||||
// class ExoticClass {
|
||||
// public:
|
||||
// ExoticClass() { DFAKE_SCOPED_LOCK_THREAD_LOCKED(ctor_dtor_); ... }
|
||||
// ~ExoticClass() { DFAKE_SCOPED_LOCK_THREAD_LOCKED(ctor_dtor_); ... }
|
||||
//
|
||||
// void Shareable() { DFAKE_SCOPED_LOCK(shareable_section_); ... }
|
||||
// void NotShareable() { DFAKE_SCOPED_LOCK_THREAD_LOCKED(ctor_dtor_); ... }
|
||||
// ...
|
||||
// private:
|
||||
// DFAKE_MUTEX(ctor_dtor_);
|
||||
// DFAKE_MUTEX(shareable_section_);
|
||||
// };
|
||||
|
||||
|
||||
#if !defined(NDEBUG)
|
||||
|
||||
// Defines a class member that acts like a mutex. It is used only as a
|
||||
// verification tool.
|
||||
#define DFAKE_MUTEX(obj) \
|
||||
mutable base::ThreadCollisionWarner obj;
|
||||
// Asserts the call is never called simultaneously in two threads. Used at
|
||||
// member function scope.
|
||||
#define DFAKE_SCOPED_LOCK(obj) \
|
||||
base::ThreadCollisionWarner::ScopedCheck s_check_##obj(&obj)
|
||||
// Asserts the call is never called simultaneously in two threads. Used at
|
||||
// member function scope. Same as DFAKE_SCOPED_LOCK but allows recursive locks.
|
||||
#define DFAKE_SCOPED_RECURSIVE_LOCK(obj) \
|
||||
base::ThreadCollisionWarner::ScopedRecursiveCheck sr_check_##obj(&obj)
|
||||
// Asserts the code is always executed in the same thread.
|
||||
#define DFAKE_SCOPED_LOCK_THREAD_LOCKED(obj) \
|
||||
base::ThreadCollisionWarner::Check check_##obj(&obj)
|
||||
|
||||
#else
|
||||
|
||||
#define DFAKE_MUTEX(obj)
|
||||
#define DFAKE_SCOPED_LOCK(obj) ((void)0)
|
||||
#define DFAKE_SCOPED_RECURSIVE_LOCK(obj) ((void)0)
|
||||
#define DFAKE_SCOPED_LOCK_THREAD_LOCKED(obj) ((void)0)
|
||||
|
||||
#endif
|
||||
|
||||
namespace base {
|
||||
|
||||
// The class ThreadCollisionWarner uses an Asserter to notify the collision
|
||||
// AsserterBase is the interfaces and DCheckAsserter is the default asserter
|
||||
// used. During the unit tests is used another class that doesn't "DCHECK"
|
||||
// in case of collision (check thread_collision_warner_unittests.cc)
|
||||
struct AsserterBase {
|
||||
virtual ~AsserterBase() {}
|
||||
virtual void warn() = 0;
|
||||
};
|
||||
|
||||
struct DCheckAsserter : public AsserterBase {
|
||||
virtual ~DCheckAsserter() {}
|
||||
virtual void warn();
|
||||
};
|
||||
|
||||
class ThreadCollisionWarner {
|
||||
public:
|
||||
// The parameter asserter is there only for test purpose
|
||||
explicit ThreadCollisionWarner(AsserterBase* asserter = new DCheckAsserter())
|
||||
: valid_thread_id_(0),
|
||||
counter_(0),
|
||||
asserter_(asserter) {}
|
||||
|
||||
~ThreadCollisionWarner() {
|
||||
delete asserter_;
|
||||
}
|
||||
|
||||
// This class is meant to be used through the macro
|
||||
// DFAKE_SCOPED_LOCK_THREAD_LOCKED
|
||||
// it doesn't leave the critical section, as opposed to ScopedCheck,
|
||||
// because the critical section being pinned is allowed to be used only
|
||||
// from one thread
|
||||
class Check {
|
||||
public:
|
||||
explicit Check(ThreadCollisionWarner* warner)
|
||||
: warner_(warner) {
|
||||
warner_->EnterSelf();
|
||||
}
|
||||
|
||||
~Check() {}
|
||||
|
||||
private:
|
||||
ThreadCollisionWarner* warner_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(Check);
|
||||
};
|
||||
|
||||
// This class is meant to be used through the macro
|
||||
// DFAKE_SCOPED_LOCK
|
||||
class ScopedCheck {
|
||||
public:
|
||||
explicit ScopedCheck(ThreadCollisionWarner* warner)
|
||||
: warner_(warner) {
|
||||
warner_->Enter();
|
||||
}
|
||||
|
||||
~ScopedCheck() {
|
||||
warner_->Leave();
|
||||
}
|
||||
|
||||
private:
|
||||
ThreadCollisionWarner* warner_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(ScopedCheck);
|
||||
};
|
||||
|
||||
// This class is meant to be used through the macro
|
||||
// DFAKE_SCOPED_RECURSIVE_LOCK
|
||||
class ScopedRecursiveCheck {
|
||||
public:
|
||||
explicit ScopedRecursiveCheck(ThreadCollisionWarner* warner)
|
||||
: warner_(warner) {
|
||||
warner_->EnterSelf();
|
||||
}
|
||||
|
||||
~ScopedRecursiveCheck() {
|
||||
warner_->Leave();
|
||||
}
|
||||
|
||||
private:
|
||||
ThreadCollisionWarner* warner_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(ScopedRecursiveCheck);
|
||||
};
|
||||
|
||||
private:
|
||||
// This method stores the current thread identifier and does a DCHECK
|
||||
// if a another thread has already done it, it is safe if same thread
|
||||
// calls this multiple time (recursion allowed).
|
||||
void EnterSelf();
|
||||
|
||||
// Same as EnterSelf but recursion is not allowed.
|
||||
void Enter();
|
||||
|
||||
// Removes the thread_id stored in order to allow other threads to
|
||||
// call EnterSelf or Enter.
|
||||
void Leave();
|
||||
|
||||
// This stores the thread id that is inside the critical section, if the
|
||||
// value is 0 then no thread is inside.
|
||||
volatile subtle::Atomic32 valid_thread_id_;
|
||||
|
||||
// Counter to trace how many time a critical section was "pinned"
|
||||
// (when allowed) in order to unpin it when counter_ reaches 0.
|
||||
volatile subtle::Atomic32 counter_;
|
||||
|
||||
// Here only for class unit tests purpose, during the test I need to not
|
||||
// DCHECK but notify the collision with something else.
|
||||
AsserterBase* asserter_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(ThreadCollisionWarner);
|
||||
};
|
||||
|
||||
} // namespace base
|
||||
|
||||
#endif // BASE_THREAD_COLLISION_WARNER_H_
|
@ -1,40 +0,0 @@
|
||||
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Basic time formatting methods. These methods use the current locale
|
||||
// formatting for displaying the time.
|
||||
|
||||
#ifndef BASE_TIME_FORMAT_H_
|
||||
#define BASE_TIME_FORMAT_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace base {
|
||||
|
||||
class Time;
|
||||
|
||||
// Returns the time of day, e.g., "3:07 PM".
|
||||
std::wstring TimeFormatTimeOfDay(const Time& time);
|
||||
|
||||
// Returns a shortened date, e.g. "Nov 7, 2007"
|
||||
std::wstring TimeFormatShortDate(const Time& time);
|
||||
|
||||
// Returns a numeric date such as 12/13/52.
|
||||
std::wstring TimeFormatShortDateNumeric(const Time& time);
|
||||
|
||||
// Formats a time in a friendly sentence format, e.g.
|
||||
// "Monday, March 6, 2008 2:44:30 PM".
|
||||
std::wstring TimeFormatShortDateAndTime(const Time& time);
|
||||
|
||||
// Formats a time in a friendly sentence format, e.g.
|
||||
// "Monday, March 6, 2008 2:44:30 PM".
|
||||
std::wstring TimeFormatFriendlyDateAndTime(const Time& time);
|
||||
|
||||
// Formats a time in a friendly sentence format, e.g.
|
||||
// "Monday, March 6, 2008".
|
||||
std::wstring TimeFormatFriendlyDate(const Time& time);
|
||||
|
||||
} // namespace base
|
||||
|
||||
#endif // BASE_TIME_FORMAT_H_
|
@ -8,25 +8,12 @@
|
||||
#include <sddl.h>
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/registry.h"
|
||||
#include "base/singleton.h"
|
||||
#include "base/string_util.h"
|
||||
#include "base/tracked.h"
|
||||
|
||||
namespace win_util {
|
||||
|
||||
bool IsShiftPressed() {
|
||||
return (::GetKeyState(VK_SHIFT) & 0x80) == 0x80;
|
||||
}
|
||||
|
||||
bool IsCtrlPressed() {
|
||||
return (::GetKeyState(VK_CONTROL) & 0x80) == 0x80;
|
||||
}
|
||||
|
||||
bool IsAltPressed() {
|
||||
return (::GetKeyState(VK_MENU) & 0x80) == 0x80;
|
||||
}
|
||||
|
||||
std::wstring FormatMessage(unsigned messageid) {
|
||||
wchar_t* string_buffer = NULL;
|
||||
unsigned string_length = ::FormatMessage(
|
||||
@ -50,25 +37,3 @@ std::wstring FormatLastWin32Error() {
|
||||
}
|
||||
|
||||
} // namespace win_util
|
||||
|
||||
#ifdef _MSC_VER
|
||||
//
|
||||
// If the ASSERT below fails, please install Visual Studio 2005 Service Pack 1.
|
||||
//
|
||||
extern char VisualStudio2005ServicePack1Detection[10];
|
||||
COMPILE_ASSERT(sizeof(&VisualStudio2005ServicePack1Detection) == sizeof(void*),
|
||||
VS2005SP1Detect);
|
||||
//
|
||||
// Chrome requires at least Service Pack 1 for Visual Studio 2005.
|
||||
//
|
||||
#endif // _MSC_VER
|
||||
|
||||
#if 0
|
||||
#error You must install the Windows 2008 or Vista Software Development Kit and \
|
||||
set it as your default include path to build this library. You can grab it by \
|
||||
searching for "download windows sdk 2008" in your favorite web search engine. \
|
||||
Also make sure you register the SDK with Visual Studio, by selecting \
|
||||
"Integrate Windows SDK with Visual Studio 2005" from the Windows SDK \
|
||||
menu (see Start - All Programs - Microsoft Windows SDK - \
|
||||
Visual Studio Registration).
|
||||
#endif
|
||||
|
@ -14,19 +14,6 @@
|
||||
|
||||
namespace win_util {
|
||||
|
||||
// Returns true if the shift key is currently pressed.
|
||||
bool IsShiftPressed();
|
||||
|
||||
// Returns true if the ctrl key is currently pressed.
|
||||
bool IsCtrlPressed();
|
||||
|
||||
// Returns true if the alt key is currently pressed.
|
||||
bool IsAltPressed();
|
||||
|
||||
// Use the Win32 API FormatMessage() function to generate a string, using
|
||||
// Windows's default Message Compiled resources; ignoring the inserts.
|
||||
std::wstring FormatMessage(unsigned messageid);
|
||||
|
||||
// Uses the last Win32 error to generate a human readable message string.
|
||||
std::wstring FormatLastWin32Error();
|
||||
|
||||
|
@ -4,436 +4,13 @@
|
||||
|
||||
#include "chrome/common/chrome_switches.h"
|
||||
|
||||
#include "base/base_switches.h"
|
||||
|
||||
namespace switches {
|
||||
|
||||
// Can't find the switch you are looking for? try looking in
|
||||
// base/base_switches.cc instead.
|
||||
|
||||
// Suppresses hang monitor dialogs in renderer processes.
|
||||
const wchar_t kDisableHangMonitor[] = L"disable-hang-monitor";
|
||||
|
||||
// Completely disables UMA metrics system.
|
||||
const wchar_t kDisableMetrics[] = L"disable-metrics";
|
||||
|
||||
// Enables the recording of metrics reports but disables reporting.
|
||||
// In contrast to kDisableMetrics, this executes all the code that a normal
|
||||
// client would use for reporting, except the report is dropped rather than sent
|
||||
// to the server. This is useful for finding issues in the metrics code during
|
||||
// UI and performance tests.
|
||||
const wchar_t kMetricsRecordingOnly[] = L"metrics-recording-only";
|
||||
|
||||
// Causes the browser process to throw an assertion on startup.
|
||||
const wchar_t kBrowserAssertTest[] = L"assert-test";
|
||||
|
||||
// Causes the renderer process to throw an assertion on launch.
|
||||
const wchar_t kRendererAssertTest[] = L"renderer-assert-test";
|
||||
|
||||
// Causes the browser process to crash on startup.
|
||||
const wchar_t kBrowserCrashTest[] = L"crash-test";
|
||||
|
||||
// Causes the renderer process to crash on launch.
|
||||
const wchar_t kRendererCrashTest[] = L"renderer-crash-test";
|
||||
|
||||
// Causes the renderer process to display a dialog on launch.
|
||||
const wchar_t kRendererStartupDialog[] = L"renderer-startup-dialog";
|
||||
|
||||
// Causes the plugin process to display a dialog on launch.
|
||||
const wchar_t kPluginStartupDialog[] = L"plugin-startup-dialog";
|
||||
|
||||
// Specifies a command that should be used to launch the plugin process. Useful
|
||||
// for running the plugin process through purify or quantify. Ex:
|
||||
// --plugin-launcher="path\to\purify /Run=yes"
|
||||
const wchar_t kPluginLauncher[] = L"plugin-launcher";
|
||||
|
||||
// The value of this switch tells the child process which
|
||||
// IPC channel the browser expects to use to communicate with it.
|
||||
const wchar_t kProcessChannelID[] = L"channel";
|
||||
|
||||
// The value of this switch tells the app to listen for and broadcast
|
||||
// testing-related messages on IPC channel with the given ID.
|
||||
const wchar_t kTestingChannelID[] = L"testing-channel";
|
||||
|
||||
// The value of this switch specifies which page will be displayed
|
||||
// in newly-opened tabs. We need this for testing purposes so
|
||||
// that the UI tests don't depend on what comes up for http://google.com.
|
||||
const wchar_t kHomePage[] = L"homepage";
|
||||
|
||||
// Causes the process to run as renderer instead of as browser.
|
||||
const wchar_t kRendererProcess[] = L"renderer";
|
||||
|
||||
// Path to the exe to run for the renderer and plugin subprocesses.
|
||||
const wchar_t kBrowserSubprocessPath[] = L"browser-subprocess-path";
|
||||
|
||||
// Causes the process to run as a plugin subprocess.
|
||||
const wchar_t kPluginProcess[] = L"plugin";
|
||||
|
||||
// Causes the process to run as a worker subprocess.
|
||||
const wchar_t kWorkerProcess[] = L"worker";
|
||||
|
||||
// Runs the renderer and plugins in the same process as the browser
|
||||
const wchar_t kSingleProcess[] = L"single-process";
|
||||
|
||||
// Runs each set of script-connected tabs (i.e., a BrowsingInstance) in its own
|
||||
// renderer process. We default to using a renderer process for each
|
||||
// site instance (i.e., group of pages from the same registered domain with
|
||||
// script connections to each other).
|
||||
const wchar_t kProcessPerTab[] = L"process-per-tab";
|
||||
|
||||
// Runs a single process for each site (i.e., group of pages from the same
|
||||
// registered domain) the user visits. We default to using a renderer process
|
||||
// for each site instance (i.e., group of pages from the same registered
|
||||
// domain with script connections to each other).
|
||||
const wchar_t kProcessPerSite[] = L"process-per-site";
|
||||
|
||||
// Runs plugins inside the renderer process
|
||||
const wchar_t kInProcessPlugins[] = L"in-process-plugins";
|
||||
|
||||
// Runs the renderer outside the sandbox.
|
||||
const wchar_t kNoSandbox[] = L"no-sandbox";
|
||||
|
||||
// Runs the plugin processes inside the sandbox.
|
||||
const wchar_t kSafePlugins[] = L"safe-plugins";
|
||||
|
||||
// Excludes these plugins from the plugin sandbox.
|
||||
// This is a comma-separated list of plugin library names and activex clsid.
|
||||
const wchar_t kTrustedPlugins[] = L"trusted-plugins";
|
||||
|
||||
// Runs the security test for the sandbox.
|
||||
const wchar_t kTestSandbox[] = L"test-sandbox";
|
||||
|
||||
// Specifies the user data directory, which is where the browser will look
|
||||
// for all of its state.
|
||||
const wchar_t kUserDataDir[] = L"user-data-dir";
|
||||
|
||||
// Specifies the plugin data directory, which is where plugins (Gears
|
||||
// specifically) will store its state.
|
||||
const wchar_t kPluginDataDir[] = L"plugin-data-dir";
|
||||
|
||||
// Use a specific disk cache location, rather than one derived from the
|
||||
// UserDatadir.
|
||||
const wchar_t kDiskCacheDir[] = L"disk-cache-dir";
|
||||
|
||||
// Whether the multiple profiles feature based on the user-data-dir flag is
|
||||
// enabled or not.
|
||||
const wchar_t kEnableUserDataDirProfiles[] = L"enable-udd-profiles";
|
||||
|
||||
// Specifies the path to the user data folder for the parent profile.
|
||||
const wchar_t kParentProfile[] = L"parent-profile";
|
||||
|
||||
// Specifies that the associated value should be launched in "application" mode.
|
||||
const wchar_t kApp[] = L"app";
|
||||
|
||||
// Specifies if the dom_automation_controller_ needs to be bound in the
|
||||
// renderer. This binding happens on per-frame basis and hence can potentially
|
||||
// be a performance bottleneck. One should only enable it when automating
|
||||
// dom based tests.
|
||||
const wchar_t kDomAutomationController[] = L"dom-automation";
|
||||
|
||||
// Tells the plugin process the path of the plugin to load
|
||||
const wchar_t kPluginPath[] = L"plugin-path";
|
||||
|
||||
// A string used to override the default user agent with a custom one.
|
||||
const wchar_t kUserAgent[] = L"user-agent";
|
||||
|
||||
// Specifies the flags passed to JS engine
|
||||
const wchar_t kJavaScriptFlags[] = L"js-flags";
|
||||
|
||||
// The Country we should use. This is normally obtained from the operating
|
||||
// system during first run and cached in the preferences afterwards. This is a
|
||||
// string value, the 2 letter code from ISO 3166-1.
|
||||
const wchar_t kCountry[] = L"country";
|
||||
|
||||
// The language file that we want to try to open. Of the form
|
||||
// language[-country] where language is the 2 letter code from ISO-639.
|
||||
const wchar_t kLang[] = L"lang";
|
||||
|
||||
// Will add kDebugOnStart to every child processes. If a value is passed, it
|
||||
// will be used as a filter to determine if the child process should have the
|
||||
// kDebugOnStart flag passed on or not.
|
||||
const wchar_t kDebugChildren[] = L"debug-children";
|
||||
|
||||
// Will add kWaitForDebugger to every child processes. If a value is passed, it
|
||||
// will be used as a filter to determine if the child process should have the
|
||||
// kWaitForDebugger flag passed on or not.
|
||||
const wchar_t kWaitForDebuggerChildren[] = L"wait-for-debugger-children";
|
||||
|
||||
// Will filter log messages to show only the messages that are prefixed
|
||||
// with the specified value
|
||||
const wchar_t kLogFilterPrefix[] = L"log-filter-prefix";
|
||||
|
||||
// Force logging to be enabled. Logging is disabled by default in release
|
||||
// builds.
|
||||
const wchar_t kEnableLogging[] = L"enable-logging";
|
||||
|
||||
// Force logging to be disabled. Logging is enabled by default in debug
|
||||
// builds.
|
||||
const wchar_t kDisableLogging[] = L"disable-logging";
|
||||
|
||||
// Sets the minimum log level. Valid values are from 0 to 3:
|
||||
// INFO = 0, WARNING = 1, LOG_ERROR = 2, LOG_FATAL = 3.
|
||||
const wchar_t kLoggingLevel[] = L"log-level";
|
||||
|
||||
// Make plugin processes log their sent and received messages to CHROMIUM_LOG(INFO).
|
||||
const wchar_t kLogPluginMessages[] = L"log-plugin-messages";
|
||||
|
||||
// Dump any accumualted histograms to the log when browser terminates (requires
|
||||
// logging to be enabled to really do anything). Used by developers and test
|
||||
// scripts.
|
||||
const wchar_t kDumpHistogramsOnExit[] = L"dump-histograms-on-exit";
|
||||
|
||||
// enable remote debug / automation shell on the specified port
|
||||
const wchar_t kRemoteShellPort[] = L"remote-shell-port";
|
||||
|
||||
// Runs un-installation steps that were done by chrome first-run.
|
||||
const wchar_t kUninstall[] = L"uninstall";
|
||||
|
||||
// Number of entries to show in the omnibox popup.
|
||||
const wchar_t kOmniBoxPopupCount[] = L"omnibox-popup-count";
|
||||
|
||||
// The value of this switch tells the app to listen for and broadcast
|
||||
// automation-related messages on IPC channel with the given ID.
|
||||
const wchar_t kAutomationClientChannelID[] = L"automation-channel";
|
||||
|
||||
// Indicates the last session should be restored on startup. This overrides
|
||||
// the preferences value and is primarily intended for testing. The value of
|
||||
// this switch is the number of tabs to wait until loaded before
|
||||
// 'load completed' is sent to the ui_test.
|
||||
const wchar_t kRestoreLastSession[] = L"restore-last-session";
|
||||
|
||||
// Chrome supports a playback and record mode. Record mode saves *everything*
|
||||
// to the cache. Playback mode reads data exclusively from the cache. This
|
||||
// allows us to record a session into the cache and then replay it at will.
|
||||
const wchar_t kRecordMode[] = L"record-mode";
|
||||
const wchar_t kPlaybackMode[] = L"playback-mode";
|
||||
|
||||
// Don't record/playback events when using record & playback.
|
||||
const wchar_t kNoEvents[] = L"no-events";
|
||||
|
||||
// Support a separate switch that enables the v8 playback extension.
|
||||
// The extension causes javascript calls to Date.now() and Math.random()
|
||||
// to return consistent values, such that subsequent loads of the same
|
||||
// page will result in consistent js-generated data and XHR requests.
|
||||
// Pages may still be able to generate inconsistent data from plugins.
|
||||
const wchar_t kNoJsRandomness[] = L"no-js-randomness";
|
||||
|
||||
// Make Windows happy by allowing it to show "Enable access to this program"
|
||||
// checkbox in Add/Remove Programs->Set Program Access and Defaults. This
|
||||
// only shows an error box because the only way to hide Chrome is by
|
||||
// uninstalling it.
|
||||
const wchar_t kHideIcons[] = L"hide-icons";
|
||||
|
||||
const wchar_t kShowIcons[] = L"show-icons";
|
||||
|
||||
// Make Chrome default browser
|
||||
const wchar_t kMakeDefaultBrowser[] = L"make-default-browser";
|
||||
|
||||
// Use a specified proxy server, overrides system settings. This switch only
|
||||
// affects HTTP and HTTPS requests.
|
||||
const wchar_t kProxyServer[] = L"proxy-server";
|
||||
|
||||
// Use WinHTTP to fetch and evaluate PAC scripts. Otherwise the default is
|
||||
// to use Chromium's network stack to fetch, and V8 to evaluate.
|
||||
const wchar_t kWinHttpProxyResolver[] = L"winhttp-proxy-resolver";
|
||||
|
||||
// Chrome will support prefetching of DNS information. Until this becomes
|
||||
// the default, we'll provide a command line switch.
|
||||
extern const wchar_t kDnsLogDetails[] = L"dns-log-details";
|
||||
extern const wchar_t kDnsPrefetchDisable[] = L"dns-prefetch-disable";
|
||||
|
||||
// Enables support to debug printing subsystem.
|
||||
const wchar_t kDebugPrint[] = L"debug-print";
|
||||
|
||||
// Allow initialization of all activex controls. This is only to help website
|
||||
// developers test their controls to see if they are compatible in Chrome.
|
||||
// Note there's a duplicate value in activex_shared.cc (to avoid
|
||||
// dependency on chrome module). Please change both locations at the same time.
|
||||
const wchar_t kAllowAllActiveX[] = L"allow-all-activex";
|
||||
|
||||
// Browser flag to disable the web inspector for all renderers.
|
||||
const wchar_t kDisableDevTools[] = L"disable-dev-tools";
|
||||
|
||||
// Enable web inspector for all windows, even if they're part of the browser.
|
||||
// Allows us to use our dev tools to debug browser windows itself.
|
||||
const wchar_t kAlwaysEnableDevTools[] = L"always-enable-dev-tools";
|
||||
|
||||
// Used to set the value of SessionRestore::num_tabs_to_load_. See
|
||||
// session_restore.h for details.
|
||||
const wchar_t kTabCountToLoadOnSessionRestore[] =
|
||||
L"tab-count-to-load-on-session-restore";
|
||||
|
||||
// Enable dynamic loading of the Memory Profiler DLL, which will trace
|
||||
// all memory allocations during the run.
|
||||
const wchar_t kMemoryProfiling[] = L"memory-profile";
|
||||
|
||||
// Configure Chrome's memory model.
|
||||
// Does chrome really need multiple memory models? No. But we get a lot
|
||||
// of concerns from individuals about how the changes work on *their*
|
||||
// system, and we need to be able to experiment with a few choices.
|
||||
const wchar_t kMemoryModel[] = L"memory-model";
|
||||
|
||||
// By default, cookies are not allowed on file://. They are needed in for
|
||||
// testing, for example page cycler and layout tests. See bug 1157243.
|
||||
const wchar_t kEnableFileCookies[] = L"enable-file-cookies";
|
||||
|
||||
// Start the browser maximized, regardless of any previous settings.
|
||||
const wchar_t kStartMaximized[] = L"start-maximized";
|
||||
|
||||
// Spawn threads to watch for excessive delays in specified message loops.
|
||||
// User should set breakpoints on Alarm() to examine problematic thread.
|
||||
// Usage: -enable-watchdog=[ui][io]
|
||||
// Order of the listed sub-arguments does not matter.
|
||||
const wchar_t kEnableWatchdog[] = L"enable-watchdog";
|
||||
|
||||
// Display the First Run experience when the browser is started, regardless of
|
||||
// whether or not it's actually the first run.
|
||||
const wchar_t kFirstRun[] = L"first-run";
|
||||
|
||||
// Bypass the First Run experience when the browser is started, regardless of
|
||||
// whether or not it's actually the first run. Overrides kFirstRun in case
|
||||
// you're for some reason tempted to pass them both.
|
||||
const wchar_t kNoFirstRun[] = L"no-first-run";
|
||||
|
||||
// Enable histograming of tasks served by MessageLoop. See about:histograms/Loop
|
||||
// for results, which show frequency of messages on each thread, including APC
|
||||
// count, object signalling count, etc.
|
||||
const wchar_t kMessageLoopHistogrammer[] = L"message-loop-histogrammer";
|
||||
|
||||
// Perform importing from another browser. The value associated with this
|
||||
// setting encodes the target browser and what items to import.
|
||||
const wchar_t kImport[] = L"import";
|
||||
|
||||
// Change the DCHECKS to dump memory and continue instead of displaying error
|
||||
// dialog. This is valid only in Release mode when --enable-dcheck is
|
||||
// specified.
|
||||
const wchar_t kSilentDumpOnDCHECK[] = L"silent-dump-on-dcheck";
|
||||
|
||||
// Normally when the user attempts to navigate to a page that was the result of
|
||||
// a post we prompt to make sure they want to. This switch may be used to
|
||||
// disable that check. This switch is used during automated testing.
|
||||
const wchar_t kDisablePromptOnRepost[] = L"disable-prompt-on-repost";
|
||||
|
||||
// Disable pop-up blocking.
|
||||
const wchar_t kDisablePopupBlocking[] = L"disable-popup-blocking";
|
||||
|
||||
// Don't execute JavaScript (browser JS like the new tab page still runs).
|
||||
const wchar_t kDisableJavaScript[] = L"disable-javascript";
|
||||
|
||||
// Don't enforce the same-origin policy. (Used by people testing their sites.)
|
||||
const wchar_t kDisableWebSecurity[] = L"disable-web-security";
|
||||
|
||||
// Prevent Java from running.
|
||||
const wchar_t kDisableJava[] = L"disable-java";
|
||||
|
||||
// Prevent plugins from running.
|
||||
const wchar_t kDisablePlugins[] = L"disable-plugins";
|
||||
|
||||
// Prevent images from loading.
|
||||
const wchar_t kDisableImages[] = L"disable-images";
|
||||
|
||||
// Use the low fragmentation heap for the CRT.
|
||||
const wchar_t kUseLowFragHeapCrt[] = L"use-lf-heap";
|
||||
|
||||
#ifndef NDEBUG
|
||||
// Debug only switch to specify which gears plugin dll to load.
|
||||
const wchar_t kGearsPluginPathOverride[] = L"gears-plugin-path";
|
||||
#endif
|
||||
|
||||
// Enable the fastback page cache.
|
||||
const wchar_t kEnableFastback[] = L"enable-fastback";
|
||||
|
||||
// Allow loading of the javascript debugger UI from the filesystem.
|
||||
const wchar_t kJavaScriptDebuggerPath[] = L"javascript-debugger-path";
|
||||
|
||||
const wchar_t kDisableP13n[] = L"disable-p13n";
|
||||
|
||||
// Enable support for SDCH filtering (dictionary based expansion of content).
|
||||
// Optional argument is *the* only domain name that will have SDCH suppport.
|
||||
// Default is "-enable-sdch" to advertise SDCH on all domains.
|
||||
// Sample usage with argument: "-enable-sdch=.google.com"
|
||||
// SDCH is currently only supported server-side for searches on google.com.
|
||||
const wchar_t kSdchFilter[] = L"enable-sdch";
|
||||
|
||||
// Enable user script support.
|
||||
const wchar_t kEnableUserScripts[] = L"enable-user-scripts";
|
||||
|
||||
// Enable extensions.
|
||||
const wchar_t kEnableExtensions[] = L"enable-extensions";
|
||||
|
||||
// Install the extension specified in the argument. This is for MIME type
|
||||
// handling so that users can double-click on an extension.
|
||||
const wchar_t kInstallExtension[] = L"install-extension";
|
||||
|
||||
// Load an extension from the specified directory.
|
||||
const wchar_t kLoadExtension[] = L"load-extension";
|
||||
|
||||
// Load an NPAPI plugin from the specified path.
|
||||
const wchar_t kLoadPlugin[] = L"load-plugin";
|
||||
|
||||
// directory to locate user scripts in as an over-ride of the default
|
||||
const wchar_t kUserScriptsDir[] = L"user-scripts-dir";
|
||||
|
||||
// Causes the browser to launch directly in incognito mode.
|
||||
const wchar_t kIncognito[] = L"incognito";
|
||||
|
||||
// Turns on the accessibility in the renderer. Off by default until
|
||||
// http://b/issue?id=1432077 is fixed.
|
||||
const wchar_t kEnableRendererAccessibility[] = L"enable-renderer-accessibility";
|
||||
|
||||
// Pass the name of the current running automated test to Chrome.
|
||||
const wchar_t kTestName[] = L"test-name";
|
||||
|
||||
// On POSIX only: the contents of this flag are prepended to the renderer
|
||||
// command line. (Useful values might be "valgrind" or "gdb --args")
|
||||
const wchar_t kRendererCmdPrefix[] = L"renderer-cmd-prefix";
|
||||
|
||||
// Temparary option for new ftp implemetation.
|
||||
const wchar_t kNewFtp[] = L"new-ftp";
|
||||
|
||||
// On POSIX only: use FIFO for IPC channels so that "unrelated" process
|
||||
// can connect to a channel, provided it knows its name. For debugging purposes.
|
||||
const wchar_t kIPCUseFIFO[] = L"ipc-use-fifo";
|
||||
|
||||
// If this flag is set open out of process developer tools window instead of
|
||||
// Console Debugger when user clicks "Debug JavaScript".
|
||||
const wchar_t kEnableOutOfProcessDevTools[] = L"enable-oop-devtools";
|
||||
|
||||
// Enable HTML5 Worker support
|
||||
const wchar_t kEnableWebWorkers[] = L"enable-web-workers";
|
||||
|
||||
// Causes the worker process allocation to use as many processes as cores.
|
||||
const wchar_t kWebWorkerProcessPerCore[] = L"web-worker-process-per-core";
|
||||
|
||||
// Causes workers to run together in one process, depending on their domains.
|
||||
// Note this is duplicated in webworkerclient_impl.cc
|
||||
const wchar_t kWebWorkerShareProcesses[] = L"web-worker-share-processes";
|
||||
|
||||
// Enables experimental views under gtk.
|
||||
const wchar_t kViewsGtk[] = L"views-gtk";
|
||||
|
||||
// Enables the bookmark menu.
|
||||
const wchar_t kBookmarkMenu[] = L"bookmark-menu";
|
||||
|
||||
// Enables StatsTable, logging statistics to a global named shared memory table.
|
||||
const wchar_t kEnableStatsTable[] = L"enable-stats-table";
|
||||
|
||||
// Enables the Omnibox2 popup and functionality.
|
||||
const wchar_t kEnableOmnibox2[] = L"enable-omnibox2";
|
||||
|
||||
// Replaces the audio IPC layer for <audio> and <video> with a mock audio
|
||||
// device, useful when using remote desktop or machines without sound cards.
|
||||
// This is temporary until we fix the underlying problem.
|
||||
//
|
||||
// TODO(scherkus): remove --disable-audio when we have a proper fallback
|
||||
// mechanism.
|
||||
const wchar_t kDisableAudio[] = L"disable-audio";
|
||||
|
||||
// Replaces the buffered data source for <audio> and <video> with a simplified
|
||||
// resource loader that downloads the entire resource into memory.
|
||||
//
|
||||
// TODO(scherkus): remove --simple-data-source when our media resource loading
|
||||
// is cleaned up and playback testing completed.
|
||||
const wchar_t kSimpleDataSource[] = L"simple-data-source";
|
||||
|
||||
} // namespace switches
|
||||
|
@ -7,165 +7,13 @@
|
||||
#ifndef CHROME_COMMON_CHROME_SWITCHES_H__
|
||||
#define CHROME_COMMON_CHROME_SWITCHES_H__
|
||||
|
||||
#include "base/base_switches.h"
|
||||
#if defined(COMPILER_MSVC)
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
namespace switches {
|
||||
|
||||
extern const wchar_t kDisableHangMonitor[];
|
||||
extern const wchar_t kDisableMetrics[];
|
||||
extern const wchar_t kMetricsRecordingOnly[];
|
||||
extern const wchar_t kBrowserAssertTest[];
|
||||
extern const wchar_t kRendererAssertTest[];
|
||||
extern const wchar_t kBrowserCrashTest[];
|
||||
extern const wchar_t kRendererCrashTest[];
|
||||
extern const wchar_t kRendererStartupDialog[];
|
||||
extern const wchar_t kPluginStartupDialog[];
|
||||
extern const wchar_t kPluginLauncher[];
|
||||
|
||||
extern const wchar_t kProcessChannelID[];
|
||||
extern const wchar_t kTestingChannelID[];
|
||||
extern const wchar_t kHomePage[];
|
||||
extern const wchar_t kRendererProcess[];
|
||||
extern const wchar_t kBrowserSubprocessPath[];
|
||||
extern const wchar_t kPluginProcess[];
|
||||
extern const wchar_t kWorkerProcess[];
|
||||
extern const wchar_t kSingleProcess[];
|
||||
extern const wchar_t kProcessPerTab[];
|
||||
extern const wchar_t kProcessPerSite[];
|
||||
extern const wchar_t kInProcessPlugins[];
|
||||
extern const wchar_t kNoSandbox[];
|
||||
extern const wchar_t kSafePlugins[];
|
||||
extern const wchar_t kTrustedPlugins[];
|
||||
extern const wchar_t kTestSandbox[];
|
||||
extern const wchar_t kUserDataDir[];
|
||||
extern const wchar_t kPluginDataDir[];
|
||||
extern const wchar_t kDiskCacheDir[];
|
||||
extern const wchar_t kEnableUserDataDirProfiles[];
|
||||
extern const wchar_t kParentProfile[];
|
||||
extern const wchar_t kApp[];
|
||||
extern const wchar_t kDomAutomationController[];
|
||||
extern const wchar_t kPluginPath[];
|
||||
extern const wchar_t kUserAgent[];
|
||||
extern const wchar_t kJavaScriptFlags[];
|
||||
extern const wchar_t kCountry[];
|
||||
extern const wchar_t kLang[];
|
||||
extern const wchar_t kDebugChildren[];
|
||||
extern const wchar_t kWaitForDebuggerChildren[];
|
||||
|
||||
extern const wchar_t kLogFilterPrefix[];
|
||||
extern const wchar_t kEnableLogging[];
|
||||
extern const wchar_t kLoggingLevel[];
|
||||
extern const wchar_t kLogPluginMessages[];
|
||||
|
||||
extern const wchar_t kDumpHistogramsOnExit[];
|
||||
extern const wchar_t kDisableLogging[];
|
||||
extern const wchar_t kRemoteShellPort[];
|
||||
extern const wchar_t kUninstall[];
|
||||
extern const wchar_t kOmniBoxPopupCount[];
|
||||
|
||||
extern const wchar_t kAutomationClientChannelID[];
|
||||
|
||||
extern const wchar_t kRestoreLastSession[];
|
||||
|
||||
extern const wchar_t kRecordMode[];
|
||||
extern const wchar_t kPlaybackMode[];
|
||||
extern const wchar_t kNoEvents[];
|
||||
extern const wchar_t kNoJsRandomness[];
|
||||
|
||||
extern const wchar_t kHideIcons[];
|
||||
extern const wchar_t kShowIcons[];
|
||||
extern const wchar_t kMakeDefaultBrowser[];
|
||||
|
||||
extern const wchar_t kProxyServer[];
|
||||
extern const wchar_t kWinHttpProxyResolver[];
|
||||
extern const wchar_t kDebugPrint[];
|
||||
|
||||
extern const wchar_t kDnsLogDetails[];
|
||||
extern const wchar_t kDnsPrefetchDisable[];
|
||||
|
||||
extern const wchar_t kAllowAllActiveX[];
|
||||
|
||||
extern const wchar_t kDisableDevTools[];
|
||||
extern const wchar_t kAlwaysEnableDevTools[];
|
||||
|
||||
extern const wchar_t kTabCountToLoadOnSessionRestore[];
|
||||
|
||||
extern const wchar_t kMemoryProfiling[];
|
||||
extern const wchar_t kMemoryModel[];
|
||||
|
||||
extern const wchar_t kEnableFileCookies[];
|
||||
|
||||
extern const wchar_t kStartMaximized[];
|
||||
|
||||
extern const wchar_t kEnableWatchdog[];
|
||||
|
||||
extern const wchar_t kFirstRun[];
|
||||
|
||||
extern const wchar_t kNoFirstRun[];
|
||||
|
||||
extern const wchar_t kMessageLoopHistogrammer[];
|
||||
|
||||
extern const wchar_t kImport[];
|
||||
|
||||
extern const wchar_t kSilentDumpOnDCHECK[];
|
||||
|
||||
extern const wchar_t kDisablePromptOnRepost[];
|
||||
|
||||
extern const wchar_t kDisablePopupBlocking[];
|
||||
extern const wchar_t kDisableJavaScript[];
|
||||
extern const wchar_t kDisableJava[];
|
||||
extern const wchar_t kDisablePlugins[];
|
||||
extern const wchar_t kDisableImages[];
|
||||
extern const wchar_t kDisableWebSecurity[];
|
||||
|
||||
extern const wchar_t kUseLowFragHeapCrt[];
|
||||
|
||||
#ifndef NDEBUG
|
||||
extern const wchar_t kGearsPluginPathOverride[];
|
||||
#endif
|
||||
|
||||
extern const wchar_t kEnableFastback[];
|
||||
|
||||
extern const wchar_t kJavaScriptDebuggerPath[];
|
||||
|
||||
extern const wchar_t kDisableP13n[];
|
||||
|
||||
extern const wchar_t kSdchFilter[];
|
||||
|
||||
extern const wchar_t kEnableUserScripts[];
|
||||
extern const wchar_t kEnableExtensions[];
|
||||
extern const wchar_t kInstallExtension[];
|
||||
extern const wchar_t kLoadExtension[];
|
||||
extern const wchar_t kLoadPlugin[];
|
||||
extern const wchar_t kUserScriptsDir[];
|
||||
|
||||
extern const wchar_t kIncognito[];
|
||||
|
||||
extern const wchar_t kEnableRendererAccessibility[];
|
||||
|
||||
extern const wchar_t kTestName[];
|
||||
|
||||
extern const wchar_t kRendererCmdPrefix[];
|
||||
|
||||
extern const wchar_t kNewFtp[];
|
||||
|
||||
extern const wchar_t kIPCUseFIFO[];
|
||||
|
||||
extern const wchar_t kEnableOutOfProcessDevTools[];
|
||||
|
||||
extern const wchar_t kEnableWebWorkers[];
|
||||
extern const wchar_t kWebWorkerProcessPerCore[];
|
||||
extern const wchar_t kWebWorkerShareProcesses[];
|
||||
|
||||
extern const wchar_t kViewsGtk[];
|
||||
|
||||
extern const wchar_t kBookmarkMenu[];
|
||||
extern const wchar_t kEnableStatsTable[];
|
||||
|
||||
extern const wchar_t kEnableOmnibox2[];
|
||||
|
||||
extern const wchar_t kDisableAudio[];
|
||||
extern const wchar_t kSimpleDataSource[];
|
||||
|
||||
} // namespace switches
|
||||
|
||||
|
@ -1,33 +0,0 @@
|
||||
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "chrome/common/env_vars.h"
|
||||
|
||||
namespace env_vars {
|
||||
|
||||
// We call running in unattended mode (for automated testing) "headless".
|
||||
// This mode can be enabled using this variable or by the kNoErrorDialogs
|
||||
// switch.
|
||||
const wchar_t kHeadless[] = L"CHROME_HEADLESS";
|
||||
|
||||
// The name of the log file.
|
||||
const wchar_t kLogFileName[] = L"CHROME_LOG_FILE";
|
||||
|
||||
// CHROME_CRASHED exists if a previous instance of chrome has crashed. This
|
||||
// triggers the 'restart chrome' dialog. CHROME_RESTART contains the strings
|
||||
// that are needed to show the dialog.
|
||||
const wchar_t kShowRestart[] = L"CHROME_CRASHED";
|
||||
const wchar_t kRestartInfo[] = L"CHROME_RESTART";
|
||||
|
||||
// The strings RIGHT_TO_LEFT and LEFT_TO_RIGHT indicate the locale direction.
|
||||
// For example, for Hebrew and Arabic locales, we use RIGHT_TO_LEFT so that the
|
||||
// dialog is displayed using the right orientation.
|
||||
const wchar_t kRtlLocale[] = L"RIGHT_TO_LEFT";
|
||||
const wchar_t kLtrLocale[] = L"LEFT_TO_RIGHT";
|
||||
|
||||
// If the out-of-process breakpad could not be installed, we set this variable
|
||||
// according to the process.
|
||||
const wchar_t kNoOOBreakpad[] = L"NO_OO_BREAKPAD";
|
||||
|
||||
} // namespace env_vars
|
@ -1,26 +0,0 @@
|
||||
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Defines all the environment variables used by Chrome.
|
||||
|
||||
#ifndef CHROME_COMMON_ENV_VARS_H__
|
||||
#define CHROME_COMMON_ENV_VARS_H__
|
||||
|
||||
#if defined(COMPILER_MSVC)
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
namespace env_vars {
|
||||
|
||||
extern const wchar_t kHeadless[];
|
||||
extern const wchar_t kLogFileName[];
|
||||
extern const wchar_t kShowRestart[];
|
||||
extern const wchar_t kRestartInfo[];
|
||||
extern const wchar_t kRtlLocale[];
|
||||
extern const wchar_t kLtrLocale[];
|
||||
extern const wchar_t kNoOOBreakpad[];
|
||||
|
||||
} // namespace env_vars
|
||||
|
||||
#endif // CHROME_COMMON_ENV_VARS_H__
|
@ -141,110 +141,6 @@ int ChannelNameToClientFD(const std::string& channel_id) {
|
||||
//------------------------------------------------------------------------------
|
||||
const size_t kMaxPipeNameLength = sizeof(((sockaddr_un*)0)->sun_path);
|
||||
|
||||
// Creates a Fifo with the specified name ready to listen on.
|
||||
bool CreateServerFifo(const std::string& pipe_name, int* server_listen_fd) {
|
||||
DCHECK(server_listen_fd);
|
||||
DCHECK_GT(pipe_name.length(), 0u);
|
||||
DCHECK_LT(pipe_name.length(), kMaxPipeNameLength);
|
||||
|
||||
if (pipe_name.length() == 0 || pipe_name.length() >= kMaxPipeNameLength) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create socket.
|
||||
int fd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if (fd < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Make socket non-blocking
|
||||
if (fcntl(fd, F_SETFL, O_NONBLOCK) == -1) {
|
||||
HANDLE_EINTR(close(fd));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Delete any old FS instances.
|
||||
unlink(pipe_name.c_str());
|
||||
|
||||
// Create unix_addr structure
|
||||
struct sockaddr_un unix_addr;
|
||||
memset(&unix_addr, 0, sizeof(unix_addr));
|
||||
unix_addr.sun_family = AF_UNIX;
|
||||
snprintf(unix_addr.sun_path, kMaxPipeNameLength, "%s", pipe_name.c_str());
|
||||
size_t unix_addr_len = offsetof(struct sockaddr_un, sun_path) +
|
||||
strlen(unix_addr.sun_path) + 1;
|
||||
|
||||
// Bind the socket.
|
||||
if (bind(fd, reinterpret_cast<const sockaddr*>(&unix_addr),
|
||||
unix_addr_len) != 0) {
|
||||
HANDLE_EINTR(close(fd));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Start listening on the socket.
|
||||
const int listen_queue_length = 1;
|
||||
if (listen(fd, listen_queue_length) != 0) {
|
||||
HANDLE_EINTR(close(fd));
|
||||
return false;
|
||||
}
|
||||
|
||||
*server_listen_fd = fd;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Accept a connection on a fifo.
|
||||
bool ServerAcceptFifoConnection(int server_listen_fd, int* server_socket) {
|
||||
DCHECK(server_socket);
|
||||
|
||||
int accept_fd = HANDLE_EINTR(accept(server_listen_fd, NULL, 0));
|
||||
if (accept_fd < 0)
|
||||
return false;
|
||||
if (fcntl(accept_fd, F_SETFL, O_NONBLOCK) == -1) {
|
||||
HANDLE_EINTR(close(accept_fd));
|
||||
return false;
|
||||
}
|
||||
|
||||
*server_socket = accept_fd;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ClientConnectToFifo(const std::string &pipe_name, int* client_socket) {
|
||||
DCHECK(client_socket);
|
||||
DCHECK_LT(pipe_name.length(), kMaxPipeNameLength);
|
||||
|
||||
// Create socket.
|
||||
int fd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if (fd < 0) {
|
||||
CHROMIUM_LOG(ERROR) << "fd is invalid";
|
||||
return false;
|
||||
}
|
||||
|
||||
// Make socket non-blocking
|
||||
if (fcntl(fd, F_SETFL, O_NONBLOCK) == -1) {
|
||||
CHROMIUM_LOG(ERROR) << "fcntl failed";
|
||||
HANDLE_EINTR(close(fd));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create server side of socket.
|
||||
struct sockaddr_un server_unix_addr;
|
||||
memset(&server_unix_addr, 0, sizeof(server_unix_addr));
|
||||
server_unix_addr.sun_family = AF_UNIX;
|
||||
snprintf(server_unix_addr.sun_path, kMaxPipeNameLength, "%s",
|
||||
pipe_name.c_str());
|
||||
size_t server_unix_addr_len = offsetof(struct sockaddr_un, sun_path) +
|
||||
strlen(server_unix_addr.sun_path) + 1;
|
||||
|
||||
if (HANDLE_EINTR(connect(fd, reinterpret_cast<sockaddr*>(&server_unix_addr),
|
||||
server_unix_addr_len)) != 0) {
|
||||
HANDLE_EINTR(close(fd));
|
||||
return false;
|
||||
}
|
||||
|
||||
*client_socket = fd;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SetCloseOnExec(int fd) {
|
||||
int flags = fcntl(fd, F_GETFD);
|
||||
if (flags == -1)
|
||||
@ -264,7 +160,6 @@ Channel::ChannelImpl::ChannelImpl(const std::wstring& channel_id, Mode mode,
|
||||
Listener* listener)
|
||||
: factory_(this) {
|
||||
Init(mode, listener);
|
||||
uses_fifo_ = CommandLine::ForCurrentProcess()->HasSwitch(switches::kIPCUseFIFO);
|
||||
|
||||
if (!CreatePipe(channel_id, mode)) {
|
||||
// The pipe may have been closed already.
|
||||
@ -289,7 +184,6 @@ void Channel::ChannelImpl::Init(Mode mode, Listener* listener) {
|
||||
mode_ = mode;
|
||||
is_blocked_on_write_ = false;
|
||||
message_send_bytes_written_ = 0;
|
||||
uses_fifo_ = false;
|
||||
server_listen_pipe_ = -1;
|
||||
pipe_ = -1;
|
||||
client_pipe_ = -1;
|
||||
@ -307,56 +201,38 @@ bool Channel::ChannelImpl::CreatePipe(const std::wstring& channel_id,
|
||||
Mode mode) {
|
||||
DCHECK(server_listen_pipe_ == -1 && pipe_ == -1);
|
||||
|
||||
if (uses_fifo_) {
|
||||
// This only happens in unit tests; see the comment above PipeMap.
|
||||
// TODO(playmobil): We shouldn't need to create fifos on disk.
|
||||
// TODO(playmobil): If we do, they should be in the user data directory.
|
||||
// TODO(playmobil): Cleanup any stale fifos.
|
||||
pipe_name_ = "/var/tmp/chrome_" + WideToASCII(channel_id);
|
||||
if (mode == MODE_SERVER) {
|
||||
if (!CreateServerFifo(pipe_name_, &server_listen_pipe_)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!ClientConnectToFifo(pipe_name_, &pipe_)) {
|
||||
return false;
|
||||
}
|
||||
waiting_connect_ = false;
|
||||
// socketpair()
|
||||
pipe_name_ = WideToASCII(channel_id);
|
||||
if (mode == MODE_SERVER) {
|
||||
int pipe_fds[2];
|
||||
if (socketpair(AF_UNIX, SOCK_STREAM, 0, pipe_fds) != 0) {
|
||||
return false;
|
||||
}
|
||||
// Set both ends to be non-blocking.
|
||||
if (fcntl(pipe_fds[0], F_SETFL, O_NONBLOCK) == -1 ||
|
||||
fcntl(pipe_fds[1], F_SETFL, O_NONBLOCK) == -1) {
|
||||
HANDLE_EINTR(close(pipe_fds[0]));
|
||||
HANDLE_EINTR(close(pipe_fds[1]));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!SetCloseOnExec(pipe_fds[0]) ||
|
||||
!SetCloseOnExec(pipe_fds[1])) {
|
||||
HANDLE_EINTR(close(pipe_fds[0]));
|
||||
HANDLE_EINTR(close(pipe_fds[1]));
|
||||
return false;
|
||||
}
|
||||
|
||||
pipe_ = pipe_fds[0];
|
||||
client_pipe_ = pipe_fds[1];
|
||||
|
||||
if (pipe_name_.length()) {
|
||||
Singleton<PipeMap>()->Insert(pipe_name_, client_pipe_);
|
||||
}
|
||||
} else {
|
||||
// socketpair()
|
||||
pipe_name_ = WideToASCII(channel_id);
|
||||
if (mode == MODE_SERVER) {
|
||||
int pipe_fds[2];
|
||||
if (socketpair(AF_UNIX, SOCK_STREAM, 0, pipe_fds) != 0) {
|
||||
return false;
|
||||
}
|
||||
// Set both ends to be non-blocking.
|
||||
if (fcntl(pipe_fds[0], F_SETFL, O_NONBLOCK) == -1 ||
|
||||
fcntl(pipe_fds[1], F_SETFL, O_NONBLOCK) == -1) {
|
||||
HANDLE_EINTR(close(pipe_fds[0]));
|
||||
HANDLE_EINTR(close(pipe_fds[1]));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!SetCloseOnExec(pipe_fds[0]) ||
|
||||
!SetCloseOnExec(pipe_fds[1])) {
|
||||
HANDLE_EINTR(close(pipe_fds[0]));
|
||||
HANDLE_EINTR(close(pipe_fds[1]));
|
||||
return false;
|
||||
}
|
||||
|
||||
pipe_ = pipe_fds[0];
|
||||
client_pipe_ = pipe_fds[1];
|
||||
|
||||
if (pipe_name_.length()) {
|
||||
Singleton<PipeMap>()->Insert(pipe_name_, client_pipe_);
|
||||
}
|
||||
} else {
|
||||
pipe_ = ChannelNameToClientFD(pipe_name_);
|
||||
DCHECK(pipe_ > 0);
|
||||
waiting_connect_ = false;
|
||||
}
|
||||
pipe_ = ChannelNameToClientFD(pipe_name_);
|
||||
DCHECK(pipe_ > 0);
|
||||
waiting_connect_ = false;
|
||||
}
|
||||
|
||||
// Create the Hello message to be sent when Connect is called
|
||||
@ -402,29 +278,18 @@ void Channel::ChannelImpl::ClearAndShrinkInputOverflowBuf()
|
||||
}
|
||||
|
||||
bool Channel::ChannelImpl::Connect() {
|
||||
if (mode_ == MODE_SERVER && uses_fifo_) {
|
||||
if (server_listen_pipe_ == -1) {
|
||||
return false;
|
||||
}
|
||||
MessageLoopForIO::current()->WatchFileDescriptor(
|
||||
server_listen_pipe_,
|
||||
true,
|
||||
MessageLoopForIO::WATCH_READ,
|
||||
&server_listen_connection_watcher_,
|
||||
this);
|
||||
} else {
|
||||
if (pipe_ == -1) {
|
||||
return false;
|
||||
}
|
||||
MessageLoopForIO::current()->WatchFileDescriptor(
|
||||
pipe_,
|
||||
true,
|
||||
MessageLoopForIO::WATCH_READ,
|
||||
&read_watcher_,
|
||||
this);
|
||||
waiting_connect_ = false;
|
||||
if (pipe_ == -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageLoopForIO::current()->WatchFileDescriptor(
|
||||
pipe_,
|
||||
true,
|
||||
MessageLoopForIO::WATCH_READ,
|
||||
&read_watcher_,
|
||||
this);
|
||||
waiting_connect_ = false;
|
||||
|
||||
if (!waiting_connect_)
|
||||
return ProcessOutgoingMessages();
|
||||
return true;
|
||||
@ -847,32 +712,6 @@ void Channel::ChannelImpl::CloseClientFileDescriptor() {
|
||||
|
||||
// Called by libevent when we can read from th pipe without blocking.
|
||||
void Channel::ChannelImpl::OnFileCanReadWithoutBlocking(int fd) {
|
||||
bool send_server_hello_msg = false;
|
||||
if (waiting_connect_ && mode_ == MODE_SERVER) {
|
||||
// In the case of a socketpair() the server starts listening on its end
|
||||
// of the pipe in Connect().
|
||||
DCHECK(uses_fifo_);
|
||||
|
||||
if (!ServerAcceptFifoConnection(server_listen_pipe_, &pipe_)) {
|
||||
Close();
|
||||
}
|
||||
|
||||
// No need to watch the listening socket any longer since only one client
|
||||
// can connect. So unregister with libevent.
|
||||
server_listen_connection_watcher_.StopWatchingFileDescriptor();
|
||||
|
||||
// Start watching our end of the socket.
|
||||
MessageLoopForIO::current()->WatchFileDescriptor(
|
||||
pipe_,
|
||||
true,
|
||||
MessageLoopForIO::WATCH_READ,
|
||||
&read_watcher_,
|
||||
this);
|
||||
|
||||
waiting_connect_ = false;
|
||||
send_server_hello_msg = true;
|
||||
}
|
||||
|
||||
if (!waiting_connect_ && fd == pipe_) {
|
||||
if (!ProcessIncomingMessages()) {
|
||||
Close();
|
||||
@ -881,16 +720,6 @@ void Channel::ChannelImpl::OnFileCanReadWithoutBlocking(int fd) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// If we're a server and handshaking, then we want to make sure that we
|
||||
// only send our handshake message after we've processed the client's.
|
||||
// This gives us a chance to kill the client if the incoming handshake
|
||||
// is invalid.
|
||||
if (send_server_hello_msg) {
|
||||
// This should be our first write so there's no chance we can block here...
|
||||
DCHECK(is_blocked_on_write_ == false);
|
||||
ProcessOutgoingMessages();
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
@ -961,11 +790,6 @@ void Channel::ChannelImpl::Close() {
|
||||
client_pipe_ = -1;
|
||||
}
|
||||
|
||||
if (uses_fifo_) {
|
||||
// Unlink the FIFO
|
||||
unlink(pipe_name_.c_str());
|
||||
}
|
||||
|
||||
while (!output_queue_.empty()) {
|
||||
Message* m = output_queue_.front();
|
||||
OutputQueuePop();
|
||||
|
@ -87,10 +87,6 @@ class Channel::ChannelImpl : public MessageLoopForIO::Watcher {
|
||||
// to keep track of where we are.
|
||||
size_t message_send_bytes_written_;
|
||||
|
||||
// If the kTestingChannelID flag is specified, we use a FIFO instead of
|
||||
// a socketpair().
|
||||
bool uses_fifo_;
|
||||
|
||||
int server_listen_pipe_;
|
||||
int pipe_;
|
||||
int client_pipe_; // The client end of our socketpair().
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include "base/message_loop.h"
|
||||
#include "base/object_watcher.h"
|
||||
#include "base/sys_info.h"
|
||||
#include "chrome/common/env_vars.h"
|
||||
#include "chrome/common/result_codes.h"
|
||||
|
||||
// Maximum amount of time (in milliseconds) to wait for the process to exit.
|
||||
@ -48,15 +47,6 @@ class TimerExpiredTask : public Task, public base::ObjectWatcher::Delegate {
|
||||
|
||||
private:
|
||||
void KillProcess() {
|
||||
if (base::SysInfo::HasEnvVar(env_vars::kHeadless)) {
|
||||
// If running the distributed tests, give the renderer a little time
|
||||
// to figure out that the channel is shutdown and unwind.
|
||||
if (WaitForSingleObject(process_, kWaitInterval) == WAIT_OBJECT_0) {
|
||||
OnObjectSignaled(process_);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// OK, time to get frisky. We don't actually care when the process
|
||||
// terminates. We just care that it eventually terminates, and that's what
|
||||
// TerminateProcess should do for us. Don't check for the result code since
|
||||
|
Loading…
Reference in New Issue
Block a user