NO CODE CHANGE (except one global std::wstring changed to const wchar_t* const per style compliance).
Preliminary work to enforce new PRESUBMIT.py rules: - <=80 cols - no trailing whitespaces - svn:eol-style=LF git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10791 0039d316-1c4b-4281-b951-d872f2087c98
Esse commit está contido em:
+1
-1
@@ -21,7 +21,7 @@ namespace base {
|
||||
// AtExitManager object on the stack:
|
||||
// int main(...) {
|
||||
// base::AtExitManager exit_manager;
|
||||
//
|
||||
//
|
||||
// }
|
||||
// When the exit_manager object goes out of scope, all the registered
|
||||
// callbacks and singleton destructors will be called.
|
||||
|
||||
@@ -52,7 +52,7 @@ TEST(AtExitTest, Basic) {
|
||||
base::AtExitManager::RegisterCallback(&IncrementTestCounter1, NULL);
|
||||
base::AtExitManager::RegisterCallback(&IncrementTestCounter2, NULL);
|
||||
base::AtExitManager::RegisterCallback(&IncrementTestCounter1, NULL);
|
||||
|
||||
|
||||
EXPECT_EQ(0, g_test_counter_1);
|
||||
EXPECT_EQ(0, g_test_counter_2);
|
||||
base::AtExitManager::ProcessCallbacksNow();
|
||||
@@ -67,7 +67,7 @@ TEST(AtExitTest, LIFOOrder) {
|
||||
base::AtExitManager::RegisterCallback(&IncrementTestCounter1, NULL);
|
||||
base::AtExitManager::RegisterCallback(&ExpectCounter1IsZero, NULL);
|
||||
base::AtExitManager::RegisterCallback(&IncrementTestCounter2, NULL);
|
||||
|
||||
|
||||
EXPECT_EQ(0, g_test_counter_1);
|
||||
EXPECT_EQ(0, g_test_counter_2);
|
||||
base::AtExitManager::ProcessCallbacksNow();
|
||||
|
||||
@@ -70,7 +70,7 @@ static void AtomicOps_Internalx86CPUFeaturesInit() {
|
||||
|
||||
// Opteron Rev E has a bug in which on very rare occasions a locked
|
||||
// instruction doesn't act as a read-acquire barrier if followed by a
|
||||
// non-locked read-modify-write instruction. Rev F has this bug in
|
||||
// non-locked read-modify-write instruction. Rev F has this bug in
|
||||
// pre-release versions, but not in versions released to customers,
|
||||
// so we test only for Rev E, which is family 15, model 32..63 inclusive.
|
||||
if (strcmp(vendor, "AuthenticAMD") == 0 && // AMD
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
#ifndef BASE_BASE_PATHS_MAC_H_
|
||||
#define BASE_BASE_PATHS_MAC_H_
|
||||
|
||||
// This file declares Mac-specific path keys for the base module.
|
||||
// These can be used with the PathService to access various special
|
||||
// This file declares Mac-specific path keys for the base module.
|
||||
// These can be used with the PathService to access various special
|
||||
// directories and files.
|
||||
|
||||
namespace base {
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
#ifndef BASE_BASE_PATHS_WIN_H__
|
||||
#define BASE_BASE_PATHS_WIN_H__
|
||||
|
||||
// This file declares windows-specific path keys for the base module.
|
||||
// These can be used with the PathService to access various special
|
||||
// This file declares windows-specific path keys for the base module.
|
||||
// These can be used with the PathService to access various special
|
||||
// directories and files.
|
||||
|
||||
namespace base {
|
||||
|
||||
+1
-1
@@ -62,7 +62,7 @@ class Clipboard {
|
||||
// CBF_BOOKMARK html char array
|
||||
// url char array
|
||||
// CBF_LINK html char array
|
||||
// url char array
|
||||
// url char array
|
||||
// CBF_FILES files char array representing multiple files.
|
||||
// Filenames are separated by null characters and
|
||||
// the final filename is double null terminated.
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
#if defined(OS_WIN)
|
||||
class ClipboardTest : public PlatformTest {
|
||||
protected:
|
||||
protected:
|
||||
virtual void SetUp() {
|
||||
message_loop_.reset(new MessageLoopForUI());
|
||||
}
|
||||
|
||||
@@ -232,7 +232,10 @@ bool ClipboardUtil::GetUrl(IDataObject* data_object,
|
||||
PathIsUNCA(data.get()))) {
|
||||
char file_url[INTERNET_MAX_URL_LENGTH];
|
||||
DWORD file_url_len = sizeof(file_url) / sizeof(file_url[0]);
|
||||
if (SUCCEEDED(::UrlCreateFromPathA(data.get(), file_url, &file_url_len, 0))) {
|
||||
if (SUCCEEDED(::UrlCreateFromPathA(data.get(),
|
||||
file_url,
|
||||
&file_url_len,
|
||||
0))) {
|
||||
*url = UTF8ToWide(file_url);
|
||||
title->assign(*url);
|
||||
success = true;
|
||||
@@ -396,7 +399,7 @@ bool ClipboardUtil::GetFileContents(IDataObject* data_object,
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
// Helper method for converting from text/html to MS CF_HTML.
|
||||
|
||||
@@ -283,7 +283,8 @@ void Clipboard::WriteBitmapFromSharedMemory(const char* bitmap_data,
|
||||
BITMAPINFO bm_info = {0};
|
||||
bm_info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||
bm_info.bmiHeader.biWidth = size->width();
|
||||
bm_info.bmiHeader.biHeight = -size->height(); // Sets the vertical orientation
|
||||
// Sets the vertical orientation.
|
||||
bm_info.bmiHeader.biHeight = -size->height();
|
||||
bm_info.bmiHeader.biPlanes = 1;
|
||||
bm_info.bmiHeader.biBitCount = 32;
|
||||
bm_info.bmiHeader.biCompression = BI_RGB;
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ void CPU::Initialize() {
|
||||
// __cpuid with an InfoType argument of 0 returns the number of
|
||||
// valid Ids in CPUInfo[0] and the CPU identification string in
|
||||
// the other three array elements. The CPU identification string is
|
||||
// not in linear order. The code below arranges the information
|
||||
// not in linear order. The code below arranges the information
|
||||
// in a human readable form.
|
||||
//
|
||||
// More info can be found here:
|
||||
|
||||
+1
-1
@@ -291,7 +291,7 @@ std::wstring FilePath::ToWStringHack() const {
|
||||
FilePath FilePath::StripTrailingSeparators() const {
|
||||
FilePath new_path(path_);
|
||||
new_path.StripTrailingSeparatorsInternal();
|
||||
|
||||
|
||||
return new_path;
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ class FileVersionInfo {
|
||||
VS_FIXEDFILEINFO* fixed_file_info_;
|
||||
#elif defined(OS_MACOSX)
|
||||
explicit FileVersionInfo(NSBundle *bundle);
|
||||
|
||||
|
||||
NSBundle *bundle_;
|
||||
#elif defined(OS_LINUX)
|
||||
FileVersionInfo();
|
||||
|
||||
@@ -44,7 +44,9 @@ namespace {
|
||||
const static int initial_output_buffer_size = 8192;
|
||||
|
||||
struct JpegEncoderState {
|
||||
JpegEncoderState(std::vector<unsigned char>* o) : out(o), image_buffer_used(0) {
|
||||
JpegEncoderState(std::vector<unsigned char>* o)
|
||||
: out(o),
|
||||
image_buffer_used(0) {
|
||||
}
|
||||
|
||||
// Output buffer, of which 'image_buffer_used' bytes are actually used (this
|
||||
|
||||
@@ -103,7 +103,7 @@ HRESULT NativeTheme::PaintButton(HDC hdc,
|
||||
if (handle && get_theme_content_rect_) {
|
||||
get_theme_content_rect_(handle, hdc, part_id, state_id, rect, rect);
|
||||
} else {
|
||||
InflateRect(rect, -GetSystemMetrics(SM_CXEDGE),
|
||||
InflateRect(rect, -GetSystemMetrics(SM_CXEDGE),
|
||||
-GetSystemMetrics(SM_CYEDGE));
|
||||
}
|
||||
DrawFocusRect(hdc, rect);
|
||||
@@ -193,13 +193,14 @@ HRESULT NativeTheme::PaintScrollbarArrow(HDC hdc,
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT NativeTheme::PaintScrollbarTrack(HDC hdc,
|
||||
int part_id,
|
||||
int state_id,
|
||||
int classic_state,
|
||||
RECT* target_rect,
|
||||
RECT* align_rect,
|
||||
skia::PlatformCanvasWin* canvas) const {
|
||||
HRESULT NativeTheme::PaintScrollbarTrack(
|
||||
HDC hdc,
|
||||
int part_id,
|
||||
int state_id,
|
||||
int classic_state,
|
||||
RECT* target_rect,
|
||||
RECT* align_rect,
|
||||
skia::PlatformCanvasWin* canvas) const {
|
||||
HANDLE handle = GetThemeHandle(SCROLLBAR);
|
||||
if (handle && draw_theme_)
|
||||
return draw_theme_(handle, hdc, part_id, state_id, target_rect, NULL);
|
||||
|
||||
@@ -165,8 +165,10 @@ TEST(PNGCodec, StripAddAlpha) {
|
||||
|
||||
// Encode RGBA data as RGB.
|
||||
std::vector<unsigned char> encoded;
|
||||
EXPECT_TRUE(PNGEncoder::Encode(&original_rgba[0], PNGEncoder::FORMAT_RGBA, w, h,
|
||||
w * 4, true, &encoded));
|
||||
EXPECT_TRUE(PNGEncoder::Encode(&original_rgba[0],
|
||||
PNGEncoder::FORMAT_RGBA,
|
||||
w, h,
|
||||
w * 4, true, &encoded));
|
||||
|
||||
// Decode the RGB to RGBA.
|
||||
std::vector<unsigned char> decoded;
|
||||
@@ -182,8 +184,10 @@ TEST(PNGCodec, StripAddAlpha) {
|
||||
ASSERT_TRUE(original_rgba == decoded);
|
||||
|
||||
// Encode RGBA to RGBA.
|
||||
EXPECT_TRUE(PNGEncoder::Encode(&original_rgba[0], PNGEncoder::FORMAT_RGBA, w, h,
|
||||
w * 4, false, &encoded));
|
||||
EXPECT_TRUE(PNGEncoder::Encode(&original_rgba[0],
|
||||
PNGEncoder::FORMAT_RGBA,
|
||||
w, h,
|
||||
w * 4, false, &encoded));
|
||||
|
||||
// Decode the RGBA to RGB.
|
||||
EXPECT_TRUE(PNGDecoder::Decode(&encoded[0], encoded.size(),
|
||||
|
||||
@@ -293,7 +293,10 @@ bool PNGDecoder::Decode(const unsigned char* input, size_t input_size,
|
||||
|
||||
png_set_progressive_read_fn(png_ptr, &state, &DecodeInfoCallback,
|
||||
&DecodeRowCallback, &DecodeEndCallback);
|
||||
png_process_data(png_ptr, info_ptr, const_cast<unsigned char*>(input), input_size);
|
||||
png_process_data(png_ptr,
|
||||
info_ptr,
|
||||
const_cast<unsigned char*>(input),
|
||||
input_size);
|
||||
|
||||
if (!state.done) {
|
||||
// Fed it all the data but the library didn't think we got all the data, so
|
||||
|
||||
@@ -177,7 +177,8 @@ bool PNGEncoder::Encode(const unsigned char* input, ColorFormat format,
|
||||
if (!converter) {
|
||||
// No conversion needed, give the data directly to libpng.
|
||||
for (int y = 0; y < h; y ++)
|
||||
png_write_row(png_ptr, const_cast<unsigned char*>(&input[y * row_byte_width]));
|
||||
png_write_row(png_ptr,
|
||||
const_cast<unsigned char*>(&input[y * row_byte_width]));
|
||||
} else {
|
||||
// Needs conversion using a separate buffer.
|
||||
unsigned char* row = new unsigned char[w * output_color_components];
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
// Deal with the differences between Microsoft and GNU implemenations
|
||||
// of hash_map. Allows all platforms to use |base::hash_map| and
|
||||
// |base::hash_set|.
|
||||
// eg:
|
||||
// eg:
|
||||
// base::hash_map<int> my_map;
|
||||
// base::hash_set<int> my_set;
|
||||
//
|
||||
|
||||
+6
-6
@@ -20,18 +20,18 @@
|
||||
#include "unicode/putil.h"
|
||||
#include "unicode/udata.h"
|
||||
|
||||
#define ICU_UTIL_DATA_FILE 0
|
||||
#define ICU_UTIL_DATA_SHARED 1
|
||||
#define ICU_UTIL_DATA_STATIC 2
|
||||
#define ICU_UTIL_DATA_FILE 0
|
||||
#define ICU_UTIL_DATA_SHARED 1
|
||||
#define ICU_UTIL_DATA_STATIC 2
|
||||
|
||||
#ifndef ICU_UTIL_DATA_IMPL
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#define ICU_UTIL_DATA_IMPL ICU_UTIL_DATA_SHARED
|
||||
#define ICU_UTIL_DATA_IMPL ICU_UTIL_DATA_SHARED
|
||||
#elif defined(OS_MACOSX)
|
||||
#define ICU_UTIL_DATA_IMPL ICU_UTIL_DATA_STATIC
|
||||
#define ICU_UTIL_DATA_IMPL ICU_UTIL_DATA_STATIC
|
||||
#elif defined(OS_LINUX)
|
||||
#define ICU_UTIL_DATA_IMPL ICU_UTIL_DATA_FILE
|
||||
#define ICU_UTIL_DATA_IMPL ICU_UTIL_DATA_FILE
|
||||
#endif
|
||||
|
||||
#endif // ICU_UTIL_DATA_IMPL
|
||||
|
||||
@@ -35,22 +35,22 @@ bool OSIdleTimeSource(int32 *milliseconds_interval_since_last_event) {
|
||||
return false;
|
||||
}
|
||||
int32 last_input_time = lastInputInfo.dwTime;
|
||||
|
||||
// Note: On Windows GetLastInputInfo returns a 32bit value which rolls over
|
||||
|
||||
// Note: On Windows GetLastInputInfo returns a 32bit value which rolls over
|
||||
// ~49days.
|
||||
int32 current_time = GetTickCount();
|
||||
int32 delta = current_time - last_input_time;
|
||||
// delta will go negative if we've been idle for 2GB of ticks.
|
||||
if (delta < 0)
|
||||
delta = -delta;
|
||||
delta = -delta;
|
||||
*milliseconds_interval_since_last_event = delta;
|
||||
return true;
|
||||
}
|
||||
#elif defined(OS_MACOSX)
|
||||
bool OSIdleTimeSource(int32 *milliseconds_interval_since_last_event) {
|
||||
*milliseconds_interval_since_last_event =
|
||||
*milliseconds_interval_since_last_event =
|
||||
CGEventSourceSecondsSinceLastEventType(
|
||||
kCGEventSourceStateCombinedSessionState,
|
||||
kCGEventSourceStateCombinedSessionState,
|
||||
kCGAnyInputEventType) * 1000.0;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ static Time mock_timer_started;
|
||||
|
||||
bool MockIdleTimeSource(int32 *milliseconds_interval_since_last_event) {
|
||||
TimeDelta delta = Time::Now() - mock_timer_started;
|
||||
*milliseconds_interval_since_last_event =
|
||||
*milliseconds_interval_since_last_event =
|
||||
static_cast<int32>(delta.InMilliseconds());
|
||||
return true;
|
||||
}
|
||||
@@ -112,7 +112,7 @@ TEST_F(IdleTimerTest, NoRepeatFlipIdleOnce) {
|
||||
base::OneShotTimer<TestFinishedTask> t1;
|
||||
t1.Start(TimeDelta::FromMilliseconds(10 * kSafeTestIntervalMs), &finish_task,
|
||||
&TestFinishedTask::Run);
|
||||
|
||||
|
||||
base::OneShotTimer<ResetIdleTask> t2;
|
||||
t2.Start(TimeDelta::FromMilliseconds(4 * kSafeTestIntervalMs), &reset_task,
|
||||
&ResetIdleTask::Run);
|
||||
@@ -138,7 +138,7 @@ TEST_F(IdleTimerTest, NoRepeatNotIdle) {
|
||||
base::OneShotTimer<TestFinishedTask> t;
|
||||
t.Start(TimeDelta::FromMilliseconds(10 * kSafeTestIntervalMs), &finish_task,
|
||||
&TestFinishedTask::Run);
|
||||
|
||||
|
||||
base::RepeatingTimer<ResetIdleTask> reset_timer;
|
||||
reset_timer.Start(TimeDelta::FromMilliseconds(50), &reset_task,
|
||||
&ResetIdleTask::Run);
|
||||
@@ -194,7 +194,7 @@ TEST_F(IdleTimerTest, RepeatIdleReset) {
|
||||
base::OneShotTimer<TestFinishedTask> t1;
|
||||
t1.Start(TimeDelta::FromMilliseconds(10 * kSafeTestIntervalMs), &finish_task,
|
||||
&TestFinishedTask::Run);
|
||||
|
||||
|
||||
base::OneShotTimer<ResetIdleTask> t2;
|
||||
t2.Start(TimeDelta::FromMilliseconds(5 * kSafeTestIntervalMs), &reset_task,
|
||||
&ResetIdleTask::Run);
|
||||
@@ -224,7 +224,7 @@ TEST_F(IdleTimerTest, RepeatNotIdle) {
|
||||
base::OneShotTimer<TestFinishedTask> t;
|
||||
t.Start(TimeDelta::FromMilliseconds(8 * kSafeTestIntervalMs), &finish_task,
|
||||
&TestFinishedTask::Run);
|
||||
|
||||
|
||||
base::RepeatingTimer<ResetIdleTask> reset_timer;
|
||||
reset_timer.Start(TimeDelta::FromMilliseconds(50), &reset_task,
|
||||
&ResetIdleTask::Run);
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
// static LazyInstance<MyClass> my_instance(base::LINKER_INITIALIZED);
|
||||
// void SomeMethod() {
|
||||
// my_instance.Get().SomeMethod(); // MyClass::SomeMethod()
|
||||
//
|
||||
//
|
||||
// MyClass* ptr = my_instance.Pointer();
|
||||
// ptr->DoDoDo(); // MyClass::DoDoDo
|
||||
// }
|
||||
|
||||
@@ -75,7 +75,7 @@ TEST(LazyInstanceTest, Basic) {
|
||||
lazy_logger.Pointer();
|
||||
EXPECT_EQ(3, constructed_seq_.GetNext());
|
||||
EXPECT_EQ(2, destructed_seq_.GetNext());
|
||||
}
|
||||
}
|
||||
EXPECT_EQ(4, constructed_seq_.GetNext());
|
||||
EXPECT_EQ(4, destructed_seq_.GetNext());
|
||||
}
|
||||
|
||||
+12
-7
@@ -40,7 +40,7 @@ typedef pthread_mutex_t* MutexHandle;
|
||||
#include "base/string_piece.h"
|
||||
#include "base/string_util.h"
|
||||
#include "base/sys_string_conversions.h"
|
||||
|
||||
|
||||
namespace logging {
|
||||
|
||||
bool g_enable_dcheck = false;
|
||||
@@ -406,7 +406,8 @@ void LogMessage::Init(const char* file, int line) {
|
||||
}
|
||||
if (log_tickcount)
|
||||
stream_ << TickCount() << ':';
|
||||
stream_ << log_severity_names[severity_] << ":" << file << "(" << line << ")] ";
|
||||
stream_ << log_severity_names[severity_] << ":" << file <<
|
||||
"(" << line << ")] ";
|
||||
|
||||
message_start_ = stream_.tellp();
|
||||
}
|
||||
@@ -452,16 +453,16 @@ LogMessage::~LogMessage() {
|
||||
// problems with unit tests, especially on the buildbots.
|
||||
fprintf(stderr, "%s", str_newline.c_str());
|
||||
}
|
||||
|
||||
|
||||
// write to log file
|
||||
if (logging_destination != LOG_NONE &&
|
||||
logging_destination != LOG_ONLY_TO_SYSTEM_DEBUG_LOG &&
|
||||
InitializeLogFileHandle()) {
|
||||
// we can have multiple threads and/or processes, so try to prevent them from
|
||||
// clobbering each other's writes
|
||||
// We can have multiple threads and/or processes, so try to prevent them
|
||||
// from clobbering each other's writes.
|
||||
if (lock_log_file == LOCK_LOG_FILE) {
|
||||
// Ensure that the mutex is initialized in case the client app did not
|
||||
// call InitLogging. This is not thread safe. See below
|
||||
// call InitLogging. This is not thread safe. See below.
|
||||
InitLogMutex();
|
||||
|
||||
#if defined(OS_WIN)
|
||||
@@ -486,7 +487,11 @@ LogMessage::~LogMessage() {
|
||||
#if defined(OS_WIN)
|
||||
SetFilePointer(log_file, 0, 0, SEEK_END);
|
||||
DWORD num_written;
|
||||
WriteFile(log_file, (void*)str_newline.c_str(), (DWORD)str_newline.length(), &num_written, NULL);
|
||||
WriteFile(log_file,
|
||||
static_cast<void*>(str_newline.c_str()),
|
||||
static_cast<DWORD>(str_newline.length()),
|
||||
&num_written,
|
||||
NULL);
|
||||
#else
|
||||
fprintf(log_file, "%s", str_newline.c_str());
|
||||
#endif
|
||||
|
||||
@@ -14,7 +14,7 @@ typedef PlatformTest MacUtilTest;
|
||||
TEST_F(MacUtilTest, TestFSRef) {
|
||||
FSRef ref;
|
||||
std::string path("/System/Library");
|
||||
|
||||
|
||||
ASSERT_TRUE(mac_util::FSRefFromPath(path, &ref));
|
||||
EXPECT_EQ(path, mac_util::PathFromFSRef(ref));
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ class MessagePump : public RefCountedThreadSafe<MessagePump> {
|
||||
};
|
||||
|
||||
virtual ~MessagePump() {}
|
||||
|
||||
|
||||
// The Run method is called to enter the message pump's run loop.
|
||||
//
|
||||
// Within the method, the message pump is responsible for processing native
|
||||
@@ -98,7 +98,7 @@ class MessagePump : public RefCountedThreadSafe<MessagePump> {
|
||||
// nested sub-loops that are "seemingly" outside the control of this message
|
||||
// pump. DoWork in particular must never be starved for time slices unless
|
||||
// it returns false (meaning it has run out of things to do).
|
||||
//
|
||||
//
|
||||
virtual void Run(Delegate* delegate) = 0;
|
||||
|
||||
// Quit immediately from the most recently entered run loop. This method may
|
||||
|
||||
@@ -100,7 +100,7 @@ MessagePumpForUI::MessagePumpForUI()
|
||||
wakeup_pipe_write_ = fds[1];
|
||||
wakeup_gpollfd_.fd = wakeup_pipe_read_;
|
||||
wakeup_gpollfd_.events = G_IO_IN;
|
||||
|
||||
|
||||
work_source_ = g_source_new(&WorkSourceFuncs, sizeof(WorkSource));
|
||||
static_cast<WorkSource*>(work_source_)->pump = this;
|
||||
g_source_add_poll(work_source_, &wakeup_gpollfd_);
|
||||
|
||||
@@ -383,7 +383,7 @@ bool MessagePumpForUI::ProcessPumpReplacementMessage() {
|
||||
int old_have_work = InterlockedExchange(&have_work_, 0);
|
||||
DCHECK(old_have_work);
|
||||
|
||||
// We don't need a special time slice if we didn't have_message to process.
|
||||
// We don't need a special time slice if we didn't have_message to process.
|
||||
if (!have_message)
|
||||
return false;
|
||||
|
||||
|
||||
+3
-3
@@ -49,9 +49,9 @@ class NSSInitSingleton {
|
||||
// Explicitly enable exactly those ciphers with keys of at least 80 bits
|
||||
for (int i = 0; i < SSL_NumImplementedCiphers; i++) {
|
||||
SSLCipherSuiteInfo info;
|
||||
if (SSL_GetCipherSuiteInfo(SSL_ImplementedCiphers[i], &info,
|
||||
if (SSL_GetCipherSuiteInfo(SSL_ImplementedCiphers[i], &info,
|
||||
sizeof(info)) == SECSuccess) {
|
||||
SSL_CipherPrefSetDefault(SSL_ImplementedCiphers[i],
|
||||
SSL_CipherPrefSetDefault(SSL_ImplementedCiphers[i],
|
||||
(info.effectiveKeyBits >= 80));
|
||||
}
|
||||
}
|
||||
@@ -59,7 +59,7 @@ class NSSInitSingleton {
|
||||
// Enable SSL
|
||||
SSL_OptionSetDefault(SSL_SECURITY, PR_TRUE);
|
||||
|
||||
// All other SSL options are set per-session by SSLClientSocket
|
||||
// All other SSL options are set per-session by SSLClientSocket.
|
||||
}
|
||||
|
||||
~NSSInitSingleton() {
|
||||
|
||||
@@ -23,7 +23,7 @@ struct ObjectWatcher::Watch : public Task {
|
||||
// just get out of dodge.
|
||||
if (!watcher)
|
||||
return;
|
||||
|
||||
|
||||
DCHECK(did_signal);
|
||||
watcher->StopWatching();
|
||||
|
||||
@@ -78,7 +78,7 @@ bool ObjectWatcher::StopWatching() {
|
||||
|
||||
// Make sure ObjectWatcher is used in a single-threaded fashion.
|
||||
DCHECK(watch_->origin_loop == MessageLoop::current());
|
||||
|
||||
|
||||
// If DoneWaiting is in progress, we wait for it to finish. We know whether
|
||||
// DoneWaiting happened or not by inspecting the did_signal flag.
|
||||
if (!UnregisterWaitEx(watch_->wait_object, INVALID_HANDLE_VALUE)) {
|
||||
|
||||
@@ -84,7 +84,8 @@ class ObjectWatcher : public MessageLoop::DestructionObserver {
|
||||
Watch* watch_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(ObjectWatcher);
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace base
|
||||
|
||||
#endif // BASE_OBJECT_WATCHER_H_
|
||||
|
||||
@@ -43,7 +43,7 @@ void RunTest_BasicSignal(MessageLoop::Type message_loop_type) {
|
||||
bool ok = watcher.StartWatching(event, &delegate);
|
||||
EXPECT_TRUE(ok);
|
||||
EXPECT_EQ(event, watcher.GetWatchedObject());
|
||||
|
||||
|
||||
SetEvent(event);
|
||||
|
||||
MessageLoop::current()->Run();
|
||||
@@ -63,7 +63,7 @@ void RunTest_BasicCancel(MessageLoop::Type message_loop_type) {
|
||||
QuitDelegate delegate;
|
||||
bool ok = watcher.StartWatching(event, &delegate);
|
||||
EXPECT_TRUE(ok);
|
||||
|
||||
|
||||
watcher.StopWatching();
|
||||
|
||||
CloseHandle(event);
|
||||
@@ -83,12 +83,12 @@ void RunTest_CancelAfterSet(MessageLoop::Type message_loop_type) {
|
||||
|
||||
bool ok = watcher.StartWatching(event, &delegate);
|
||||
EXPECT_TRUE(ok);
|
||||
|
||||
|
||||
SetEvent(event);
|
||||
|
||||
|
||||
// Let the background thread do its business
|
||||
Sleep(30);
|
||||
|
||||
|
||||
watcher.StopWatching();
|
||||
|
||||
MessageLoop::current()->RunAllPending();
|
||||
|
||||
@@ -89,7 +89,7 @@ class ObserverList {
|
||||
|
||||
// Remove an observer from the list.
|
||||
void RemoveObserver(ObserverType* obs) {
|
||||
typename ListType::iterator it =
|
||||
typename ListType::iterator it =
|
||||
std::find(observers_.begin(), observers_.end(), obs);
|
||||
if (it != observers_.end()) {
|
||||
if (notify_depth_) {
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
// OVERVIEW:
|
||||
//
|
||||
// A thread-safe container for a list of observers.
|
||||
// This is similar to the observer_list (see observer_list.h), but it
|
||||
// This is similar to the observer_list (see observer_list.h), but it
|
||||
// is more robust for multi-threaded situations.
|
||||
//
|
||||
//
|
||||
// The following use cases are supported:
|
||||
// * Observers can register for notifications from any thread.
|
||||
// Callbacks to the observer will occur on the same thread where
|
||||
@@ -42,14 +42,14 @@
|
||||
//
|
||||
// IMPLEMENTATION NOTES
|
||||
// The ObserverListThreadSafe maintains an ObserverList for each thread
|
||||
// which uses the ThreadSafeObserver. When Notifying the observers,
|
||||
// which uses the ThreadSafeObserver. When Notifying the observers,
|
||||
// we simply call PostTask to each registered thread, and then each thread
|
||||
// will notify its regular ObserverList.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
template <class ObserverType>
|
||||
class ObserverListThreadSafe :
|
||||
public base::RefCountedThreadSafe<ObserverListThreadSafe<ObserverType> > {
|
||||
class ObserverListThreadSafe
|
||||
: public base::RefCountedThreadSafe<ObserverListThreadSafe<ObserverType> > {
|
||||
public:
|
||||
ObserverListThreadSafe() {}
|
||||
|
||||
@@ -138,7 +138,7 @@ class ObserverListThreadSafe :
|
||||
MessageLoop* loop = (*it).first;
|
||||
ObserverList<ObserverType>* list = (*it).second;
|
||||
loop->PostTask(FROM_HERE,
|
||||
NewRunnableMethod(this,
|
||||
NewRunnableMethod(this,
|
||||
&ObserverListThreadSafe<ObserverType>::
|
||||
template NotifyWrapper<Method, Params>, list, method));
|
||||
}
|
||||
|
||||
@@ -110,7 +110,8 @@ class AddRemoveThread : public PlatformThread::Delegate,
|
||||
loop_->PostTask(FROM_HERE,
|
||||
factory_->NewRunnableMethod(&AddRemoveThread::AddTask));
|
||||
loop_->Run();
|
||||
//LOG(ERROR) << "Loop 0x" << std::hex << loop_ << " done. " << count_observes_ << ", " << count_addtask_;
|
||||
//LOG(ERROR) << "Loop 0x" << std::hex << loop_ << " done. " <<
|
||||
// count_observes_ << ", " << count_addtask_;
|
||||
delete loop_;
|
||||
loop_ = reinterpret_cast<MessageLoop*>(0xdeadbeef);
|
||||
delete this;
|
||||
@@ -231,7 +232,7 @@ TEST(ObserverListThreadSafeTest, BasicTest) {
|
||||
// from the observer list. Optionally, if cross_thread_notifies is set
|
||||
// to true, the observer threads will also trigger notifications to
|
||||
// all observers.
|
||||
static void ThreadSafeObserverHarness(int num_threads,
|
||||
static void ThreadSafeObserverHarness(int num_threads,
|
||||
bool cross_thread_notifies) {
|
||||
MessageLoop loop;
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ struct PathData {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
static PathData* GetPathData() {
|
||||
return Singleton<PathData>::get();
|
||||
}
|
||||
@@ -131,7 +131,7 @@ static PathData* GetPathData() {
|
||||
bool PathService::GetFromCache(int key, FilePath* result) {
|
||||
PathData* path_data = GetPathData();
|
||||
AutoLock scoped_lock(path_data->lock);
|
||||
|
||||
|
||||
// check for a cached version
|
||||
PathMap::const_iterator it = path_data->cache.find(key);
|
||||
if (it != path_data->cache.end()) {
|
||||
|
||||
@@ -43,7 +43,8 @@ class PathService {
|
||||
// path specifies a directory that does not exist, the directory will be
|
||||
// created by this method. This method returns true if successful.
|
||||
//
|
||||
// If the given path is relative, then it will be resolved against DIR_CURRENT.
|
||||
// If the given path is relative, then it will be resolved against
|
||||
// DIR_CURRENT.
|
||||
//
|
||||
// WARNING: Consumers of PathService::Get may expect paths to be constant
|
||||
// over the lifetime of the app, so this method should be used with caution.
|
||||
@@ -73,7 +74,7 @@ class PathService {
|
||||
private:
|
||||
static bool GetFromCache(int key, FilePath* path);
|
||||
static void AddToCache(int key, const FilePath& path);
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // BASE_PATH_SERVICE_H__
|
||||
|
||||
@@ -34,8 +34,8 @@ enum PlatformFileFlags {
|
||||
PLATFORM_FILE_ASYNC = 256
|
||||
};
|
||||
|
||||
// Creates or open the given file. If PLATFORM_FILE_OPEN_ALWAYS is used, and
|
||||
// |created| is provided, |created| will be set to true if the file was created
|
||||
// Creates or open the given file. If PLATFORM_FILE_OPEN_ALWAYS is used, and
|
||||
// |created| is provided, |created| will be set to true if the file was created
|
||||
// or to false in case the file was just opened.
|
||||
PlatformFile CreatePlatformFile(const std::wstring& name,
|
||||
int flags,
|
||||
|
||||
@@ -23,7 +23,7 @@ void InitThreading();
|
||||
static void* ThreadFunc(void* closure) {
|
||||
PlatformThread::Delegate* delegate =
|
||||
static_cast<PlatformThread::Delegate*>(closure);
|
||||
delegate->ThreadMain();
|
||||
delegate->ThreadMain();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ typedef struct tagTHREADNAME_INFO {
|
||||
DWORD __stdcall ThreadFunc(void* closure) {
|
||||
PlatformThread::Delegate* delegate =
|
||||
static_cast<PlatformThread::Delegate*>(closure);
|
||||
delegate->ThreadMain();
|
||||
delegate->ThreadMain();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -66,11 +66,11 @@ int GetCurrentProcId();
|
||||
|
||||
// Returns the ProcessHandle of the current process.
|
||||
ProcessHandle GetCurrentProcessHandle();
|
||||
|
||||
|
||||
// Converts a PID to a process handle. This handle must be closed by
|
||||
// CloseProcessHandle when you are done with it.
|
||||
ProcessHandle OpenProcessHandle(int pid);
|
||||
|
||||
|
||||
// Closes the process handle opened by OpenProcessHandle.
|
||||
void CloseProcessHandle(ProcessHandle process);
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ bool LaunchApp(const CommandLine& cl,
|
||||
}
|
||||
|
||||
NamedProcessIterator::NamedProcessIterator(const std::wstring& executable_name,
|
||||
const ProcessFilter* filter)
|
||||
const ProcessFilter* filter)
|
||||
: executable_name_(executable_name),
|
||||
index_of_kinfo_proc_(0),
|
||||
filter_(filter) {
|
||||
@@ -102,7 +102,7 @@ NamedProcessIterator::NamedProcessIterator(const std::wstring& executable_name,
|
||||
// impossible.
|
||||
|
||||
int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_UID, geteuid() };
|
||||
|
||||
|
||||
// Since more processes could start between when we get the size and when
|
||||
// we get the list, we do a loop to keep trying until we get it.
|
||||
bool done = false;
|
||||
@@ -119,7 +119,7 @@ NamedProcessIterator::NamedProcessIterator(const std::wstring& executable_name,
|
||||
size_t num_of_kinfo_proc = len / sizeof(struct kinfo_proc);
|
||||
// Leave some spare room for process table growth (more could show up
|
||||
// between when we check and now)
|
||||
num_of_kinfo_proc += 4;
|
||||
num_of_kinfo_proc += 4;
|
||||
kinfo_procs_.resize(num_of_kinfo_proc);
|
||||
len = num_of_kinfo_proc * sizeof(struct kinfo_proc);
|
||||
// Load the list of processes
|
||||
@@ -139,7 +139,7 @@ NamedProcessIterator::NamedProcessIterator(const std::wstring& executable_name,
|
||||
}
|
||||
}
|
||||
} while (!done && (try_num++ < max_tries));
|
||||
|
||||
|
||||
if (!done) {
|
||||
LOG(ERROR) << "failed to collect the process list in a few tries";
|
||||
kinfo_procs_.resize(0);
|
||||
@@ -154,7 +154,7 @@ const ProcessEntry* NamedProcessIterator::NextProcessEntry() {
|
||||
do {
|
||||
result = CheckForNextProcess();
|
||||
} while (result && !IncludeEntry());
|
||||
|
||||
|
||||
if (result) {
|
||||
return &entry_;
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ bool DidProcessCrash(ProcessHandle handle) {
|
||||
|
||||
// Warning, this is not generic code; it heavily depends on the way
|
||||
// the rest of the code kills a process.
|
||||
|
||||
|
||||
if (exitcode == PROCESS_END_NORMAL_TERMINATON ||
|
||||
exitcode == PROCESS_END_KILLED_BY_USER ||
|
||||
exitcode == PROCESS_END_PROCESS_WAS_HUNG ||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "base/logging.h"
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
uint32 RandUint32() {
|
||||
uint32 number;
|
||||
CHECK(rand_s(&number) == 0);
|
||||
|
||||
+19
-56
@@ -3,12 +3,12 @@
|
||||
// found in the LICENSE file.
|
||||
// All Rights Reserved.
|
||||
|
||||
#include "base/registry.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <shlwapi.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include "base/registry.h"
|
||||
|
||||
#pragma comment(lib, "shlwapi.lib") // for SHDeleteKey
|
||||
|
||||
// local types (see the same declarations in the header file)
|
||||
@@ -20,7 +20,6 @@
|
||||
// RegistryValueIterator
|
||||
//
|
||||
|
||||
|
||||
RegistryValueIterator::RegistryValueIterator(HKEY root_key,
|
||||
LPCTSTR folder_key) {
|
||||
LONG result = RegOpenKeyEx(root_key, folder_key, 0, KEY_READ, &key_);
|
||||
@@ -52,14 +51,12 @@ bool RegistryValueIterator::Valid() const {
|
||||
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_);
|
||||
@@ -76,11 +73,11 @@ bool RegistryValueIterator::Read() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
DWORD RegistryValueIterator::ValueCount() const {
|
||||
|
||||
DWORD count = 0;
|
||||
HRESULT result = ::RegQueryInfoKey(key_, NULL, 0, NULL, NULL, NULL, NULL, &count, NULL, NULL, NULL, NULL);
|
||||
HRESULT result = ::RegQueryInfoKey(key_, NULL, 0, NULL, NULL, NULL, NULL,
|
||||
&count, NULL, NULL, NULL, NULL);
|
||||
|
||||
if (result != ERROR_SUCCESS)
|
||||
return 0;
|
||||
@@ -88,12 +85,10 @@ DWORD RegistryValueIterator::ValueCount() const {
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// RegistryKeyIterator
|
||||
//
|
||||
|
||||
|
||||
RegistryKeyIterator::RegistryKeyIterator(HKEY root_key,
|
||||
LPCTSTR folder_key) {
|
||||
LONG result = RegOpenKeyEx(root_key, folder_key, 0, KEY_READ, &key_);
|
||||
@@ -125,14 +120,12 @@ bool RegistryKeyIterator::Valid() const {
|
||||
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_);
|
||||
@@ -147,7 +140,6 @@ bool RegistryKeyIterator::Read() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
DWORD RegistryKeyIterator::SubkeyCount() const {
|
||||
|
||||
DWORD count = 0;
|
||||
@@ -160,13 +152,10 @@ DWORD RegistryKeyIterator::SubkeyCount() const {
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// RegKey
|
||||
//
|
||||
|
||||
|
||||
|
||||
RegKey::RegKey(HKEY rootkey, const tchar* subkey, REGSAM access)
|
||||
: key_(NULL), watch_event_(0) {
|
||||
if (rootkey) {
|
||||
@@ -178,8 +167,6 @@ RegKey::RegKey(HKEY rootkey, const tchar* subkey, REGSAM access)
|
||||
else assert(!subkey);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RegKey::Close() {
|
||||
StopWatching();
|
||||
if (key_) {
|
||||
@@ -188,15 +175,11 @@ void RegKey::Close() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
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);
|
||||
@@ -218,8 +201,6 @@ bool RegKey::CreateWithDisposition(HKEY rootkey, const tchar* subkey,
|
||||
else return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool RegKey::Open(HKEY rootkey, const tchar* subkey, REGSAM access) {
|
||||
assert(rootkey && subkey && access);
|
||||
this->Close();
|
||||
@@ -233,8 +214,6 @@ bool RegKey::Open(HKEY rootkey, const tchar* subkey, REGSAM access) {
|
||||
else return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool RegKey::CreateKey(const tchar* name, REGSAM access) {
|
||||
assert(name && access);
|
||||
|
||||
@@ -248,8 +227,6 @@ bool RegKey::CreateKey(const tchar* name, REGSAM access) {
|
||||
return (result == ERROR_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool RegKey::OpenKey(const tchar* name, REGSAM access) {
|
||||
assert(name && access);
|
||||
|
||||
@@ -262,9 +239,6 @@ bool RegKey::OpenKey(const tchar* name, REGSAM access) {
|
||||
return (result == ERROR_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
DWORD RegKey::ValueCount() {
|
||||
DWORD count = 0;
|
||||
HRESULT const result = ::RegQueryInfoKey(key_, NULL, 0, NULL, NULL, NULL,
|
||||
@@ -272,7 +246,6 @@ DWORD RegKey::ValueCount() {
|
||||
return (result != ERROR_SUCCESS) ? 0 : count;
|
||||
}
|
||||
|
||||
|
||||
bool RegKey::ReadName(int index, tstr* name) {
|
||||
tchar buf[256];
|
||||
DWORD bufsize = sizeof(buf)/sizeof(*buf);
|
||||
@@ -285,15 +258,12 @@ bool RegKey::ReadName(int index, tstr* name) {
|
||||
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;
|
||||
@@ -303,8 +273,6 @@ bool RegKey::ReadValue(const tchar* name, void* data,
|
||||
return (result == ERROR_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool RegKey::ReadValue(const tchar* name, tstr * value) {
|
||||
assert(value);
|
||||
static const size_t kMaxStringLength = 1024; // This is after expansion.
|
||||
@@ -332,8 +300,6 @@ bool RegKey::ReadValue(const tchar* name, tstr * value) {
|
||||
else return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool RegKey::ReadValueDW(const tchar* name, DWORD * value) {
|
||||
assert(value);
|
||||
DWORD type = REG_DWORD, size = sizeof(DWORD), result = 0;
|
||||
@@ -346,33 +312,32 @@ bool RegKey::ReadValueDW(const tchar* name, DWORD * value) {
|
||||
else return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool RegKey::WriteValue(const tchar* name, const void * data, DWORD dsize, DWORD dtype) {
|
||||
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);
|
||||
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));
|
||||
@@ -428,9 +393,10 @@ bool RegKey::HasChanged() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Register a COM object with the most usual properties.
|
||||
bool RegisterCOMServer(const tchar* guid, const tchar* name, const tchar* path) {
|
||||
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);
|
||||
@@ -438,7 +404,7 @@ bool RegisterCOMServer(const tchar* guid, const tchar* name, const tchar* path)
|
||||
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];
|
||||
@@ -452,6 +418,3 @@ bool UnregisterCOMServer(const tchar* guid) {
|
||||
key.DeleteKey(guid);
|
||||
return true;
|
||||
}
|
||||
|
||||
// LocalWords: RegKey
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ BSTR ScopedBstr::Allocate(const wchar_t* wide_str) {
|
||||
}
|
||||
|
||||
BSTR ScopedBstr::AllocateBytes(int bytes) {
|
||||
Reset(SysAllocStringByteLen(NULL, bytes));
|
||||
Reset(SysAllocStringByteLen(NULL, bytes));
|
||||
return bstr_;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ bool ScopedTempDir::CreateUniqueTempDir() {
|
||||
|
||||
bool ScopedTempDir::Set(const FilePath& path) {
|
||||
DCHECK(path_.empty());
|
||||
if (!file_util::DirectoryExists(path) &&
|
||||
if (!file_util::DirectoryExists(path) &&
|
||||
!file_util::CreateDirectory(path)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ class MultipleThreadMain : public PlatformThread::Delegate {
|
||||
|
||||
static void CleanUp() {
|
||||
SharedMemory memory;
|
||||
memory.Delete(test_name_);
|
||||
memory.Delete(s_test_name_);
|
||||
}
|
||||
|
||||
// PlatformThread::Delegate interface.
|
||||
@@ -35,7 +35,7 @@ class MultipleThreadMain : public PlatformThread::Delegate {
|
||||
ScopedNSAutoreleasePool pool; // noop if not OSX
|
||||
const int kDataSize = 1024;
|
||||
SharedMemory memory;
|
||||
bool rv = memory.Create(test_name_, false, true, kDataSize);
|
||||
bool rv = memory.Create(s_test_name_, false, true, kDataSize);
|
||||
EXPECT_TRUE(rv);
|
||||
rv = memory.Map(kDataSize);
|
||||
EXPECT_TRUE(rv);
|
||||
@@ -54,12 +54,13 @@ class MultipleThreadMain : public PlatformThread::Delegate {
|
||||
private:
|
||||
int16 id_;
|
||||
|
||||
static const std::wstring test_name_;
|
||||
static const wchar_t* const s_test_name_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(MultipleThreadMain);
|
||||
};
|
||||
|
||||
const std::wstring MultipleThreadMain::test_name_ = L"SharedMemoryOpenThreadTest";
|
||||
const wchar_t* const MultipleThreadMain::s_test_name_ =
|
||||
L"SharedMemoryOpenThreadTest";
|
||||
|
||||
// TODO(port):
|
||||
// This test requires the ability to pass file descriptors between processes.
|
||||
@@ -281,7 +282,7 @@ class SharedMemoryProcessTest : public MultiProcessTest {
|
||||
|
||||
static void CleanUp() {
|
||||
SharedMemory memory;
|
||||
memory.Delete(test_name_);
|
||||
memory.Delete(s_test_name_);
|
||||
}
|
||||
|
||||
static int TaskTestMain() {
|
||||
@@ -289,7 +290,7 @@ class SharedMemoryProcessTest : public MultiProcessTest {
|
||||
ScopedNSAutoreleasePool pool; // noop if not OSX
|
||||
const int kDataSize = 1024;
|
||||
SharedMemory memory;
|
||||
bool rv = memory.Create(test_name_, false, true, kDataSize);
|
||||
bool rv = memory.Create(s_test_name_, false, true, kDataSize);
|
||||
EXPECT_TRUE(rv);
|
||||
if (rv != true)
|
||||
errors++;
|
||||
@@ -314,10 +315,10 @@ class SharedMemoryProcessTest : public MultiProcessTest {
|
||||
}
|
||||
|
||||
private:
|
||||
static const std::wstring test_name_;
|
||||
static const wchar_t* const s_test_name_;
|
||||
};
|
||||
|
||||
const std::wstring SharedMemoryProcessTest::test_name_ = L"MPMem";
|
||||
const const wchar_t* const SharedMemoryProcessTest::s_test_name_ = L"MPMem";
|
||||
|
||||
|
||||
TEST_F(SharedMemoryProcessTest, Tasks) {
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef BASE_STACK_CONTAINER_H__
|
||||
#define BASE_STACK_CONTAINER_H__
|
||||
#ifndef BASE_STACK_CONTAINER_H_
|
||||
#define BASE_STACK_CONTAINER_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -71,7 +71,7 @@ class StackAllocator : public std::allocator<T> {
|
||||
};
|
||||
|
||||
// For the straight up copy c-tor, we can share storage.
|
||||
StackAllocator(const StackAllocator<T, stack_capacity>& rhs)
|
||||
StackAllocator(const StackAllocator<T, stack_capacity>& rhs)
|
||||
: source_(rhs.source_) {
|
||||
}
|
||||
|
||||
@@ -80,9 +80,9 @@ class StackAllocator : public std::allocator<T> {
|
||||
// in the class _Container_base_aux_alloc_real (from <xutility>)
|
||||
// if the constructor does not exist.
|
||||
// For this constructor, we cannot share storage; there's
|
||||
// no guarantee that the Source buffer of Ts is large enough
|
||||
// no guarantee that the Source buffer of Ts is large enough
|
||||
// for Us.
|
||||
// TODO: If we were fancy pants, perhaps we could share storage
|
||||
// TODO: If we were fancy pants, perhaps we could share storage
|
||||
// iff sizeof(T) == sizeof(U).
|
||||
template<typename U, size_t other_capacity>
|
||||
StackAllocator(const StackAllocator<U, other_capacity>& other)
|
||||
@@ -245,10 +245,9 @@ class StackVector : public StackContainer<
|
||||
// Vectors are commonly indexed, which isn't very convenient even with
|
||||
// operator-> (using "->at()" does exception stuff we don't want).
|
||||
T& operator[](size_t i) { return this->container().operator[](i); }
|
||||
const T& operator[](size_t i) const {
|
||||
return this->container().operator[](i);
|
||||
const T& operator[](size_t i) const {
|
||||
return this->container().operator[](i);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // BASE_STACK_CONTAINER_H__
|
||||
|
||||
#endif // BASE_STACK_CONTAINER_H_
|
||||
|
||||
@@ -347,7 +347,7 @@ void StatsTable::UnregisterThread(StatsTableTLSData* data) {
|
||||
}
|
||||
|
||||
void StatsTable::SlotReturnFunction(void* data) {
|
||||
// This is called by the TLS destructor, which on some platforms has
|
||||
// This is called by the TLS destructor, which on some platforms has
|
||||
// already cleared the TLS info, so use the tls_data argument
|
||||
// rather than trying to fetch it ourselves.
|
||||
StatsTableTLSData* tls_data = static_cast<StatsTableTLSData*>(data);
|
||||
@@ -557,4 +557,3 @@ int* StatsTable::FindLocation(const char* name) {
|
||||
// Now we can find the location in the table.
|
||||
return table->GetLocation(counter, slot);
|
||||
}
|
||||
|
||||
|
||||
@@ -1617,7 +1617,7 @@ bool ElideString(const std::wstring& input, int max_len, std::wstring* output) {
|
||||
output->assign(input);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
switch (max_len) {
|
||||
case 0:
|
||||
output->clear();
|
||||
|
||||
@@ -52,7 +52,7 @@ bool ReadUnicodeCharacter(const char16* src, int32 src_len,
|
||||
// Invalid surrogate pair.
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Valid surrogate pair.
|
||||
*code_point = U16_GET_SUPPLEMENTARY(src[*char_index],
|
||||
src[*char_index + 1]);
|
||||
|
||||
@@ -122,10 +122,9 @@ TEST(StringUtilTest, IsStringUTF8) {
|
||||
EXPECT_TRUE(IsStringUTF8("a\xc2\x81\xe1\x80\xbf\xf1\x80\xa0\xbf"));
|
||||
EXPECT_TRUE(IsStringUTF8("\xef\xbb\xbf" "abc")); // UTF-8 BOM
|
||||
|
||||
|
||||
// surrogate code points
|
||||
// surrogate code points
|
||||
EXPECT_FALSE(IsStringUTF8("\xed\xa0\x80\xed\xbf\xbf"));
|
||||
EXPECT_FALSE(IsStringUTF8("\xed\xa0\x8f"));
|
||||
EXPECT_FALSE(IsStringUTF8("\xed\xa0\x8f"));
|
||||
EXPECT_FALSE(IsStringUTF8("\xed\xbf\xbf"));
|
||||
|
||||
// overlong sequences
|
||||
@@ -166,14 +165,14 @@ TEST(StringUtilTest, IsStringUTF8) {
|
||||
|
||||
// Strings in legacy encodings. We can certainly make up strings
|
||||
// in a legacy encoding that are valid in UTF-8, but in real data,
|
||||
// most of them are invalid as UTF-8.
|
||||
// most of them are invalid as UTF-8.
|
||||
EXPECT_FALSE(IsStringUTF8("caf\xe9")); // cafe with U+00E9 in ISO-8859-1
|
||||
EXPECT_FALSE(IsStringUTF8("\xb0\xa1\xb0\xa2")); // U+AC00, U+AC001 in EUC-KR
|
||||
EXPECT_FALSE(IsStringUTF8("\xa7\x41\xa6\x6e")); // U+4F60 U+597D in Big5
|
||||
// "abc" with U+201[CD] in windows-125[0-8]
|
||||
EXPECT_FALSE(IsStringUTF8("\x93" "abc\x94"));
|
||||
EXPECT_FALSE(IsStringUTF8("\x93" "abc\x94"));
|
||||
// U+0639 U+064E U+0644 U+064E in ISO-8859-6
|
||||
EXPECT_FALSE(IsStringUTF8("\xd9\xee\xe4\xee"));
|
||||
EXPECT_FALSE(IsStringUTF8("\xd9\xee\xe4\xee"));
|
||||
// U+03B3 U+03B5 U+03B9 U+03AC in ISO-8859-7
|
||||
EXPECT_FALSE(IsStringUTF8("\xe3\xe5\xe9\xdC"));
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
namespace base {
|
||||
|
||||
// static
|
||||
void SysInfo::OperatingSystemVersionNumbers(int32 *major_version,
|
||||
void SysInfo::OperatingSystemVersionNumbers(int32 *major_version,
|
||||
int32 *minor_version,
|
||||
int32 *bugfix_version) {
|
||||
static bool is_initialized = false;
|
||||
@@ -19,11 +19,11 @@ void SysInfo::OperatingSystemVersionNumbers(int32 *major_version,
|
||||
|
||||
if (!is_initialized) {
|
||||
// Gestalt can't be called in the sandbox, so we cache its return value.
|
||||
Gestalt(gestaltSystemVersionMajor,
|
||||
Gestalt(gestaltSystemVersionMajor,
|
||||
reinterpret_cast<SInt32*>(&major_version_cached));
|
||||
Gestalt(gestaltSystemVersionMinor,
|
||||
Gestalt(gestaltSystemVersionMinor,
|
||||
reinterpret_cast<SInt32*>(&minor_version_cached));
|
||||
Gestalt(gestaltSystemVersionBugFix,
|
||||
Gestalt(gestaltSystemVersionBugFix,
|
||||
reinterpret_cast<SInt32*>(&bugfix_version_cached));
|
||||
is_initialized = true;
|
||||
}
|
||||
|
||||
@@ -50,9 +50,9 @@ std::string SysWideToMultiByte(const std::wstring& wide, uint32 code_page);
|
||||
#endif // defined(OS_WIN)
|
||||
|
||||
// Mac-specific ----------------------------------------------------------------
|
||||
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
|
||||
|
||||
// Converts between STL strings and CFStringRefs/NSStrings.
|
||||
|
||||
// Creates a string, and returns it with a refcount of 1. You are responsible
|
||||
@@ -77,7 +77,7 @@ string16 SysNSStringToUTF16(NSString* ref);
|
||||
std::wstring SysNSStringToWide(NSString* ref);
|
||||
|
||||
#endif // defined(OS_MACOSX)
|
||||
|
||||
|
||||
} // namespace base
|
||||
|
||||
#endif // BASE_SYS_STRING_CONVERSIONS_H_
|
||||
|
||||
@@ -26,7 +26,8 @@ TEST(SysStrings, SysWideToUTF8) {
|
||||
//
|
||||
// This is what XP does, but Vista has different behavior, so we don't bother
|
||||
// verifying it:
|
||||
//EXPECT_EQ("\xE4\xBD\xA0\xED\xA0\x80zyxw", SysWideToUTF8(L"\x4f60\xd800zyxw"));
|
||||
//EXPECT_EQ("\xE4\xBD\xA0\xED\xA0\x80zyxw",
|
||||
// SysWideToUTF8(L"\x4f60\xd800zyxw"));
|
||||
|
||||
// Test embedded NULLs.
|
||||
std::wstring wide_null(L"a");
|
||||
|
||||
@@ -1,79 +1,79 @@
|
||||
// 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.
|
||||
|
||||
#include "base/system_monitor.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
class PowerTest : public base::SystemMonitor::PowerObserver {
|
||||
public:
|
||||
PowerTest()
|
||||
: battery_(false),
|
||||
power_state_changes_(0),
|
||||
suspends_(0),
|
||||
resumes_(0) {};
|
||||
|
||||
// PowerObserver callbacks.
|
||||
void OnPowerStateChange(base::SystemMonitor*) { power_state_changes_++; };
|
||||
void OnSuspend(base::SystemMonitor*) { suspends_++; };
|
||||
void OnResume(base::SystemMonitor*) { resumes_++; };
|
||||
|
||||
// Test status counts.
|
||||
bool battery() { return battery_; }
|
||||
int power_state_changes() { return power_state_changes_; }
|
||||
int suspends() { return suspends_; }
|
||||
int resumes() { return resumes_; }
|
||||
|
||||
private:
|
||||
bool battery_; // Do we currently think we're on battery power.
|
||||
int power_state_changes_; // Count of OnPowerStateChange notifications.
|
||||
int suspends_; // Count of OnSuspend notifications.
|
||||
int resumes_; // Count of OnResume notifications.
|
||||
};
|
||||
|
||||
TEST(SystemMonitor, PowerNotifications) {
|
||||
const int kObservers = 5;
|
||||
|
||||
// Initialize a message loop for this to run on.
|
||||
MessageLoop loop;
|
||||
// Initialize time() since it registers as a SystemMonitor observer.
|
||||
base::Time now = base::Time::Now();
|
||||
|
||||
base::SystemMonitor* monitor = base::SystemMonitor::Get();
|
||||
PowerTest test[kObservers];
|
||||
for (int index = 0; index < kObservers; ++index)
|
||||
monitor->AddObserver(&test[index]);
|
||||
|
||||
// Send a bunch of power changes. Since the battery power hasn't
|
||||
// actually changed, we shouldn't get notifications.
|
||||
for (int index = 0; index < 5; index++) {
|
||||
monitor->ProcessPowerMessage(base::SystemMonitor::POWER_STATE_EVENT);
|
||||
EXPECT_EQ(test[0].power_state_changes(), 0);
|
||||
}
|
||||
|
||||
// Sending resume when not suspended should have no effect.
|
||||
monitor->ProcessPowerMessage(base::SystemMonitor::RESUME_EVENT);
|
||||
loop.RunAllPending();
|
||||
EXPECT_EQ(test[0].resumes(), 0);
|
||||
|
||||
// Pretend we suspended.
|
||||
monitor->ProcessPowerMessage(base::SystemMonitor::SUSPEND_EVENT);
|
||||
loop.RunAllPending();
|
||||
EXPECT_EQ(test[0].suspends(), 1);
|
||||
|
||||
// Send a second suspend notification. This should be suppressed.
|
||||
monitor->ProcessPowerMessage(base::SystemMonitor::SUSPEND_EVENT);
|
||||
loop.RunAllPending();
|
||||
EXPECT_EQ(test[0].suspends(), 1);
|
||||
|
||||
// Pretend we were awakened.
|
||||
monitor->ProcessPowerMessage(base::SystemMonitor::RESUME_EVENT);
|
||||
loop.RunAllPending();
|
||||
EXPECT_EQ(test[0].resumes(), 1);
|
||||
|
||||
// Send a duplicate resume notification. This should be suppressed.
|
||||
monitor->ProcessPowerMessage(base::SystemMonitor::RESUME_EVENT);
|
||||
loop.RunAllPending();
|
||||
EXPECT_EQ(test[0].resumes(), 1);
|
||||
}
|
||||
|
||||
// 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.
|
||||
|
||||
#include "base/system_monitor.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
class PowerTest : public base::SystemMonitor::PowerObserver {
|
||||
public:
|
||||
PowerTest()
|
||||
: battery_(false),
|
||||
power_state_changes_(0),
|
||||
suspends_(0),
|
||||
resumes_(0) {};
|
||||
|
||||
// PowerObserver callbacks.
|
||||
void OnPowerStateChange(base::SystemMonitor*) { power_state_changes_++; };
|
||||
void OnSuspend(base::SystemMonitor*) { suspends_++; };
|
||||
void OnResume(base::SystemMonitor*) { resumes_++; };
|
||||
|
||||
// Test status counts.
|
||||
bool battery() { return battery_; }
|
||||
int power_state_changes() { return power_state_changes_; }
|
||||
int suspends() { return suspends_; }
|
||||
int resumes() { return resumes_; }
|
||||
|
||||
private:
|
||||
bool battery_; // Do we currently think we're on battery power.
|
||||
int power_state_changes_; // Count of OnPowerStateChange notifications.
|
||||
int suspends_; // Count of OnSuspend notifications.
|
||||
int resumes_; // Count of OnResume notifications.
|
||||
};
|
||||
|
||||
TEST(SystemMonitor, PowerNotifications) {
|
||||
const int kObservers = 5;
|
||||
|
||||
// Initialize a message loop for this to run on.
|
||||
MessageLoop loop;
|
||||
// Initialize time() since it registers as a SystemMonitor observer.
|
||||
base::Time now = base::Time::Now();
|
||||
|
||||
base::SystemMonitor* monitor = base::SystemMonitor::Get();
|
||||
PowerTest test[kObservers];
|
||||
for (int index = 0; index < kObservers; ++index)
|
||||
monitor->AddObserver(&test[index]);
|
||||
|
||||
// Send a bunch of power changes. Since the battery power hasn't
|
||||
// actually changed, we shouldn't get notifications.
|
||||
for (int index = 0; index < 5; index++) {
|
||||
monitor->ProcessPowerMessage(base::SystemMonitor::POWER_STATE_EVENT);
|
||||
EXPECT_EQ(test[0].power_state_changes(), 0);
|
||||
}
|
||||
|
||||
// Sending resume when not suspended should have no effect.
|
||||
monitor->ProcessPowerMessage(base::SystemMonitor::RESUME_EVENT);
|
||||
loop.RunAllPending();
|
||||
EXPECT_EQ(test[0].resumes(), 0);
|
||||
|
||||
// Pretend we suspended.
|
||||
monitor->ProcessPowerMessage(base::SystemMonitor::SUSPEND_EVENT);
|
||||
loop.RunAllPending();
|
||||
EXPECT_EQ(test[0].suspends(), 1);
|
||||
|
||||
// Send a second suspend notification. This should be suppressed.
|
||||
monitor->ProcessPowerMessage(base::SystemMonitor::SUSPEND_EVENT);
|
||||
loop.RunAllPending();
|
||||
EXPECT_EQ(test[0].suspends(), 1);
|
||||
|
||||
// Pretend we were awakened.
|
||||
monitor->ProcessPowerMessage(base::SystemMonitor::RESUME_EVENT);
|
||||
loop.RunAllPending();
|
||||
EXPECT_EQ(test[0].resumes(), 1);
|
||||
|
||||
// Send a duplicate resume notification. This should be suppressed.
|
||||
monitor->ProcessPowerMessage(base::SystemMonitor::RESUME_EVENT);
|
||||
loop.RunAllPending();
|
||||
EXPECT_EQ(test[0].resumes(), 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,49 +1,49 @@
|
||||
// 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.
|
||||
|
||||
#include "base/system_monitor.h"
|
||||
|
||||
namespace base {
|
||||
|
||||
void SystemMonitor::ProcessWmPowerBroadcastMessage(int event_id) {
|
||||
PowerEvent power_event;
|
||||
switch (event_id) {
|
||||
case PBT_APMPOWERSTATUSCHANGE: // The power status changed.
|
||||
power_event = POWER_STATE_EVENT;
|
||||
break;
|
||||
case PBT_APMRESUMEAUTOMATIC: // Non-user initiated resume from suspend.
|
||||
case PBT_APMRESUMESUSPEND: // User initiated resume from suspend.
|
||||
power_event = RESUME_EVENT;
|
||||
break;
|
||||
case PBT_APMSUSPEND: // System has been suspended.
|
||||
power_event = SUSPEND_EVENT;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
|
||||
// Other Power Events:
|
||||
// PBT_APMBATTERYLOW - removed in Vista.
|
||||
// PBT_APMOEMEVENT - removed in Vista.
|
||||
// PBT_APMQUERYSUSPEND - removed in Vista.
|
||||
// PBT_APMQUERYSUSPENDFAILED - removed in Vista.
|
||||
// PBT_APMRESUMECRITICAL - removed in Vista.
|
||||
// PBT_POWERSETTINGCHANGE - user changed the power settings.
|
||||
}
|
||||
ProcessPowerMessage(power_event);
|
||||
}
|
||||
|
||||
// Function to query the system to see if it is currently running on
|
||||
// battery power. Returns true if running on battery.
|
||||
bool SystemMonitor::IsBatteryPower() {
|
||||
SYSTEM_POWER_STATUS status;
|
||||
if (!GetSystemPowerStatus(&status)) {
|
||||
LOG(ERROR) << "GetSystemPowerStatus failed: " << GetLastError();
|
||||
return false;
|
||||
}
|
||||
return (status.ACLineStatus == 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace base
|
||||
// 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.
|
||||
|
||||
#include "base/system_monitor.h"
|
||||
|
||||
namespace base {
|
||||
|
||||
void SystemMonitor::ProcessWmPowerBroadcastMessage(int event_id) {
|
||||
PowerEvent power_event;
|
||||
switch (event_id) {
|
||||
case PBT_APMPOWERSTATUSCHANGE: // The power status changed.
|
||||
power_event = POWER_STATE_EVENT;
|
||||
break;
|
||||
case PBT_APMRESUMEAUTOMATIC: // Non-user initiated resume from suspend.
|
||||
case PBT_APMRESUMESUSPEND: // User initiated resume from suspend.
|
||||
power_event = RESUME_EVENT;
|
||||
break;
|
||||
case PBT_APMSUSPEND: // System has been suspended.
|
||||
power_event = SUSPEND_EVENT;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
|
||||
// Other Power Events:
|
||||
// PBT_APMBATTERYLOW - removed in Vista.
|
||||
// PBT_APMOEMEVENT - removed in Vista.
|
||||
// PBT_APMQUERYSUSPEND - removed in Vista.
|
||||
// PBT_APMQUERYSUSPENDFAILED - removed in Vista.
|
||||
// PBT_APMRESUMECRITICAL - removed in Vista.
|
||||
// PBT_POWERSETTINGCHANGE - user changed the power settings.
|
||||
}
|
||||
ProcessPowerMessage(power_event);
|
||||
}
|
||||
|
||||
// Function to query the system to see if it is currently running on
|
||||
// battery power. Returns true if running on battery.
|
||||
bool SystemMonitor::IsBatteryPower() {
|
||||
SYSTEM_POWER_STATUS status;
|
||||
if (!GetSystemPowerStatus(&status)) {
|
||||
LOG(ERROR) << "GetSystemPowerStatus failed: " << GetLastError();
|
||||
return false;
|
||||
}
|
||||
return (status.ACLineStatus == 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace base
|
||||
|
||||
+7
-3
@@ -332,7 +332,9 @@ inline CancelableTask* NewRunnableMethod(T* object, Method method) {
|
||||
|
||||
template <class T, class Method, class A>
|
||||
inline CancelableTask* NewRunnableMethod(T* object, Method method, const A& a) {
|
||||
return new RunnableMethod<T, Method, Tuple1<A> >(object, method, MakeTuple(a));
|
||||
return new RunnableMethod<T, Method, Tuple1<A> >(object,
|
||||
method,
|
||||
MakeTuple(a));
|
||||
}
|
||||
|
||||
template <class T, class Method, class A, class B>
|
||||
@@ -435,7 +437,8 @@ inline CancelableTask* NewRunnableFunction(Function function, const A& a) {
|
||||
template <class Function, class A, class B>
|
||||
inline CancelableTask* NewRunnableFunction(Function function,
|
||||
const A& a, const B& b) {
|
||||
return new RunnableFunction<Function, Tuple2<A, B> >(function, MakeTuple(a, b));
|
||||
return new RunnableFunction<Function, Tuple2<A, B> >(function,
|
||||
MakeTuple(a, b));
|
||||
}
|
||||
|
||||
template <class Function, class A, class B, class C>
|
||||
@@ -587,7 +590,8 @@ struct Callback1 {
|
||||
};
|
||||
|
||||
template <class T, typename Arg1>
|
||||
typename Callback1<Arg1>::Type* NewCallback(T* object, void (T::*method)(Arg1)) {
|
||||
typename Callback1<Arg1>::Type* NewCallback(T* object,
|
||||
void (T::*method)(Arg1)) {
|
||||
return new CallbackImpl<T, void (T::*)(Arg1), Tuple1<Arg1> >(object, method);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
// are synchronized somehow, it calls a method to "protect" from
|
||||
// a "protected" method
|
||||
//
|
||||
// In this case the macro DFAKE_SCOPED_RECURSIVE_LOCK
|
||||
// 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
|
||||
//
|
||||
@@ -223,7 +223,7 @@ class ThreadCollisionWarner {
|
||||
// call EnterSelf or Enter.
|
||||
void Leave();
|
||||
|
||||
// This stores the thread id that is inside the critical section, if the
|
||||
// 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_;
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// WARNING: Thread local storage is a bit tricky to get right. Please make
|
||||
// sure that this is really the proper solution for what you're trying to
|
||||
// achieve. Don't prematurely optimize, most likely you can just use a Lock.
|
||||
//
|
||||
//
|
||||
// These classes implement a warpper around the platform's TLS storage
|
||||
// mechanism. On construction, they will allocate a TLS slot, and free the
|
||||
// TLS slot on destruction. No memory management (creation or destruction) is
|
||||
|
||||
@@ -18,7 +18,7 @@ bool ThreadLocalStorage::Slot::Initialize(TLSDestructorFunc destructor) {
|
||||
NOTREACHED();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
initialized_ = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ class SetThreadLocal : public ThreadLocalTesterBase {
|
||||
SetThreadLocal(TLPType* tlp, base::WaitableEvent* done)
|
||||
: ThreadLocalTesterBase(tlp, done), val_(NULL) { }
|
||||
~SetThreadLocal() { }
|
||||
|
||||
|
||||
void set_value(ThreadLocalTesterBase* val) { val_ = val; }
|
||||
|
||||
virtual void Run() {
|
||||
@@ -46,7 +46,7 @@ class GetThreadLocal : public ThreadLocalTesterBase {
|
||||
GetThreadLocal(TLPType* tlp, base::WaitableEvent* done)
|
||||
: ThreadLocalTesterBase(tlp, done), ptr_(NULL) { }
|
||||
~GetThreadLocal() { }
|
||||
|
||||
|
||||
void set_ptr(ThreadLocalTesterBase** ptr) { ptr_ = ptr; }
|
||||
|
||||
virtual void Run() {
|
||||
@@ -70,7 +70,7 @@ TEST(ThreadLocalTest, Pointer) {
|
||||
tp2.Start();
|
||||
|
||||
base::ThreadLocalPointer<ThreadLocalTesterBase> tlp;
|
||||
|
||||
|
||||
static ThreadLocalTesterBase* const kBogusPointer =
|
||||
reinterpret_cast<ThreadLocalTesterBase*>(0x1234);
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ std::wstring TimeFormat(const DateFormat* formatter,
|
||||
const Time& time) {
|
||||
DCHECK(formatter);
|
||||
UnicodeString date_string;
|
||||
|
||||
|
||||
formatter->format(static_cast<UDate>(time.ToDoubleT() * 1000), date_string);
|
||||
std::wstring output;
|
||||
bool success = UTF16ToWide(date_string.getBuffer(), date_string.length(),
|
||||
|
||||
+2
-2
@@ -62,11 +62,11 @@ void Time::Explode(bool is_local, Exploded* exploded) const {
|
||||
CFAbsoluteTime seconds =
|
||||
(static_cast<double>(us_) / kMicrosecondsPerSecond) -
|
||||
kCFAbsoluteTimeIntervalSince1970;
|
||||
|
||||
|
||||
scoped_cftyperef<CFTimeZoneRef>
|
||||
time_zone(is_local ? CFTimeZoneCopySystem() : NULL);
|
||||
CFGregorianDate date = CFAbsoluteTimeGetGregorianDate(seconds, time_zone);
|
||||
|
||||
|
||||
exploded->year = date.year;
|
||||
exploded->month = date.month;
|
||||
exploded->day_of_month = date.day;
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#include "base/time.h"
|
||||
|
||||
#ifdef OS_MACOSX
|
||||
#include <mach/mach_time.h>
|
||||
#ifdef OS_MACOSX
|
||||
#include <mach/mach_time.h>
|
||||
#endif
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
@@ -126,9 +126,9 @@ TimeTicks TimeTicks::Now() {
|
||||
uint64_t absolute_micro;
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
static mach_timebase_info_data_t timebase_info;
|
||||
if (timebase_info.denom == 0) {
|
||||
// Zero-initialization of statics guarantees that denom will be 0 before
|
||||
static mach_timebase_info_data_t timebase_info;
|
||||
if (timebase_info.denom == 0) {
|
||||
// Zero-initialization of statics guarantees that denom will be 0 before
|
||||
// calling mach_timebase_info. mach_timebase_info will never set denom to
|
||||
// 0 as that would be invalid, so the zero-check can be used to determine
|
||||
// whether mach_timebase_info has already been called. This is
|
||||
|
||||
+5
-5
@@ -23,8 +23,8 @@
|
||||
// applications on the system. By default, precision is only 15.5ms.
|
||||
// Unfortunately, we don't want to call timeBeginPeriod because we don't
|
||||
// want to affect other applications. Further, on mobile platforms, use of
|
||||
// faster multimedia timers can hurt battery life. See the intel
|
||||
// article about this here:
|
||||
// faster multimedia timers can hurt battery life. See the intel
|
||||
// article about this here:
|
||||
// http://softwarecommunity.intel.com/articles/eng/1086.htm
|
||||
//
|
||||
// To work around all this, we're going to generally use timeGetTime(). We
|
||||
@@ -224,7 +224,7 @@ class NowSingleton : public base::SystemMonitor::PowerObserver {
|
||||
public:
|
||||
NowSingleton()
|
||||
: rollover_(TimeDelta::FromMilliseconds(0)),
|
||||
last_seen_(0),
|
||||
last_seen_(0),
|
||||
hi_res_clock_enabled_(false) {
|
||||
base::SystemMonitor* system = base::SystemMonitor::Get();
|
||||
system->AddObserver(this);
|
||||
@@ -307,9 +307,9 @@ class NowSingleton : public base::SystemMonitor::PowerObserver {
|
||||
// retrieve and more reliable.
|
||||
class HighResNowSingleton {
|
||||
public:
|
||||
HighResNowSingleton()
|
||||
HighResNowSingleton()
|
||||
: ticks_per_microsecond_(0.0),
|
||||
skew_(0) {
|
||||
skew_(0) {
|
||||
InitializeClock();
|
||||
|
||||
// On Athlon X2 CPUs (e.g. model 15) QueryPerformanceCounter is
|
||||
|
||||
@@ -175,9 +175,9 @@ TEST(TimeTicks, TimerPerformance) {
|
||||
};
|
||||
// Cheating a bit here: assumes sizeof(TimeTicks) == sizeof(Time)
|
||||
// in order to create a single test case list.
|
||||
COMPILE_ASSERT(sizeof(TimeTicks) == sizeof(Time),
|
||||
COMPILE_ASSERT(sizeof(TimeTicks) == sizeof(Time),
|
||||
test_only_works_with_same_sizes);
|
||||
TestCase cases[] = {
|
||||
TestCase cases[] = {
|
||||
{ reinterpret_cast<TestFunc>(Time::Now), "Time::Now" },
|
||||
{ TimeTicks::Now, "TimeTicks::Now" },
|
||||
{ TimeTicks::HighResNow, "TimeTicks::HighResNow" },
|
||||
@@ -193,11 +193,11 @@ TEST(TimeTicks, TimerPerformance) {
|
||||
// Turning off the check for acceptible delays. Without this check,
|
||||
// the test really doesn't do much other than measure. But the
|
||||
// measurements are still useful for testing timers on various platforms.
|
||||
// The reason to remove the check is because the tests run on many
|
||||
// The reason to remove the check is because the tests run on many
|
||||
// buildbots, some of which are VMs. These machines can run horribly
|
||||
// slow, and there is really no value for checking against a max timer.
|
||||
//EXPECT_LT((stop - start).InMilliseconds(), kMaxTime);
|
||||
printf("%s: %1.2fus per call\n", cases[test_case].description,
|
||||
printf("%s: %1.2fus per call\n", cases[test_case].description,
|
||||
(stop - start).InMillisecondsF() * 1000 / kLoops);
|
||||
test_case++;
|
||||
}
|
||||
|
||||
@@ -8,9 +8,6 @@
|
||||
|
||||
namespace base {
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// BaseTimer_Helper
|
||||
|
||||
void BaseTimer_Helper::OrphanDelayedTask() {
|
||||
if (delayed_task_) {
|
||||
delayed_task_->timer_ = NULL;
|
||||
|
||||
+1
-1
@@ -170,7 +170,7 @@ class BaseTimer : public BaseTimer_Helper {
|
||||
self->delayed_task_ = NULL;
|
||||
// By now the delayed_task_ in the Timer does not point to us anymore.
|
||||
// We should reset our own timer_ because the Timer can not do this
|
||||
// for us in its destructor.
|
||||
// for us in its destructor.
|
||||
timer_ = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ void RunTest_OneShotTimer_Cancel(MessageLoop::Type message_loop_type) {
|
||||
|
||||
// Now start the timer.
|
||||
a->Start();
|
||||
|
||||
|
||||
bool did_run_b = false;
|
||||
OneShotTimerTester b(&did_run_b);
|
||||
b.Start();
|
||||
|
||||
@@ -102,22 +102,22 @@ bool TraceLog::OpenLogFile() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void TraceLog::Trace(const std::string& name,
|
||||
void TraceLog::Trace(const std::string& name,
|
||||
EventType type,
|
||||
const void* id,
|
||||
const std::wstring& extra,
|
||||
const char* file,
|
||||
const char* file,
|
||||
int line) {
|
||||
if (!enabled_)
|
||||
return;
|
||||
Trace(name, type, id, WideToUTF8(extra), file, line);
|
||||
}
|
||||
|
||||
void TraceLog::Trace(const std::string& name,
|
||||
void TraceLog::Trace(const std::string& name,
|
||||
EventType type,
|
||||
const void* id,
|
||||
const std::string& extra,
|
||||
const char* file,
|
||||
const char* file,
|
||||
int line) {
|
||||
if (!enabled_)
|
||||
return;
|
||||
@@ -129,7 +129,7 @@ void TraceLog::Trace(const std::string& name,
|
||||
#endif
|
||||
TimeDelta delta = tick - trace_start_time_;
|
||||
int64 usec = delta.InMicroseconds();
|
||||
std::string msg =
|
||||
std::string msg =
|
||||
StringPrintf("{'pid':'0x%lx', 'tid':'0x%lx', 'type':'%s', "
|
||||
"'name':'%s', 'id':'0x%lx', 'extra':'%s', 'file':'%s', "
|
||||
"'line_number':'%d', 'usec_begin': %I64d},\n",
|
||||
|
||||
@@ -86,17 +86,17 @@ class TraceLog {
|
||||
static void StopTracing();
|
||||
|
||||
// Log a trace event of (name, type, id) with the optional extra string.
|
||||
void Trace(const std::string& name,
|
||||
void Trace(const std::string& name,
|
||||
EventType type,
|
||||
const void* id,
|
||||
const std::wstring& extra,
|
||||
const char* file,
|
||||
const char* file,
|
||||
int line);
|
||||
void Trace(const std::string& name,
|
||||
void Trace(const std::string& name,
|
||||
EventType type,
|
||||
const void* id,
|
||||
const std::string& extra,
|
||||
const char* file,
|
||||
const char* file,
|
||||
int line);
|
||||
|
||||
private:
|
||||
|
||||
+12
-4
@@ -394,7 +394,9 @@ inline void DispatchToMethod(ObjT* obj, Method method, const Tuple1<A>& arg) {
|
||||
}
|
||||
|
||||
template<class ObjT, class Method, class A, class B>
|
||||
inline void DispatchToMethod(ObjT* obj, Method method, const Tuple2<A, B>& arg) {
|
||||
inline void DispatchToMethod(ObjT* obj,
|
||||
Method method,
|
||||
const Tuple2<A, B>& arg) {
|
||||
(obj->*method)(arg.a, arg.b);
|
||||
}
|
||||
|
||||
@@ -478,7 +480,9 @@ inline void DispatchToFunction(Function function,
|
||||
// Dispatchers with 0 out param (as a Tuple0).
|
||||
|
||||
template <class ObjT, class Method>
|
||||
inline void DispatchToMethod(ObjT* obj, Method method, const Tuple0& arg, Tuple0*) {
|
||||
inline void DispatchToMethod(ObjT* obj,
|
||||
Method method,
|
||||
const Tuple0& arg, Tuple0*) {
|
||||
(obj->*method)();
|
||||
}
|
||||
|
||||
@@ -488,12 +492,16 @@ inline void DispatchToMethod(ObjT* obj, Method method, const A& arg, Tuple0*) {
|
||||
}
|
||||
|
||||
template <class ObjT, class Method, class A>
|
||||
inline void DispatchToMethod(ObjT* obj, Method method, const Tuple1<A>& arg, Tuple0*) {
|
||||
inline void DispatchToMethod(ObjT* obj,
|
||||
Method method,
|
||||
const Tuple1<A>& arg, Tuple0*) {
|
||||
(obj->*method)(arg.a);
|
||||
}
|
||||
|
||||
template<class ObjT, class Method, class A, class B>
|
||||
inline void DispatchToMethod(ObjT* obj, Method method, const Tuple2<A, B>& arg, Tuple0*) {
|
||||
inline void DispatchToMethod(ObjT* obj,
|
||||
Method method,
|
||||
const Tuple2<A, B>& arg, Tuple0*) {
|
||||
(obj->*method)(arg.a, arg.b);
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ TEST(ValuesTest, List) {
|
||||
mixed_list->Set(2, Value::CreateRealValue(88.8));
|
||||
mixed_list->Set(3, Value::CreateStringValue("foo"));
|
||||
ASSERT_EQ(4u, mixed_list->GetSize());
|
||||
|
||||
|
||||
Value *value = NULL;
|
||||
bool bool_value = false;
|
||||
int int_value = 0;
|
||||
@@ -373,7 +373,7 @@ TEST(ValuesTest, DeepCopy) {
|
||||
ASSERT_TRUE(copy_dict->Get(L"wstring", ©_wstring));
|
||||
ASSERT_TRUE(copy_wstring);
|
||||
ASSERT_NE(copy_wstring, original_wstring);
|
||||
ASSERT_TRUE(copy_wstring->IsType(Value::TYPE_STRING));
|
||||
ASSERT_TRUE(copy_wstring->IsType(Value::TYPE_STRING));
|
||||
ASSERT_TRUE(copy_wstring->GetAsString(©_string_value));
|
||||
ASSERT_TRUE(copy_wstring->GetAsString(©_wstring_value));
|
||||
ASSERT_EQ(std::string("peek-a-boo"), copy_string_value);
|
||||
|
||||
+1
-1
@@ -62,7 +62,7 @@ const std::string Version::GetString() const {
|
||||
bool Version::InitFromString(const std::string& version_str) {
|
||||
std::vector<std::string> numbers;
|
||||
SplitString(version_str, '.', &numbers);
|
||||
for (std::vector<std::string>::iterator i = numbers.begin();
|
||||
for (std::vector<std::string>::iterator i = numbers.begin();
|
||||
i != numbers.end(); ++i) {
|
||||
int num;
|
||||
if (!StringToInt(*i, &num))
|
||||
|
||||
@@ -54,7 +54,7 @@ bool WordIterator::Init() {
|
||||
int32_t destLength;
|
||||
u_strFromWCS(&chars_[0], chars_.size(), &destLength, string_.data(),
|
||||
string_.length(), &error);
|
||||
|
||||
|
||||
iter_ = ubrk_open(break_type, NULL, &chars_[0], destLength, &status);
|
||||
#endif
|
||||
if (U_FAILURE(status)) {
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário