diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-26 21:48:00 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-26 21:48:00 +0000 |
commit | a42d4638f0335dbfd14c1c9f6b05a7b09703a78e (patch) | |
tree | 96d7687e21b42cd5b5de4b23b2a1da472572e60c | |
parent | 1b5eee12138e3963415453974c824472429c4d80 (diff) | |
download | chromium_src-a42d4638f0335dbfd14c1c9f6b05a7b09703a78e.zip chromium_src-a42d4638f0335dbfd14c1c9f6b05a7b09703a78e.tar.gz chromium_src-a42d4638f0335dbfd14c1c9f6b05a7b09703a78e.tar.bz2 |
Replace most LOG/CHECK statements with DLOG/DCHECK statements in base.
[ Reland of 107042 http://codereview.chromium.org/8368009 ]
I tried hard not to change CHECKs that had side effects. I kept fatal checks
that seemed security or debugging-info (in crash reports) sensitive, and ones
that seems particularly well-conceived.
Review URL: http://codereview.chromium.org/8341026
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107434 0039d316-1c4b-4281-b951-d872f2087c98
56 files changed, 741 insertions, 240 deletions
diff --git a/base/allocator/allocator_shim.cc b/base/allocator/allocator_shim.cc index b7973e8..97bbf90 100644 --- a/base/allocator/allocator_shim.cc +++ b/base/allocator/allocator_shim.cc @@ -297,7 +297,7 @@ void SetupSubprocessAllocator() { char* secondary_value = secondary_length ? buffer : "TCMALLOC"; // Force renderer (or other subprocesses) to use secondary_value. int ret_val = _putenv_s(primary_name, secondary_value); - CHECK_EQ(0, ret_val); + DCHECK_EQ(0, ret_val); } #endif // ENABLE_DYNAMIC_ALLOCATOR_SWITCHING } diff --git a/base/allocator/allocator_unittests.cc b/base/allocator/allocator_unittests.cc index d935cf9..d6556ce 100644 --- a/base/allocator/allocator_unittests.cc +++ b/base/allocator/allocator_unittests.cc @@ -398,16 +398,16 @@ TEST(Allocators, Realloc1) { for (int s = 0; s < sizeof(start_sizes)/sizeof(*start_sizes); ++s) { void* p = malloc(start_sizes[s]); - CHECK(p); + ASSERT_TRUE(p); // The larger the start-size, the larger the non-reallocing delta. for (int d = 0; d < s*2; ++d) { void* new_p = realloc(p, start_sizes[s] + deltas[d]); - CHECK_EQ(p, new_p); // realloc should not allocate new memory + ASSERT_EQ(p, new_p); // realloc should not allocate new memory } // Test again, but this time reallocing smaller first. for (int d = 0; d < s*2; ++d) { void* new_p = realloc(p, start_sizes[s] - deltas[d]); - CHECK_EQ(p, new_p); // realloc should not allocate new memory + ASSERT_EQ(p, new_p); // realloc should not allocate new memory } free(p); } diff --git a/base/android/jni_array.cc b/base/android/jni_array.cc index 08cb42e..ae2f185 100644 --- a/base/android/jni_array.cc +++ b/base/android/jni_array.cc @@ -17,7 +17,7 @@ jbyteArray ToJavaByteArray(JNIEnv* env, size_t len) { jbyteArray byte_array = env->NewByteArray(len); CheckException(env); - CHECK(byte_array); + DCHECK(byte_array); jbyte* elements = env->GetByteArrayElements(byte_array, NULL); memcpy(elements, bytes, len); diff --git a/base/base_paths_linux.cc b/base/base_paths_linux.cc index 82f4841..36d5ee7 100644 --- a/base/base_paths_linux.cc +++ b/base/base_paths_linux.cc @@ -88,8 +88,8 @@ bool PathProviderPosix(int key, FilePath* result) { *result = path; return true; } else { - LOG(WARNING) << "CR_SOURCE_ROOT is set, but it appears to not " - << "point to the correct source root directory."; + DLOG(WARNING) << "CR_SOURCE_ROOT is set, but it appears to not " + << "point to the correct source root directory."; } } // On POSIX, unit tests execute two levels deep from the source root. @@ -118,8 +118,8 @@ bool PathProviderPosix(int key, FilePath* result) { *result = path; return true; } - LOG(ERROR) << "Couldn't find your source root. " - << "Try running from your chromium/src directory."; + DLOG(ERROR) << "Couldn't find your source root. " + << "Try running from your chromium/src directory."; return false; } case base::DIR_CACHE: diff --git a/base/command_line.cc b/base/command_line.cc index 22977af..0237ffe 100644 --- a/base/command_line.cc +++ b/base/command_line.cc @@ -268,8 +268,8 @@ std::string CommandLine::GetSwitchValueASCII( const std::string& switch_string) const { StringType value = GetSwitchValueNative(switch_string); if (!IsStringASCII(value)) { - LOG(WARNING) << "Value of switch (" << switch_string << ") must be ASCII."; - return ""; + DLOG(WARNING) << "Value of switch (" << switch_string << ") must be ASCII."; + return std::string(); } #if defined(OS_WIN) return WideToASCII(value); @@ -394,8 +394,8 @@ void CommandLine::ParseFromString(const std::wstring& command_line) { wchar_t** args = NULL; args = ::CommandLineToArgvW(command_line_string.c_str(), &num_args); - PLOG_IF(FATAL, !args) << "CommandLineToArgvW failed on command line: " << - command_line; + DPLOG_IF(FATAL, !args) << "CommandLineToArgvW failed on command line: " + << command_line; InitFromArgv(num_args, args); LocalFree(args); } diff --git a/base/debug/debugger.cc b/base/debug/debugger.cc index 3777fa1..a0d8a92 100644 --- a/base/debug/debugger.cc +++ b/base/debug/debugger.cc @@ -15,8 +15,8 @@ bool WaitForDebugger(int wait_seconds, bool silent) { #if defined(OS_ANDROID) // The pid from which we know which process to attach to are not output by // android ddms, so we have to print it out explicitly. - LOG(INFO) << "DebugUtil::WaitForDebugger(pid=" << static_cast<int>(getpid()) - << ")"; + DLOG(INFO) << "DebugUtil::WaitForDebugger(pid=" << static_cast<int>(getpid()) + << ")"; #endif for (int i = 0; i < wait_seconds * 10; ++i) { if (BeingDebugged()) { diff --git a/base/debug/trace_event.cc b/base/debug/trace_event.cc index 8b24cca..63f057f 100644 --- a/base/debug/trace_event.cc +++ b/base/debug/trace_event.cc @@ -322,7 +322,7 @@ TraceLog::~TraceLog() { const TraceCategory* TraceLog::GetCategory(const char* name) { TraceLog* tracelog = GetInstance(); if (!tracelog){ - CHECK(!g_category_already_shutdown->enabled); + DCHECK(!g_category_already_shutdown->enabled); return g_category_already_shutdown; } return tracelog->GetCategoryInternal(name); diff --git a/base/dir_reader_posix_unittest.cc b/base/dir_reader_posix_unittest.cc index 5aefb9a..a6adfdb 100644 --- a/base/dir_reader_posix_unittest.cc +++ b/base/dir_reader_posix_unittest.cc @@ -27,10 +27,10 @@ TEST(DirReaderPosixUnittest, Read) { char kDirTemplate[] = "/tmp/org.chromium.dir-reader-posix-XXXXXX"; const char* dir = mkdtemp(kDirTemplate); - CHECK(dir); + ASSERT_TRUE(dir); const int prev_wd = open(".", O_RDONLY | O_DIRECTORY); - CHECK_GE(prev_wd, 0); + DCHECK_GE(prev_wd, 0); PCHECK(chdir(dir) == 0); diff --git a/base/event_recorder_win.cc b/base/event_recorder_win.cc index b2473809..11bf0f0 100644 --- a/base/event_recorder_win.cc +++ b/base/event_recorder_win.cc @@ -24,13 +24,13 @@ EventRecorder* EventRecorder::current_ = NULL; LRESULT CALLBACK StaticRecordWndProc(int nCode, WPARAM wParam, LPARAM lParam) { - CHECK(EventRecorder::current()); + DCHECK(EventRecorder::current()); return EventRecorder::current()->RecordWndProc(nCode, wParam, lParam); } LRESULT CALLBACK StaticPlaybackWndProc(int nCode, WPARAM wParam, LPARAM lParam) { - CHECK(EventRecorder::current()); + DCHECK(EventRecorder::current()); return EventRecorder::current()->PlaybackWndProc(nCode, wParam, lParam); } diff --git a/base/file_util.cc b/base/file_util.cc index e9f1d4e..dc186d9 100644 --- a/base/file_util.cc +++ b/base/file_util.cc @@ -342,7 +342,7 @@ bool MemoryMappedFile::MapFileToMemory(const FilePath& file_name) { NULL, NULL); if (file_ == base::kInvalidPlatformFileValue) { - LOG(ERROR) << "Couldn't open " << file_name.value(); + DLOG(ERROR) << "Couldn't open " << file_name.value(); return false; } diff --git a/base/file_util.h b/base/file_util.h index b0c2459..90ec1ae 100644 --- a/base/file_util.h +++ b/base/file_util.h @@ -426,7 +426,7 @@ class ScopedFDClose { inline void operator()(int* x) const { if (x && *x >= 0) { if (HANDLE_EINTR(close(*x)) < 0) - PLOG(ERROR) << "close"; + DPLOG(ERROR) << "close"; } } }; diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc index 8d9fb29..c365869a 100644 --- a/base/file_util_posix.cc +++ b/base/file_util_posix.cc @@ -95,33 +95,33 @@ bool VerifySpecificPathControlledByUser(const FilePath& path, const std::set<gid_t>& group_gids) { stat_wrapper_t stat_info; if (CallLstat(path.value().c_str(), &stat_info) != 0) { - PLOG(ERROR) << "Failed to get information on path " - << path.value(); + DPLOG(ERROR) << "Failed to get information on path " + << path.value(); return false; } if (S_ISLNK(stat_info.st_mode)) { - LOG(ERROR) << "Path " << path.value() + DLOG(ERROR) << "Path " << path.value() << " is a symbolic link."; return false; } if (stat_info.st_uid != owner_uid) { - LOG(ERROR) << "Path " << path.value() - << " is owned by the wrong user."; + DLOG(ERROR) << "Path " << path.value() + << " is owned by the wrong user."; return false; } if ((stat_info.st_mode & S_IWGRP) && !ContainsKey(group_gids, stat_info.st_gid)) { - LOG(ERROR) << "Path " << path.value() - << " is writable by an unprivileged group."; + DLOG(ERROR) << "Path " << path.value() + << " is writable by an unprivileged group."; return false; } if (stat_info.st_mode & S_IWOTH) { - LOG(ERROR) << "Path " << path.value() - << " is writable by any user."; + DLOG(ERROR) << "Path " << path.value() + << " is writable by any user."; return false; } @@ -173,7 +173,7 @@ int CountFilesCreatedAfter(const FilePath& path, stat_wrapper_t st; int test = CallStat(path.Append(ent->d_name).value().c_str(), &st); if (test != 0) { - PLOG(ERROR) << "stat64 failed"; + DPLOG(ERROR) << "stat64 failed"; continue; } // Here, we use Time::TimeT(), which discards microseconds. This @@ -322,8 +322,8 @@ bool CopyDirectory(const FilePath& from_path, FileEnumerator::FindInfo info; FilePath current = from_path; if (stat(from_path.value().c_str(), &info.stat) < 0) { - LOG(ERROR) << "CopyDirectory() couldn't stat source directory: " << - from_path.value() << " errno = " << errno; + DLOG(ERROR) << "CopyDirectory() couldn't stat source directory: " + << from_path.value() << " errno = " << errno; success = false; } struct stat to_path_stat; @@ -353,19 +353,19 @@ bool CopyDirectory(const FilePath& from_path, if (S_ISDIR(info.stat.st_mode)) { if (mkdir(target_path.value().c_str(), info.stat.st_mode & 01777) != 0 && errno != EEXIST) { - LOG(ERROR) << "CopyDirectory() couldn't create directory: " << - target_path.value() << " errno = " << errno; + DLOG(ERROR) << "CopyDirectory() couldn't create directory: " + << target_path.value() << " errno = " << errno; success = false; } } else if (S_ISREG(info.stat.st_mode)) { if (!CopyFile(current, target_path)) { - LOG(ERROR) << "CopyDirectory() couldn't create file: " << - target_path.value(); + DLOG(ERROR) << "CopyDirectory() couldn't create file: " + << target_path.value(); success = false; } } else { - LOG(WARNING) << "CopyDirectory() skipping non-regular file: " << - current.value(); + DLOG(WARNING) << "CopyDirectory() skipping non-regular file: " + << current.value(); } current = traversal.Next(); @@ -511,8 +511,8 @@ static bool CreateTemporaryDirInDirImpl(const FilePath& base_dir, const FilePath::StringType& name_tmpl, FilePath* new_dir) { base::ThreadRestrictions::AssertIOAllowed(); // For call to mkdtemp(). - CHECK(name_tmpl.find("XXXXXX") != FilePath::StringType::npos) - << "Directory name template must contain \"XXXXXX\"."; + DCHECK(name_tmpl.find("XXXXXX") != FilePath::StringType::npos) + << "Directory name template must contain \"XXXXXX\"."; FilePath sub_dir = base_dir.Append(name_tmpl); std::string sub_dir_string = sub_dir.value(); @@ -823,8 +823,8 @@ bool FileEnumerator::ReadDirectory(std::vector<DirectoryEntryInfo>* entries, // Print the stat() error message unless it was ENOENT and we're // following symlinks. if (!(errno == ENOENT && !show_links)) { - PLOG(ERROR) << "Couldn't stat " - << source.Append(dent->d_name).value(); + DPLOG(ERROR) << "Couldn't stat " + << source.Append(dent->d_name).value(); } memset(&info.stat, 0, sizeof(info.stat)); } @@ -849,7 +849,7 @@ bool MemoryMappedFile::MapFileToMemoryInternal() { struct stat file_stat; if (fstat(file_, &file_stat) == base::kInvalidPlatformFileValue) { - LOG(ERROR) << "Couldn't fstat " << file_ << ", errno " << errno; + DLOG(ERROR) << "Couldn't fstat " << file_ << ", errno " << errno; return false; } length_ = file_stat.st_size; @@ -857,7 +857,7 @@ bool MemoryMappedFile::MapFileToMemoryInternal() { data_ = static_cast<uint8*>( mmap(NULL, length_, PROT_READ, MAP_SHARED, file_, 0)); if (data_ == MAP_FAILED) - LOG(ERROR) << "Couldn't mmap " << file_ << ", errno " << errno; + DLOG(ERROR) << "Couldn't mmap " << file_ << ", errno " << errno; return data_ != MAP_FAILED; } @@ -927,7 +927,7 @@ FilePath GetHomeDir() { return FilePath(home_dir); #if defined(OS_ANDROID) - LOG(WARNING) << "OS_ANDROID: Home directory lookup not yet implemented."; + DLOG(WARNING) << "OS_ANDROID: Home directory lookup not yet implemented."; #else // g_get_home_dir calls getpwent, which can fall through to LDAP calls. base::ThreadRestrictions::AssertIOAllowed(); @@ -998,8 +998,8 @@ bool VerifyPathControlledByUser(const FilePath& base, uid_t owner_uid, const std::set<gid_t>& group_gids) { if (base != path && !base.IsParent(path)) { - LOG(ERROR) << "|base| must be a subdirectory of |path|. base = \"" - << base.value() << "\", path = \"" << path.value() << "\""; + DLOG(ERROR) << "|base| must be a subdirectory of |path|. base = \"" + << base.value() << "\", path = \"" << path.value() << "\""; return false; } @@ -1015,8 +1015,8 @@ bool VerifyPathControlledByUser(const FilePath& base, // |base| must be a subpath of |path|, so all components should match. // If these CHECKs fail, look at the test that base is a parent of // path at the top of this function. - CHECK(ip != path_components.end()); - CHECK(*ip == *ib); + DCHECK(ip != path_components.end()); + DCHECK(*ip == *ib); } FilePath current_path = base; @@ -1050,8 +1050,8 @@ bool VerifyPathControlledByAdmin(const FilePath& path) { for (int i = 0, ie = arraysize(kAdminGroupNames); i < ie; ++i) { struct group *group_record = getgrnam(kAdminGroupNames[i]); if (!group_record) { - PLOG(ERROR) << "Could not get the group ID of group \"" - << kAdminGroupNames[i] << "\"."; + DPLOG(ERROR) << "Could not get the group ID of group \"" + << kAdminGroupNames[i] << "\"."; continue; } diff --git a/base/file_util_win.cc b/base/file_util_win.cc index 19e15fc..8d9fbdef 100644 --- a/base/file_util_win.cc +++ b/base/file_util_win.cc @@ -44,7 +44,7 @@ bool DevicePathToDriveLetterPath(const FilePath& device_path, const int kDriveMappingSize = 1024; wchar_t drive_mapping[kDriveMappingSize] = {'\0'}; if (!::GetLogicalDriveStrings(kDriveMappingSize - 1, drive_mapping)) { - LOG(ERROR) << "Failed to get drive mapping."; + DLOG(ERROR) << "Failed to get drive mapping."; return false; } @@ -603,13 +603,13 @@ bool CreateTemporaryFileInDir(const FilePath& dir, wchar_t temp_name[MAX_PATH + 1]; if (!GetTempFileName(dir.value().c_str(), L"", 0, temp_name)) { - PLOG(WARNING) << "Failed to get temporary file name in " << dir.value(); + DPLOG(WARNING) << "Failed to get temporary file name in " << dir.value(); return false; } DWORD path_len = GetLongPathName(temp_name, temp_name, MAX_PATH); if (path_len > MAX_PATH + 1 || path_len == 0) { - PLOG(WARNING) << "Failed to get long path name for " << temp_name; + DPLOG(WARNING) << "Failed to get long path name for " << temp_name; return false; } @@ -667,8 +667,8 @@ bool CreateDirectory(const FilePath& full_path) { << "directory already exists."; return true; } - LOG(WARNING) << "CreateDirectory(" << full_path_str << "), " - << "conflicts with existing file."; + DLOG(WARNING) << "CreateDirectory(" << full_path_str << "), " + << "conflicts with existing file."; return false; } @@ -695,8 +695,8 @@ bool CreateDirectory(const FilePath& full_path) { // race to create the same directory. return true; } else { - LOG(WARNING) << "Failed to create directory " << full_path_str - << ", last error is " << error_code << "."; + DLOG(WARNING) << "Failed to create directory " << full_path_str + << ", last error is " << error_code << "."; return false; } } else { @@ -773,8 +773,8 @@ int WriteFile(const FilePath& filename, const char* data, int size) { 0, NULL)); if (!file) { - LOG(WARNING) << "CreateFile failed for path " << filename.value() - << " error code=" << GetLastError(); + DLOG(WARNING) << "CreateFile failed for path " << filename.value() + << " error code=" << GetLastError(); return -1; } @@ -785,12 +785,12 @@ int WriteFile(const FilePath& filename, const char* data, int size) { if (!result) { // WriteFile failed. - LOG(WARNING) << "writing file " << filename.value() - << " failed, error code=" << GetLastError(); + DLOG(WARNING) << "writing file " << filename.value() + << " failed, error code=" << GetLastError(); } else { // Didn't write all the bytes. - LOG(WARNING) << "wrote" << written << " bytes to " << - filename.value() << " expected " << size; + DLOG(WARNING) << "wrote" << written << " bytes to " + << filename.value() << " expected " << size; } return -1; } @@ -967,7 +967,7 @@ bool MemoryMappedFile::InitializeAsImageSection(const FilePath& file_name) { NULL, NULL); if (file_ == base::kInvalidPlatformFileValue) { - LOG(ERROR) << "Couldn't open " << file_name.value(); + DLOG(ERROR) << "Couldn't open " << file_name.value(); return false; } diff --git a/base/files/file_path_watcher_mac.cc b/base/files/file_path_watcher_mac.cc new file mode 100644 index 0000000..07a4dd2 --- /dev/null +++ b/base/files/file_path_watcher_mac.cc @@ -0,0 +1,494 @@ +// Copyright (c) 2011 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/files/file_path_watcher.h" + +#include <fcntl.h> +#include <sys/event.h> +#include <sys/param.h> + +#include <vector> + +#include "base/bind.h" +#include "base/file_util.h" +#include "base/message_loop.h" +#include "base/message_loop_proxy.h" +#include "base/stringprintf.h" + +namespace base { +namespace files { + +namespace { + +// Mac-specific file watcher implementation based on kqueue. +// Originally it was based on FSEvents so that the semantics were equivalent +// on Linux, OSX and Windows where it was able to detect: +// - file creation/deletion/modification in a watched directory +// - file creation/deletion/modification for a watched file +// - modifications to the paths to a watched object that would affect the +// object such as renaming/attibute changes etc. +// The FSEvents version did all of the above except handling attribute changes +// to path components. Unfortunately FSEvents appears to have an issue where the +// current implementation (Mac OS X 10.6.7) sometimes drops events and doesn't +// send notifications. See +// http://code.google.com/p/chromium/issues/detail?id=54822#c31 for source that +// will reproduce the problem. FSEvents also required having a CFRunLoop +// backing the thread that it was running on, that caused added complexity +// in the interfaces. +// The kqueue implementation will handle all of the items in the list above +// except for detecting modifications to files in a watched directory. It will +// detect the creation and deletion of files, just not the modification of +// files. It does however detect the attribute changes that the FSEvents impl +// would miss. +class FilePathWatcherImpl : public FilePathWatcher::PlatformDelegate, + public MessageLoopForIO::Watcher, + public MessageLoop::DestructionObserver { + public: + FilePathWatcherImpl() : kqueue_(-1) {} + virtual ~FilePathWatcherImpl() {} + + // MessageLoopForIO::Watcher overrides. + virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; + virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE; + + // MessageLoop::DestructionObserver overrides. + virtual void WillDestroyCurrentMessageLoop() OVERRIDE; + + // FilePathWatcher::PlatformDelegate overrides. + virtual bool Watch(const FilePath& path, + FilePathWatcher::Delegate* delegate) OVERRIDE; + virtual void Cancel() OVERRIDE; + + private: + class EventData { + public: + EventData(const FilePath& path, const FilePath::StringType& subdir) + : path_(path), subdir_(subdir) { } + FilePath path_; // Full path to this item. + FilePath::StringType subdir_; // Path to any sub item. + }; + typedef std::vector<struct kevent> EventVector; + + // Can only be called on |io_message_loop_|'s thread. + virtual void CancelOnMessageLoopThread() OVERRIDE; + + // Returns true if the kevent values are error free. + bool AreKeventValuesValid(struct kevent* kevents, int count); + + // Respond to a change of attributes of the path component represented by + // |event|. Sets |target_file_affected| to true if |target_| is affected. + // Sets |update_watches| to true if |events_| need to be updated. + void HandleAttributesChange(const EventVector::iterator& event, + bool* target_file_affected, + bool* update_watches); + + // Respond to a move of deletion of the path component represented by + // |event|. Sets |target_file_affected| to true if |target_| is affected. + // Sets |update_watches| to true if |events_| need to be updated. + void HandleDeleteOrMoveChange(const EventVector::iterator& event, + bool* target_file_affected, + bool* update_watches); + + // Respond to a creation of an item in the path component represented by + // |event|. Sets |target_file_affected| to true if |target_| is affected. + // Sets |update_watches| to true if |events_| need to be updated. + void HandleCreateItemChange(const EventVector::iterator& event, + bool* target_file_affected, + bool* update_watches); + + // Update |events_| with the current status of the system. + // Sets |target_file_affected| to true if |target_| is affected. + // Returns false if an error occurs. + bool UpdateWatches(bool* target_file_affected); + + // Fills |events| with one kevent per component in |path|. + // Returns the number of valid events created where a valid event is + // defined as one that has a ident (file descriptor) field != -1. + static int EventsForPath(FilePath path, EventVector *events); + + // Release a kevent generated by EventsForPath. + static void ReleaseEvent(struct kevent& event); + + // Returns a file descriptor that will not block the system from deleting + // the file it references. + static int FileDescriptorForPath(const FilePath& path); + + // Closes |*fd| and sets |*fd| to -1. + static void CloseFileDescriptor(int* fd); + + // Returns true if kevent has open file descriptor. + static bool IsKeventFileDescriptorOpen(const struct kevent& event) { + return event.ident != static_cast<uintptr_t>(-1); + } + + static EventData* EventDataForKevent(const struct kevent& event) { + return reinterpret_cast<EventData*>(event.udata); + } + + EventVector events_; + scoped_refptr<base::MessageLoopProxy> io_message_loop_; + MessageLoopForIO::FileDescriptorWatcher kqueue_watcher_; + scoped_refptr<FilePathWatcher::Delegate> delegate_; + FilePath target_; + int kqueue_; + + DISALLOW_COPY_AND_ASSIGN(FilePathWatcherImpl); +}; + +void FilePathWatcherImpl::ReleaseEvent(struct kevent& event) { + CloseFileDescriptor(reinterpret_cast<int*>(&event.ident)); + EventData* entry = EventDataForKevent(event); + delete entry; + event.udata = NULL; +} + +int FilePathWatcherImpl::EventsForPath(FilePath path, EventVector* events) { + DCHECK(MessageLoopForIO::current()); + // Make sure that we are working with a clean slate. + DCHECK(events->empty()); + + std::vector<FilePath::StringType> components; + path.GetComponents(&components); + + if (components.size() < 1) { + return -1; + } + + int last_existing_entry = 0; + FilePath built_path; + bool path_still_exists = true; + for(std::vector<FilePath::StringType>::iterator i = components.begin(); + i != components.end(); ++i) { + if (i == components.begin()) { + built_path = FilePath(*i); + } else { + built_path = built_path.Append(*i); + } + int fd = -1; + if (path_still_exists) { + fd = FileDescriptorForPath(built_path); + if (fd == -1) { + path_still_exists = false; + } else { + ++last_existing_entry; + } + } + FilePath::StringType subdir = (i != (components.end() - 1)) ? *(i + 1) : ""; + EventData* data = new EventData(built_path, subdir); + struct kevent event; + EV_SET(&event, fd, EVFILT_VNODE, (EV_ADD | EV_CLEAR | EV_RECEIPT), + (NOTE_DELETE | NOTE_WRITE | NOTE_ATTRIB | + NOTE_RENAME | NOTE_REVOKE | NOTE_EXTEND), 0, data); + events->push_back(event); + } + return last_existing_entry; +} + +int FilePathWatcherImpl::FileDescriptorForPath(const FilePath& path) { + return HANDLE_EINTR(open(path.value().c_str(), O_EVTONLY)); +} + +void FilePathWatcherImpl::CloseFileDescriptor(int *fd) { + if (*fd == -1) { + return; + } + + if (HANDLE_EINTR(close(*fd)) != 0) { + DPLOG(ERROR) << "close"; + } + *fd = -1; +} + +bool FilePathWatcherImpl::AreKeventValuesValid(struct kevent* kevents, + int count) { + if (count < 0) { + DPLOG(ERROR) << "kevent"; + return false; + } + bool valid = true; + for (int i = 0; i < count; ++i) { + if (kevents[i].flags & EV_ERROR && kevents[i].data) { + // Find the kevent in |events_| that matches the kevent with the error. + EventVector::iterator event = events_.begin(); + for (; event != events_.end(); ++event) { + if (event->ident == kevents[i].ident) { + break; + } + } + std::string path_name; + if (event != events_.end()) { + EventData* event_data = EventDataForKevent(*event); + if (event_data != NULL) { + path_name = event_data->path_.value(); + } + } + if (path_name.empty()) { + path_name = base::StringPrintf( + "fd %d", *reinterpret_cast<int*>(&kevents[i].ident)); + } + DLOG(ERROR) << "Error: " << kevents[i].data << " for " << path_name; + valid = false; + } + } + return valid; +} + +void FilePathWatcherImpl::HandleAttributesChange( + const EventVector::iterator& event, + bool* target_file_affected, + bool* update_watches) { + EventVector::iterator next_event = event + 1; + EventData* next_event_data = EventDataForKevent(*next_event); + // Check to see if the next item in path is still accessible. + int have_access = FileDescriptorForPath(next_event_data->path_); + if (have_access == -1) { + *target_file_affected = true; + *update_watches = true; + EventVector::iterator local_event(event); + for (; local_event != events_.end(); ++local_event) { + // Close all nodes from the event down. This has the side effect of + // potentially rendering other events in |updates| invalid. + // There is no need to remove the events from |kqueue_| because this + // happens as a side effect of closing the file descriptor. + CloseFileDescriptor(reinterpret_cast<int*>(&local_event->ident)); + } + } else { + CloseFileDescriptor(&have_access); + } +} + +void FilePathWatcherImpl::HandleDeleteOrMoveChange( + const EventVector::iterator& event, + bool* target_file_affected, + bool* update_watches) { + *target_file_affected = true; + *update_watches = true; + EventVector::iterator local_event(event); + for (; local_event != events_.end(); ++local_event) { + // Close all nodes from the event down. This has the side effect of + // potentially rendering other events in |updates| invalid. + // There is no need to remove the events from |kqueue_| because this + // happens as a side effect of closing the file descriptor. + CloseFileDescriptor(reinterpret_cast<int*>(&local_event->ident)); + } +} + +void FilePathWatcherImpl::HandleCreateItemChange( + const EventVector::iterator& event, + bool* target_file_affected, + bool* update_watches) { + // Get the next item in the path. + EventVector::iterator next_event = event + 1; + EventData* next_event_data = EventDataForKevent(*next_event); + + // Check to see if it already has a valid file descriptor. + if (!IsKeventFileDescriptorOpen(*next_event)) { + // If not, attempt to open a file descriptor for it. + next_event->ident = FileDescriptorForPath(next_event_data->path_); + if (IsKeventFileDescriptorOpen(*next_event)) { + *update_watches = true; + if (next_event_data->subdir_.empty()) { + *target_file_affected = true; + } + } + } +} + +bool FilePathWatcherImpl::UpdateWatches(bool* target_file_affected) { + // Iterate over events adding kevents for items that exist to the kqueue. + // Then check to see if new components in the path have been created. + // Repeat until no new components in the path are detected. + // This is to get around races in directory creation in a watched path. + bool update_watches = true; + while (update_watches) { + size_t valid; + for (valid = 0; valid < events_.size(); ++valid) { + if (!IsKeventFileDescriptorOpen(events_[valid])) { + break; + } + } + if (valid == 0) { + // The root of the file path is inaccessible? + return false; + } + + EventVector updates(valid); + int count = HANDLE_EINTR(kevent(kqueue_, &events_[0], valid, &updates[0], + valid, NULL)); + if (!AreKeventValuesValid(&updates[0], count)) { + return false; + } + update_watches = false; + for (; valid < events_.size(); ++valid) { + EventData* event_data = EventDataForKevent(events_[valid]); + events_[valid].ident = FileDescriptorForPath(event_data->path_); + if (IsKeventFileDescriptorOpen(events_[valid])) { + update_watches = true; + if (event_data->subdir_.empty()) { + *target_file_affected = true; + } + } else { + break; + } + } + } + return true; +} + +void FilePathWatcherImpl::OnFileCanReadWithoutBlocking(int fd) { + DCHECK(MessageLoopForIO::current()); + DCHECK_EQ(fd, kqueue_); + DCHECK(events_.size()); + + // Request the file system update notifications that have occurred and return + // them in |updates|. |count| will contain the number of updates that have + // occurred. + EventVector updates(events_.size()); + struct timespec timeout = {0, 0}; + int count = HANDLE_EINTR(kevent(kqueue_, NULL, 0, &updates[0], updates.size(), + &timeout)); + + // Error values are stored within updates, so check to make sure that no + // errors occurred. + if (!AreKeventValuesValid(&updates[0], count)) { + delegate_->OnFilePathError(target_); + Cancel(); + return; + } + + bool update_watches = false; + bool send_notification = false; + + // Iterate through each of the updates and react to them. + for (int i = 0; i < count; ++i) { + // Find our kevent record that matches the update notification. + EventVector::iterator event = events_.begin(); + for (; event != events_.end(); ++event) { + if (!IsKeventFileDescriptorOpen(*event) || + event->ident == updates[i].ident) { + break; + } + } + if (!IsKeventFileDescriptorOpen(*event) || event == events_.end()) { + // The event may no longer exist in |events_| because another event + // modified |events_| in such a way to make it invalid. For example if + // the path is /foo/bar/bam and foo is deleted, NOTE_DELETE events for + // foo, bar and bam will be sent. If foo is processed first, then + // the file descriptors for bar and bam will already be closed and set + // to -1 before they get a chance to be processed. + continue; + } + + EventData* event_data = EventDataForKevent(*event); + + // If the subdir is empty, this is the last item on the path and is the + // target file. + bool target_file_affected = event_data->subdir_.empty(); + if ((updates[i].fflags & NOTE_ATTRIB) && !target_file_affected) { + HandleAttributesChange(event, &target_file_affected, &update_watches); + } + if (updates[i].fflags & (NOTE_DELETE | NOTE_REVOKE | NOTE_RENAME)) { + HandleDeleteOrMoveChange(event, &target_file_affected, &update_watches); + } + if ((updates[i].fflags & NOTE_WRITE) && !target_file_affected) { + HandleCreateItemChange(event, &target_file_affected, &update_watches); + } + send_notification |= target_file_affected; + } + + if (update_watches) { + if (!UpdateWatches(&send_notification)) { + delegate_->OnFilePathError(target_); + Cancel(); + } + } + + if (send_notification) { + delegate_->OnFilePathChanged(target_); + } +} + +void FilePathWatcherImpl::OnFileCanWriteWithoutBlocking(int fd) { + NOTREACHED(); +} + +void FilePathWatcherImpl::WillDestroyCurrentMessageLoop() { + CancelOnMessageLoopThread(); +} + +bool FilePathWatcherImpl::Watch(const FilePath& path, + FilePathWatcher::Delegate* delegate) { + DCHECK(MessageLoopForIO::current()); + DCHECK(target_.value().empty()); // Can only watch one path. + DCHECK(delegate); + DCHECK_EQ(kqueue_, -1); + + delegate_ = delegate; + target_ = path; + + MessageLoop::current()->AddDestructionObserver(this); + io_message_loop_ = base::MessageLoopProxy::current(); + + kqueue_ = kqueue(); + if (kqueue_ == -1) { + DPLOG(ERROR) << "kqueue"; + return false; + } + + int last_entry = EventsForPath(target_, &events_); + DCHECK_NE(last_entry, 0); + + EventVector responses(last_entry); + + int count = HANDLE_EINTR(kevent(kqueue_, &events_[0], last_entry, + &responses[0], last_entry, NULL)); + if (!AreKeventValuesValid(&responses[0], count)) { + // Calling Cancel() here to close any file descriptors that were opened. + // This would happen in the destructor anyways, but FilePathWatchers tend to + // be long lived, and if an error has occurred, there is no reason to waste + // the file descriptors. + Cancel(); + return false; + } + + return MessageLoopForIO::current()->WatchFileDescriptor( + kqueue_, true, MessageLoopForIO::WATCH_READ, &kqueue_watcher_, this); +} + +void FilePathWatcherImpl::Cancel() { + base::MessageLoopProxy* proxy = io_message_loop_.get(); + if (!proxy) { + set_cancelled(); + return; + } + if (!proxy->BelongsToCurrentThread()) { + proxy->PostTask(FROM_HERE, + base::Bind(&FilePathWatcherImpl::Cancel, this)); + return; + } + CancelOnMessageLoopThread(); +} + +void FilePathWatcherImpl::CancelOnMessageLoopThread() { + DCHECK(MessageLoopForIO::current()); + if (!is_cancelled()) { + set_cancelled(); + kqueue_watcher_.StopWatchingFileDescriptor(); + CloseFileDescriptor(&kqueue_); + std::for_each(events_.begin(), events_.end(), ReleaseEvent); + events_.clear(); + io_message_loop_ = NULL; + MessageLoop::current()->RemoveDestructionObserver(this); + delegate_ = NULL; + } +} + +} // namespace + +FilePathWatcher::FilePathWatcher() { + impl_ = new FilePathWatcherImpl(); +} + +} // namespace files +} // namespace base diff --git a/base/files/file_path_watcher_win.cc b/base/files/file_path_watcher_win.cc index b87654e..84a5398 100644 --- a/base/files/file_path_watcher_win.cc +++ b/base/files/file_path_watcher_win.cc @@ -206,8 +206,8 @@ bool FilePathWatcherImpl::SetupWatchHandle(const FilePath& dir, error_code != ERROR_SHARING_VIOLATION && error_code != ERROR_DIRECTORY) { using ::operator<<; // Pick the right operator<< below. - PLOG(ERROR) << "FindFirstChangeNotification failed for " - << dir.value(); + DPLOG(ERROR) << "FindFirstChangeNotification failed for " + << dir.value(); return false; } @@ -241,7 +241,7 @@ bool FilePathWatcherImpl::UpdateWatch() { child_dirs.push_back(watched_path.BaseName()); FilePath parent(watched_path.DirName()); if (parent == watched_path) { - LOG(ERROR) << "Reached the root directory"; + DLOG(ERROR) << "Reached the root directory"; return false; } watched_path = parent; diff --git a/base/global_descriptors_posix.cc b/base/global_descriptors_posix.cc index 65e7955..d8884a5 100644 --- a/base/global_descriptors_posix.cc +++ b/base/global_descriptors_posix.cc @@ -23,7 +23,7 @@ int GlobalDescriptors::Get(Key key) const { const int ret = MaybeGet(key); if (ret == -1) - LOG(FATAL) << "Unknown global descriptor: " << key; + DLOG(FATAL) << "Unknown global descriptor: " << key; return ret; } diff --git a/base/i18n/icu_util.cc b/base/i18n/icu_util.cc index 4f17f177..e5bbe17 100644 --- a/base/i18n/icu_util.cc +++ b/base/i18n/icu_util.cc @@ -68,13 +68,13 @@ bool Initialize() { HMODULE module = LoadLibrary(data_path.value().c_str()); if (!module) { - LOG(ERROR) << "Failed to load " << ICU_UTIL_DATA_SHARED_MODULE_NAME; + DLOG(ERROR) << "Failed to load " << ICU_UTIL_DATA_SHARED_MODULE_NAME; return false; } FARPROC addr = GetProcAddress(module, ICU_UTIL_DATA_SYMBOL); if (!addr) { - LOG(ERROR) << ICU_UTIL_DATA_SYMBOL << ": not found in " + DLOG(ERROR) << ICU_UTIL_DATA_SYMBOL << ": not found in " << ICU_UTIL_DATA_SHARED_MODULE_NAME; return false; } @@ -113,11 +113,11 @@ bool Initialize() { FilePath data_path = base::mac::PathForMainAppBundleResource(CFSTR(ICU_UTIL_DATA_FILE_NAME)); if (data_path.empty()) { - LOG(ERROR) << ICU_UTIL_DATA_FILE_NAME << " not found in bundle"; + DLOG(ERROR) << ICU_UTIL_DATA_FILE_NAME << " not found in bundle"; return false; } if (!mapped_file.Initialize(data_path)) { - LOG(ERROR) << "Couldn't mmap " << data_path.value(); + DLOG(ERROR) << "Couldn't mmap " << data_path.value(); return false; } } diff --git a/base/i18n/time_formatting.cc b/base/i18n/time_formatting.cc index 419e8db..9906dba 100644 --- a/base/i18n/time_formatting.cc +++ b/base/i18n/time_formatting.cc @@ -75,15 +75,15 @@ string16 TimeFormatTimeOfDayWithHourClockType(const Time& time, UErrorCode status = U_ZERO_ERROR; scoped_ptr<icu::DateTimePatternGenerator> generator( icu::DateTimePatternGenerator::createInstance(status)); - CHECK(U_SUCCESS(status)); + DCHECK(U_SUCCESS(status)); const char* base_pattern = (type == k12HourClock ? "ahm" : "Hm"); icu::UnicodeString generated_pattern = generator->getBestPattern(icu::UnicodeString(base_pattern), status); - CHECK(U_SUCCESS(status)); + DCHECK(U_SUCCESS(status)); // Then, format the time using the generated pattern. icu::SimpleDateFormat formatter(generated_pattern, status); - CHECK(U_SUCCESS(status)); + DCHECK(U_SUCCESS(status)); if (ampm == kKeepAmPm) { return TimeFormat(&formatter, time); } else { diff --git a/base/linux_util.cc b/base/linux_util.cc index c0757fa..6751469 100644 --- a/base/linux_util.cc +++ b/base/linux_util.cc @@ -88,7 +88,7 @@ bool ProcPathGetInode(ino_t* inode_out, const char* path, bool log = false) { const ssize_t n = readlink(path, buf, sizeof(buf) - 1); if (n == -1) { if (log) { - LOG(WARNING) << "Failed to read the inode number for a socket from /proc" + DLOG(WARNING) << "Failed to read the inode number for a socket from /proc" "(" << errno << ")"; } return false; @@ -97,8 +97,8 @@ bool ProcPathGetInode(ino_t* inode_out, const char* path, bool log = false) { if (memcmp(kSocketLinkPrefix, buf, sizeof(kSocketLinkPrefix) - 1)) { if (log) { - LOG(WARNING) << "The descriptor passed from the crashing process wasn't a" - " UNIX domain socket."; + DLOG(WARNING) << "The descriptor passed from the crashing process wasn't " + " a UNIX domain socket."; } return false; } @@ -111,8 +111,8 @@ bool ProcPathGetInode(ino_t* inode_out, const char* path, bool log = false) { if (inode_ul == ULLONG_MAX) { if (log) { - LOG(WARNING) << "Failed to parse a socket's inode number: the number was " - "too large. Please report this bug: " << buf; + DLOG(WARNING) << "Failed to parse a socket's inode number: the number " + "was too large. Please report this bug: " << buf; } return false; } @@ -201,7 +201,7 @@ bool FindProcessHoldingSocket(pid_t* pid_out, ino_t socket_inode) { DIR* proc = opendir("/proc"); if (!proc) { - LOG(WARNING) << "Cannot open /proc"; + DLOG(WARNING) << "Cannot open /proc"; return false; } @@ -263,7 +263,7 @@ pid_t FindThreadIDWithSyscall(pid_t pid, const std::string& expected_data, DIR* task = opendir(buf); if (!task) { - LOG(WARNING) << "Cannot open " << buf; + DLOG(WARNING) << "Cannot open " << buf; return -1; } diff --git a/base/mac/foundation_util.mm b/base/mac/foundation_util.mm index 37b001b..8a4ce47 100644 --- a/base/mac/foundation_util.mm +++ b/base/mac/foundation_util.mm @@ -28,7 +28,7 @@ static bool UncachedAmIBundled() { FSRef fsref; OSStatus pbErr; if ((pbErr = GetProcessBundleLocation(&psn, &fsref)) != noErr) { - LOG(ERROR) << "GetProcessBundleLocation failed: error " << pbErr; + DLOG(ERROR) << "GetProcessBundleLocation failed: error " << pbErr; return false; } @@ -36,7 +36,7 @@ static bool UncachedAmIBundled() { OSErr fsErr; if ((fsErr = FSGetCatalogInfo(&fsref, kFSCatInfoNodeFlags, &info, NULL, NULL, NULL)) != noErr) { - LOG(ERROR) << "FSGetCatalogInfo failed: error " << fsErr; + DLOG(ERROR) << "FSGetCatalogInfo failed: error " << fsErr; return false; } @@ -102,7 +102,7 @@ void SetOverrideAppBundle(NSBundle* bundle) { void SetOverrideAppBundlePath(const FilePath& file_path) { NSString* path = base::SysUTF8ToNSString(file_path.value()); NSBundle* bundle = [NSBundle bundleWithPath:path]; - CHECK(bundle) << "Failed to load the bundle at " << file_path.value(); + DCHECK(bundle) << "Failed to load the bundle at " << file_path.value(); SetOverrideAppBundle(bundle); } @@ -146,7 +146,7 @@ bool GetUserDirectory(NSSearchPathDirectory directory, FilePath* result) { FilePath GetUserLibraryPath() { FilePath user_library_path; if (!GetUserDirectory(NSLibraryDirectory, &user_library_path)) { - LOG(WARNING) << "Could not get user library path"; + DLOG(WARNING) << "Could not get user library path"; } return user_library_path; } @@ -212,7 +212,7 @@ CFTypeRef GetValueFromDictionary(CFDictionaryRef dict, CFCopyTypeIDDescription(expected_type)); ScopedCFTypeRef<CFStringRef> actual_type_ref( CFCopyTypeIDDescription(CFGetTypeID(value))); - LOG(WARNING) << "Expected value for key " + DLOG(WARNING) << "Expected value for key " << base::SysCFStringRefToUTF8(key) << " to be " << base::SysCFStringRefToUTF8(expected_type_ref) diff --git a/base/mac/mac_util.mm b/base/mac/mac_util.mm index 57e07a6..66fbf11 100644 --- a/base/mac/mac_util.mm +++ b/base/mac/mac_util.mm @@ -64,7 +64,7 @@ LSSharedFileListItemRef GetLoginItemForApp() { NULL, kLSSharedFileListSessionLoginItems, NULL)); if (!login_items.get()) { - LOG(ERROR) << "Couldn't get a Login Items list."; + DLOG(ERROR) << "Couldn't get a Login Items list."; return NULL; } @@ -126,7 +126,7 @@ CGColorSpaceRef GetSRGBColorSpace() { // Leaked. That's OK, it's scoped to the lifetime of the application. static CGColorSpaceRef g_color_space_sRGB = CGColorSpaceCreateWithName(kCGColorSpaceSRGB); - LOG_IF(ERROR, !g_color_space_sRGB) << "Couldn't get the sRGB color space"; + DLOG_IF(ERROR, !g_color_space_sRGB) << "Couldn't get the sRGB color space"; return g_color_space_sRGB; } @@ -141,10 +141,10 @@ CGColorSpaceRef GetSystemColorSpace() { g_system_color_space = CGColorSpaceCreateDeviceRGB(); if (g_system_color_space) { - LOG(WARNING) << + DLOG(WARNING) << "Couldn't get the main display's color space, using generic"; } else { - LOG(ERROR) << "Couldn't get any color space"; + DLOG(ERROR) << "Couldn't get any color space"; } } @@ -216,7 +216,7 @@ void ActivateProcess(pid_t pid) { if (status == noErr) { SetFrontProcess(&process); } else { - LOG(WARNING) << "Unable to get process for pid " << pid; + DLOG(WARNING) << "Unable to get process for pid " << pid; } } @@ -224,7 +224,7 @@ bool AmIForeground() { ProcessSerialNumber foreground_psn = { 0 }; OSErr err = GetFrontProcess(&foreground_psn); if (err != noErr) { - LOG(WARNING) << "GetFrontProcess: " << err; + DLOG(WARNING) << "GetFrontProcess: " << err; return false; } @@ -233,7 +233,7 @@ bool AmIForeground() { Boolean result = FALSE; err = SameProcess(&foreground_psn, &my_psn, &result); if (err != noErr) { - LOG(WARNING) << "SameProcess: " << err; + DLOG(WARNING) << "SameProcess: " << err; return false; } @@ -254,7 +254,7 @@ bool SetFileBackupExclusion(const FilePath& file_path) { OSStatus os_err = CSBackupSetItemExcluded(base::mac::NSToCFCast(file_url), TRUE, FALSE); if (os_err != noErr) { - LOG(WARNING) << "Failed to set backup exclusion for file '" + DLOG(WARNING) << "Failed to set backup exclusion for file '" << file_path.value().c_str() << "' with error " << os_err << " (" << GetMacOSStatusErrorString(os_err) << ": " << GetMacOSStatusCommentString(os_err) @@ -300,7 +300,7 @@ void SetProcessName(CFStringRef process_name) { CFBundleRef launch_services_bundle = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.LaunchServices")); if (!launch_services_bundle) { - LOG(ERROR) << "Failed to look up LaunchServices bundle"; + DLOG(ERROR) << "Failed to look up LaunchServices bundle"; return; } @@ -309,7 +309,7 @@ void SetProcessName(CFStringRef process_name) { CFBundleGetFunctionPointerForName( launch_services_bundle, CFSTR("_LSGetCurrentApplicationASN"))); if (!ls_get_current_application_asn_func) - LOG(ERROR) << "Could not find _LSGetCurrentApplicationASN"; + DLOG(ERROR) << "Could not find _LSGetCurrentApplicationASN"; ls_set_application_information_item_func = reinterpret_cast<LSSetApplicationInformationItemType>( @@ -317,14 +317,14 @@ void SetProcessName(CFStringRef process_name) { launch_services_bundle, CFSTR("_LSSetApplicationInformationItem"))); if (!ls_set_application_information_item_func) - LOG(ERROR) << "Could not find _LSSetApplicationInformationItem"; + DLOG(ERROR) << "Could not find _LSSetApplicationInformationItem"; CFStringRef* key_pointer = reinterpret_cast<CFStringRef*>( CFBundleGetDataPointerForName(launch_services_bundle, CFSTR("_kLSDisplayNameKey"))); ls_display_name_key = key_pointer ? *key_pointer : NULL; if (!ls_display_name_key) - LOG(ERROR) << "Could not find _kLSDisplayNameKey"; + DLOG(ERROR) << "Could not find _kLSDisplayNameKey"; // Internally, this call relies on the Mach ports that are started up by the // Carbon Process Manager. In debug builds this usually happens due to how @@ -349,7 +349,7 @@ void SetProcessName(CFStringRef process_name) { ls_display_name_key, process_name, NULL /* optional out param */); - LOG_IF(ERROR, err) << "Call to set process name failed, err " << err; + DLOG_IF(ERROR, err) << "Call to set process name failed, err " << err; } // Converts a NSImage to a CGImageRef. Normally, the system frameworks can do @@ -406,7 +406,7 @@ void AddToLoginItems(bool hide_on_startup) { NULL, kLSSharedFileListSessionLoginItems, NULL)); if (!login_items.get()) { - LOG(ERROR) << "Couldn't get a Login Items list."; + DLOG(ERROR) << "Couldn't get a Login Items list."; return; } @@ -430,7 +430,7 @@ void AddToLoginItems(bool hide_on_startup) { reinterpret_cast<CFDictionaryRef>(properties), NULL)); if (!new_item.get()) { - LOG(ERROR) << "Couldn't insert current app into Login Items list."; + DLOG(ERROR) << "Couldn't insert current app into Login Items list."; } } @@ -443,7 +443,7 @@ void RemoveFromLoginItems() { NULL, kLSSharedFileListSessionLoginItems, NULL)); if (!login_items.get()) { - LOG(ERROR) << "Couldn't get a Login Items list."; + DLOG(ERROR) << "Couldn't get a Login Items list."; return; } @@ -481,7 +481,7 @@ bool WasLaunchedAsHiddenLoginItem() { // Lion can launch items for the resume feature. So log an error only for // Snow Leopard or earlier. if (IsOSSnowLeopardOrEarlier()) - LOG(ERROR) << + DLOG(ERROR) << "Process launched at Login but can't access Login Item List."; return false; @@ -509,12 +509,12 @@ int DarwinMajorVersionInternal() { struct utsname uname_info; if (uname(&uname_info) != 0) { - PLOG(ERROR) << "uname"; + DPLOG(ERROR) << "uname"; return 0; } if (strcmp(uname_info.sysname, "Darwin") != 0) { - LOG(ERROR) << "unexpected uname sysname " << uname_info.sysname; + DLOG(ERROR) << "unexpected uname sysname " << uname_info.sysname; return 0; } @@ -527,7 +527,7 @@ int DarwinMajorVersionInternal() { } if (!dot) { - LOG(ERROR) << "could not parse uname release " << uname_info.release; + DLOG(ERROR) << "could not parse uname release " << uname_info.release; return 0; } @@ -548,7 +548,7 @@ int MacOSXMinorVersionInternal() { // immediate death. CHECK(darwin_major_version >= 6); int mac_os_x_minor_version = darwin_major_version - 4; - LOG_IF(WARNING, darwin_major_version > 11) << "Assuming Darwin " + DLOG_IF(WARNING, darwin_major_version > 11) << "Assuming Darwin " << base::IntToString(darwin_major_version) << " is Mac OS X 10." << base::IntToString(mac_os_x_minor_version); diff --git a/base/mac/objc_property_releaser.mm b/base/mac/objc_property_releaser.mm index bd7a750..f7ee88f 100644 --- a/base/mac/objc_property_releaser.mm +++ b/base/mac/objc_property_releaser.mm @@ -98,8 +98,8 @@ void ObjCPropertyReleaser::Init(id object, Class classy) { } void ObjCPropertyReleaser::ReleaseProperties() { - CHECK(object_); - CHECK(class_); + DCHECK(object_); + DCHECK(class_); unsigned int property_count = 0; objc_property_t* properties = class_copyPropertyList(class_, &property_count); @@ -114,7 +114,7 @@ void ObjCPropertyReleaser::ReleaseProperties() { Ivar instance_variable = object_getInstanceVariable(object_, instance_name.c_str(), (void**)&instance_value); - CHECK(instance_variable); + DCHECK(instance_variable); [instance_value release]; } } diff --git a/base/message_loop.cc b/base/message_loop.cc index 593c03c9..553efb1 100644 --- a/base/message_loop.cc +++ b/base/message_loop.cc @@ -258,7 +258,7 @@ void MessageLoop::RemoveDestructionObserver( void MessageLoop::PostTask( const tracked_objects::Location& from_here, Task* task) { - CHECK(task); + DCHECK(task); PendingTask pending_task( base::Bind( &base::subtle::TaskClosureAdapter::Run, @@ -270,7 +270,7 @@ void MessageLoop::PostTask( void MessageLoop::PostDelayedTask( const tracked_objects::Location& from_here, Task* task, int64 delay_ms) { - CHECK(task); + DCHECK(task); PendingTask pending_task( base::Bind( &base::subtle::TaskClosureAdapter::Run, @@ -282,7 +282,7 @@ void MessageLoop::PostDelayedTask( void MessageLoop::PostNonNestableTask( const tracked_objects::Location& from_here, Task* task) { - CHECK(task); + DCHECK(task); PendingTask pending_task( base::Bind( &base::subtle::TaskClosureAdapter::Run, @@ -294,7 +294,7 @@ void MessageLoop::PostNonNestableTask( void MessageLoop::PostNonNestableDelayedTask( const tracked_objects::Location& from_here, Task* task, int64 delay_ms) { - CHECK(task); + DCHECK(task); PendingTask pending_task( base::Bind( &base::subtle::TaskClosureAdapter::Run, @@ -306,7 +306,7 @@ void MessageLoop::PostNonNestableDelayedTask( void MessageLoop::PostTask( const tracked_objects::Location& from_here, const base::Closure& task) { - CHECK(!task.is_null()) << from_here.ToString(); + DCHECK(!task.is_null()) << from_here.ToString(); PendingTask pending_task(task, from_here, CalculateDelayedRuntime(0), true); AddToIncomingQueue(&pending_task); } @@ -314,7 +314,7 @@ void MessageLoop::PostTask( void MessageLoop::PostDelayedTask( const tracked_objects::Location& from_here, const base::Closure& task, int64 delay_ms) { - CHECK(!task.is_null()) << from_here.ToString(); + DCHECK(!task.is_null()) << from_here.ToString(); PendingTask pending_task(task, from_here, CalculateDelayedRuntime(delay_ms), true); AddToIncomingQueue(&pending_task); @@ -322,7 +322,7 @@ void MessageLoop::PostDelayedTask( void MessageLoop::PostNonNestableTask( const tracked_objects::Location& from_here, const base::Closure& task) { - CHECK(!task.is_null()) << from_here.ToString(); + DCHECK(!task.is_null()) << from_here.ToString(); PendingTask pending_task(task, from_here, CalculateDelayedRuntime(0), false); AddToIncomingQueue(&pending_task); } @@ -330,7 +330,7 @@ void MessageLoop::PostNonNestableTask( void MessageLoop::PostNonNestableDelayedTask( const tracked_objects::Location& from_here, const base::Closure& task, int64 delay_ms) { - CHECK(!task.is_null()) << from_here.ToString(); + DCHECK(!task.is_null()) << from_here.ToString(); PendingTask pending_task(task, from_here, CalculateDelayedRuntime(delay_ms), false); AddToIncomingQueue(&pending_task); diff --git a/base/message_pump_glib.cc b/base/message_pump_glib.cc index 20fc8ea9..19a0eea 100644 --- a/base/message_pump_glib.cc +++ b/base/message_pump_glib.cc @@ -145,7 +145,10 @@ MessagePumpGlib::MessagePumpGlib() wakeup_gpollfd_(new GPollFD) { // Create our wakeup pipe, which is used to flag when work was scheduled. int fds[2]; - CHECK_EQ(pipe(fds), 0); + int ret = pipe(fds); + DCHECK_EQ(ret, 0); + (void)ret; // Prevent warning in release mode. + wakeup_pipe_read_ = fds[0]; wakeup_pipe_write_ = fds[1]; wakeup_gpollfd_->fd = wakeup_pipe_read_; diff --git a/base/message_pump_libevent.cc b/base/message_pump_libevent.cc index 1b4c023..9bef229 100644 --- a/base/message_pump_libevent.cc +++ b/base/message_pump_libevent.cc @@ -129,11 +129,11 @@ MessagePumpLibevent::~MessagePumpLibevent() { delete wakeup_event_; if (wakeup_pipe_in_ >= 0) { if (HANDLE_EINTR(close(wakeup_pipe_in_)) < 0) - PLOG(ERROR) << "close"; + DPLOG(ERROR) << "close"; } if (wakeup_pipe_out_ >= 0) { if (HANDLE_EINTR(close(wakeup_pipe_out_)) < 0) - PLOG(ERROR) << "close"; + DPLOG(ERROR) << "close"; } event_base_free(event_base_); } diff --git a/base/message_pump_x.cc b/base/message_pump_x.cc index a9b1b8a..15276e4 100644 --- a/base/message_pump_x.cc +++ b/base/message_pump_x.cc @@ -66,7 +66,7 @@ void InitializeXInput2(void) { int event, err; if (!XQueryExtension(display, "XInputExtension", &xiopcode, &event, &err)) { - VLOG(1) << "X Input extension not available."; + DVLOG(1) << "X Input extension not available."; xiopcode = -1; return; } @@ -78,13 +78,13 @@ void InitializeXInput2(void) { int major = 2, minor = 0; #endif if (XIQueryVersion(display, &major, &minor) == BadRequest) { - VLOG(1) << "XInput2 not supported in the server."; + DVLOG(1) << "XInput2 not supported in the server."; xiopcode = -1; return; } #if defined(USE_XI2_MT) if (major < 2 || (major == 2 && minor < USE_XI2_MT)) { - VLOG(1) << "XI version on server is " << major << "." << minor << ". " + DVLOG(1) << "XI version on server is " << major << "." << minor << ". " << "But 2." << USE_XI2_MT << " is required."; xiopcode = -1; return; @@ -148,7 +148,7 @@ void MessagePumpX::InitXSource() { DCHECK(!x_source_); GPollFD* x_poll = new GPollFD(); Display* display = GetDefaultXDisplay(); - CHECK(display) << "Unable to get connection to X server"; + DCHECK(display) << "Unable to get connection to X server"; x_poll->fd = ConnectionNumber(display); x_poll->events = G_IO_IN; @@ -186,7 +186,7 @@ bool MessagePumpX::ProcessXEvent(XEvent* xev) { should_quit = true; Quit(); } else if (status == MessagePumpDispatcher::EVENT_IGNORED) { - VLOG(1) << "Event (" << xev->type << ") not handled."; + DVLOG(1) << "Event (" << xev->type << ") not handled."; } DidProcessXEvent(xev); } diff --git a/base/metrics/histogram.cc b/base/metrics/histogram.cc index 484d095..7077b09 100644 --- a/base/metrics/histogram.cc +++ b/base/metrics/histogram.cc @@ -268,7 +268,7 @@ bool Histogram::DeserializeHistogramInfo(const std::string& histogram_info) { !pickle.ReadInt(&iter, &histogram_type) || !pickle.ReadInt(&iter, &pickle_flags) || !sample.Histogram::SampleSet::Deserialize(&iter, pickle)) { - LOG(ERROR) << "Pickle error decoding Histogram: " << histogram_name; + DLOG(ERROR) << "Pickle error decoding Histogram: " << histogram_name; return false; } DCHECK(pickle_flags & kIPCSerializationSourceFlag); @@ -276,7 +276,7 @@ bool Histogram::DeserializeHistogramInfo(const std::string& histogram_info) { // checks above and beyond those in Histogram::Initialize() if (declared_max <= 0 || declared_min <= 0 || declared_max < declared_min || INT_MAX / sizeof(Count) <= bucket_count || bucket_count < 2) { - LOG(ERROR) << "Values error decoding Histogram: " << histogram_name; + DLOG(ERROR) << "Values error decoding Histogram: " << histogram_name; return false; } @@ -295,8 +295,8 @@ bool Histogram::DeserializeHistogramInfo(const std::string& histogram_info) { } else if (histogram_type == BOOLEAN_HISTOGRAM) { render_histogram = BooleanHistogram::FactoryGet(histogram_name, flags); } else { - LOG(ERROR) << "Error Deserializing Histogram Unknown histogram_type: " - << histogram_type; + DLOG(ERROR) << "Error Deserializing Histogram Unknown histogram_type: " + << histogram_type; return false; } @@ -433,7 +433,7 @@ Histogram::~Histogram() { if (StatisticsRecorder::dump_on_exit()) { std::string output; WriteAscii(true, "\n", &output); - LOG(INFO) << output; + DLOG(INFO) << output; } // Just to make sure most derived class did this properly... @@ -1025,7 +1025,7 @@ StatisticsRecorder::~StatisticsRecorder() { if (dump_on_exit_) { std::string output; WriteGraph("", &output); - LOG(INFO) << output; + DLOG(INFO) << output; } // Clean up. HistogramMap* histograms = NULL; diff --git a/base/metrics/stats_table.cc b/base/metrics/stats_table.cc index 3db008e..2bccc90 100644 --- a/base/metrics/stats_table.cc +++ b/base/metrics/stats_table.cc @@ -265,7 +265,7 @@ StatsTable::StatsTable(const std::string& name, int max_threads, impl_ = Private::New(name, table_size, max_threads, max_counters); if (!impl_) - PLOG(ERROR) << "StatsTable did not initialize"; + DPLOG(ERROR) << "StatsTable did not initialize"; } StatsTable::~StatsTable() { diff --git a/base/mime_util_xdg.cc b/base/mime_util_xdg.cc index a25a0d5..294638d 100644 --- a/base/mime_util_xdg.cc +++ b/base/mime_util_xdg.cc @@ -371,7 +371,7 @@ bool IconTheme::SetDirectories(const std::string& dirs) { while ((epos = dirs.find(',', pos)) != std::string::npos) { TrimWhitespaceASCII(dirs.substr(pos, epos - pos), TRIM_ALL, &dir); if (dir.length() == 0) { - LOG(WARNING) << "Invalid index.theme: blank subdir"; + DLOG(WARNING) << "Invalid index.theme: blank subdir"; return false; } subdirs_[dir] = num++; @@ -379,7 +379,7 @@ bool IconTheme::SetDirectories(const std::string& dirs) { } TrimWhitespaceASCII(dirs.substr(pos), TRIM_ALL, &dir); if (dir.length() == 0) { - LOG(WARNING) << "Invalid index.theme: blank subdir"; + DLOG(WARNING) << "Invalid index.theme: blank subdir"; return false; } subdirs_[dir] = num++; diff --git a/base/native_library_linux.cc b/base/native_library_linux.cc index bcc4ffb..4b82ff4 100644 --- a/base/native_library_linux.cc +++ b/base/native_library_linux.cc @@ -34,7 +34,7 @@ NativeLibrary LoadNativeLibrary(const FilePath& library_path, void UnloadNativeLibrary(NativeLibrary library) { int ret = dlclose(library); if (ret < 0) { - LOG(ERROR) << "dlclose failed: " << dlerror(); + DLOG(ERROR) << "dlclose failed: " << dlerror(); NOTREACHED(); } } diff --git a/base/process_linux.cc b/base/process_linux.cc index dfdc20e..3f78a31 100644 --- a/base/process_linux.cc +++ b/base/process_linux.cc @@ -113,7 +113,7 @@ bool Process::SetProcessBackgrounded(bool background) { setpriority( PRIO_PROCESS, process_, current_priority + kPriorityAdjustment); if (result == -1) { - LOG(ERROR) << "Failed to lower priority, errno: " << errno; + DLOG(ERROR) << "Failed to lower priority, errno: " << errno; return false; } saved_priority_ = current_priority; diff --git a/base/process_util_linux.cc b/base/process_util_linux.cc index f9d151b..2f433d9 100644 --- a/base/process_util_linux.cc +++ b/base/process_util_linux.cc @@ -84,7 +84,7 @@ int GetProcessCPU(pid_t pid) { DIR* dir = opendir(path.value().c_str()); if (!dir) { - PLOG(ERROR) << "opendir(" << path.value() << ")"; + DPLOG(ERROR) << "opendir(" << path.value() << ")"; return -1; } @@ -273,7 +273,7 @@ ProcessMetrics* ProcessMetrics::CreateProcessMetrics(ProcessHandle process) { size_t ProcessMetrics::GetPagefileUsage() const { std::vector<std::string> proc_stats; if (!GetProcStats(process_, &proc_stats)) - LOG(WARNING) << "Failed to get process stats."; + DLOG(WARNING) << "Failed to get process stats."; const size_t kVmSize = 22; if (proc_stats.size() > kVmSize) { int vm_size; @@ -287,7 +287,7 @@ size_t ProcessMetrics::GetPagefileUsage() const { size_t ProcessMetrics::GetPeakPagefileUsage() const { std::vector<std::string> proc_stats; if (!GetProcStats(process_, &proc_stats)) - LOG(WARNING) << "Failed to get process stats."; + DLOG(WARNING) << "Failed to get process stats."; const size_t kVmPeak = 21; if (proc_stats.size() > kVmPeak) { int vm_peak; @@ -301,7 +301,7 @@ size_t ProcessMetrics::GetPeakPagefileUsage() const { size_t ProcessMetrics::GetWorkingSetSize() const { std::vector<std::string> proc_stats; if (!GetProcStats(process_, &proc_stats)) - LOG(WARNING) << "Failed to get process stats."; + DLOG(WARNING) << "Failed to get process stats."; const size_t kVmRss = 23; if (proc_stats.size() > kVmRss) { int num_pages; @@ -315,7 +315,7 @@ size_t ProcessMetrics::GetWorkingSetSize() const { size_t ProcessMetrics::GetPeakWorkingSetSize() const { std::vector<std::string> proc_stats; if (!GetProcStats(process_, &proc_stats)) - LOG(WARNING) << "Failed to get process stats."; + DLOG(WARNING) << "Failed to get process stats."; const size_t kVmHwm = 23; if (proc_stats.size() > kVmHwm) { int num_pages; @@ -576,14 +576,14 @@ bool GetSystemMemoryInfo(SystemMemoryInfoKB* meminfo) { FilePath meminfo_file("/proc/meminfo"); std::string meminfo_data; if (!file_util::ReadFileToString(meminfo_file, &meminfo_data)) { - LOG(WARNING) << "Failed to open /proc/meminfo."; + DLOG(WARNING) << "Failed to open /proc/meminfo."; return false; } std::vector<std::string> meminfo_fields; SplitStringAlongWhitespace(meminfo_data, &meminfo_fields); if (meminfo_fields.size() < kMemCachedIndex) { - LOG(WARNING) << "Failed to parse /proc/meminfo. Only found " << + DLOG(WARNING) << "Failed to parse /proc/meminfo. Only found " << meminfo_fields.size() << " fields."; return false; } @@ -752,7 +752,8 @@ bool AdjustOOMScore(ProcessId process, int score) { FilePath oom_file = oom_path.AppendASCII("oom_score_adj"); if (file_util::PathExists(oom_file)) { std::string score_str = base::IntToString(score); - VLOG(1) << "Adjusting oom_score_adj of " << process << " to " << score_str; + DVLOG(1) << "Adjusting oom_score_adj of " << process << " to " + << score_str; int score_len = static_cast<int>(score_str.length()); return (score_len == file_util::WriteFile(oom_file, score_str.c_str(), @@ -765,7 +766,7 @@ bool AdjustOOMScore(ProcessId process, int score) { if (file_util::PathExists(oom_file)) { std::string score_str = base::IntToString( score * kMaxOldOomScore / kMaxOomScore); - VLOG(1) << "Adjusting oom_adj of " << process << " to " << score_str; + DVLOG(1) << "Adjusting oom_adj of " << process << " to " << score_str; int score_len = static_cast<int>(score_str.length()); return (score_len == file_util::WriteFile(oom_file, score_str.c_str(), diff --git a/base/process_util_mac.mm b/base/process_util_mac.mm index e364d1b..5519d21 100644 --- a/base/process_util_mac.mm +++ b/base/process_util_mac.mm @@ -75,7 +75,7 @@ ProcessIterator::ProcessIterator(const ProcessFilter* filter) // Get the size of the buffer size_t len = 0; if (sysctl(mib, arraysize(mib), NULL, &len, NULL, 0) < 0) { - LOG(ERROR) << "failed to get the size needed for the process list"; + DLOG(ERROR) << "failed to get the size needed for the process list"; kinfo_procs_.resize(0); done = true; } else { @@ -90,7 +90,7 @@ ProcessIterator::ProcessIterator(const ProcessFilter* filter) // If we get a mem error, it just means we need a bigger buffer, so // loop around again. Anything else is a real error and give up. if (errno != ENOMEM) { - LOG(ERROR) << "failed to get the process list"; + DLOG(ERROR) << "failed to get the process list"; kinfo_procs_.resize(0); done = true; } @@ -104,7 +104,7 @@ ProcessIterator::ProcessIterator(const ProcessFilter* filter) } while (!done && (try_num++ < max_tries)); if (!done) { - LOG(ERROR) << "failed to collect the process list in a few tries"; + DLOG(ERROR) << "failed to collect the process list in a few tries"; kinfo_procs_.resize(0); } } @@ -149,7 +149,7 @@ bool ProcessIterator::CheckForNextProcess() { // to populate |entry_.exe_file_|. size_t exec_name_end = data.find('\0'); if (exec_name_end == std::string::npos) { - LOG(ERROR) << "command line data didn't match expected format"; + DLOG(ERROR) << "command line data didn't match expected format"; continue; } @@ -248,7 +248,7 @@ static bool GetCPUTypeForProcess(pid_t pid, cpu_type_t* cpu_type) { NULL, 0); if (result != 0) { - PLOG(ERROR) << "sysctlbyname(""sysctl.proc_cputype"")"; + DPLOG(ERROR) << "sysctlbyname(""sysctl.proc_cputype"")"; return false; } @@ -280,7 +280,7 @@ bool ProcessMetrics::GetMemoryBytes(size_t* private_bytes, mach_port_t task = TaskForPid(process_); if (task == MACH_PORT_NULL) { - LOG(ERROR) << "Invalid process"; + DLOG(ERROR) << "Invalid process"; return false; } @@ -319,7 +319,7 @@ bool ProcessMetrics::GetMemoryBytes(size_t* private_bytes, // We're at the end of the address space. break; } else if (kr != KERN_SUCCESS) { - LOG(ERROR) << "Calling mach_vm_region failed with error: " + DLOG(ERROR) << "Calling mach_vm_region failed with error: " << mach_error_string(kr); return false; } @@ -354,7 +354,7 @@ bool ProcessMetrics::GetMemoryBytes(size_t* private_bytes, vm_size_t page_size; kr = host_page_size(task, &page_size); if (kr != KERN_SUCCESS) { - LOG(ERROR) << "Failed to fetch host page size, error: " + DLOG(ERROR) << "Failed to fetch host page size, error: " << mach_error_string(kr); return false; } @@ -472,14 +472,14 @@ size_t GetSystemCommitCharge() { reinterpret_cast<host_info_t>(&data), &count); if (kr) { - LOG(WARNING) << "Failed to fetch host statistics."; + DLOG(WARNING) << "Failed to fetch host statistics."; return 0; } vm_size_t page_size; kr = host_page_size(host, &page_size); if (kr) { - LOG(ERROR) << "Failed to fetch host page size."; + DLOG(ERROR) << "Failed to fetch host page size."; return 0; } @@ -497,7 +497,7 @@ const char* LookUpLibCPath() { if (dladdr(addr, &info)) return info.dli_fname; - LOG(WARNING) << "Could not find image path for malloc()"; + DLOG(WARNING) << "Could not find image path for malloc()"; return NULL; } @@ -545,6 +545,7 @@ malloc_error_break_t LookUpMallocErrorBreak() { void CrMallocErrorBreak() { g_original_malloc_error_break(); + // A unit test checks this error message, so it needs to be in release builds. LOG(ERROR) << "Terminating process due to a potential for future heap corruption"; int* death_ptr = NULL; @@ -556,7 +557,7 @@ void CrMallocErrorBreak() { void EnableTerminationOnHeapCorruption() { malloc_error_break_t malloc_error_break = LookUpMallocErrorBreak(); if (!malloc_error_break) { - LOG(WARNING) << "Could not find malloc_error_break"; + DLOG(WARNING) << "Could not find malloc_error_break"; return; } @@ -566,7 +567,7 @@ void EnableTerminationOnHeapCorruption() { (void**)&g_original_malloc_error_break); if (err != err_none) - LOG(WARNING) << "Could not override malloc_error_break; error = " << err; + DLOG(WARNING) << "Could not override malloc_error_break; error = " << err; } // ------------------------------------------------------------------------ @@ -976,7 +977,7 @@ ProcessId GetParentProcessId(ProcessHandle process) { size_t length = sizeof(struct kinfo_proc); int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, process }; if (sysctl(mib, 4, &info, &length, NULL, 0) < 0) { - PLOG(ERROR) << "sysctl"; + DPLOG(ERROR) << "sysctl"; return -1; } if (length == 0) diff --git a/base/process_util_openbsd.cc b/base/process_util_openbsd.cc index 67c901f..d4ad5c2 100644 --- a/base/process_util_openbsd.cc +++ b/base/process_util_openbsd.cc @@ -79,7 +79,7 @@ ProcessIterator::ProcessIterator(const ProcessFilter* filter) do { size_t len = 0; if (sysctl(mib, arraysize(mib), NULL, &len, NULL, 0) < 0) { - LOG(ERROR) << "failed to get the size needed for the process list"; + DLOG(ERROR) << "failed to get the size needed for the process list"; kinfo_procs_.resize(0); done = true; } else { @@ -93,7 +93,7 @@ ProcessIterator::ProcessIterator(const ProcessFilter* filter) // If we get a mem error, it just means we need a bigger buffer, so // loop around again. Anything else is a real error and give up. if (errno != ENOMEM) { - LOG(ERROR) << "failed to get the process list"; + DLOG(ERROR) << "failed to get the process list"; kinfo_procs_.resize(0); done = true; } @@ -107,7 +107,7 @@ ProcessIterator::ProcessIterator(const ProcessFilter* filter) } while (!done && (try_num++ < max_tries)); if (!done) { - LOG(ERROR) << "failed to collect the process list in a few tries"; + DDLOG(ERROR) << "failed to collect the process list in a few tries"; kinfo_procs_.resize(0); } } @@ -152,7 +152,7 @@ bool ProcessIterator::CheckForNextProcess() { // to populate |entry_.exe_file_|. size_t exec_name_end = data.find('\0'); if (exec_name_end == std::string::npos) { - LOG(ERROR) << "command line data didn't match expected format"; + DLOG(ERROR) << "command line data didn't match expected format"; continue; } diff --git a/base/process_util_posix.cc b/base/process_util_posix.cc index 06fa779..055edcc 100644 --- a/base/process_util_posix.cc +++ b/base/process_util_posix.cc @@ -131,7 +131,7 @@ void StackDumpSignalHandler(int signal, siginfo_t* info, ucontext_t* context) { if (debug::BeingDebugged()) debug::BreakDebugger(); - LOG(ERROR) << "Received signal " << signal; + DLOG(ERROR) << "Received signal " << signal; debug::StackTrace().PrintBacktrace(); // TODO(shess): Port to Linux. @@ -296,7 +296,7 @@ bool KillProcess(ProcessHandle process_id, int exit_code, bool wait) { bool KillProcessGroup(ProcessHandle process_group_id) { bool result = kill(-1 * process_group_id, SIGKILL) == 0; if (!result) - PLOG(ERROR) << "Unable to terminate process group " << process_group_id; + DPLOG(ERROR) << "Unable to terminate process group " << process_group_id; return result; } @@ -565,11 +565,11 @@ bool LaunchProcess(const std::vector<std::string>& argv, // synchronize means "return from LaunchProcess but don't let the child // run until LaunchSynchronize is called". These two options are highly // incompatible. - CHECK(!options.wait); + DCHECK(!options.wait); // Create the pipe used for synchronization. if (HANDLE_EINTR(pipe(synchronization_pipe_fds)) != 0) { - PLOG(ERROR) << "pipe"; + DPLOG(ERROR) << "pipe"; return false; } @@ -594,7 +594,7 @@ bool LaunchProcess(const std::vector<std::string>& argv, } if (pid < 0) { - PLOG(ERROR) << "fork"; + DPLOG(ERROR) << "fork"; return false; } else if (pid == 0) { // Child process @@ -749,7 +749,7 @@ void LaunchSynchronize(LaunchSynchronizationHandle handle) { // Write a '\0' character to the pipe. if (HANDLE_EINTR(write(synchronization_fd, "", 1)) != 1) { - PLOG(ERROR) << "write"; + DPLOG(ERROR) << "write"; } } #endif // defined(OS_MACOSX) @@ -789,7 +789,7 @@ TerminationStatus GetTerminationStatus(ProcessHandle handle, int* exit_code) { int status = 0; const pid_t result = HANDLE_EINTR(waitpid(handle, &status, WNOHANG)); if (result == -1) { - PLOG(ERROR) << "waitpid(" << handle << ")"; + DPLOG(ERROR) << "waitpid(" << handle << ")"; if (exit_code) *exit_code = 0; return TERMINATION_STATUS_NORMAL_TERMINATION; @@ -874,7 +874,7 @@ static bool WaitForSingleNonChildProcess(ProcessHandle handle, int kq = kqueue(); if (kq == -1) { - PLOG(ERROR) << "kqueue"; + DPLOG(ERROR) << "kqueue"; return false; } file_util::ScopedFD kq_closer(&kq); @@ -888,7 +888,7 @@ static bool WaitForSingleNonChildProcess(ProcessHandle handle, return true; } - PLOG(ERROR) << "kevent (setup " << handle << ")"; + DPLOG(ERROR) << "kevent (setup " << handle << ")"; return false; } @@ -928,11 +928,11 @@ static bool WaitForSingleNonChildProcess(ProcessHandle handle, } if (result < 0) { - PLOG(ERROR) << "kevent (wait " << handle << ")"; + DPLOG(ERROR) << "kevent (wait " << handle << ")"; return false; } else if (result > 1) { - LOG(ERROR) << "kevent (wait " << handle << "): unexpected result " - << result; + DLOG(ERROR) << "kevent (wait " << handle << "): unexpected result " + << result; return false; } else if (result == 0) { // Timed out. @@ -944,10 +944,10 @@ static bool WaitForSingleNonChildProcess(ProcessHandle handle, if (event.filter != EVFILT_PROC || (event.fflags & NOTE_EXIT) == 0 || event.ident != static_cast<uintptr_t>(handle)) { - LOG(ERROR) << "kevent (wait " << handle - << "): unexpected event: filter=" << event.filter - << ", fflags=" << event.fflags - << ", ident=" << event.ident; + DLOG(ERROR) << "kevent (wait " << handle + << "): unexpected event: filter=" << event.filter + << ", fflags=" << event.fflags + << ", ident=" << event.ident; return false; } diff --git a/base/process_util_win.cc b/base/process_util_win.cc index c6ce3f5..85aeace 100644 --- a/base/process_util_win.cc +++ b/base/process_util_win.cc @@ -276,7 +276,7 @@ bool LaunchProcess(const string16& cmdline, if (options.job_handle) { if (0 == AssignProcessToJobObject(options.job_handle, process_info.hProcess)) { - LOG(ERROR) << "Could not AssignProcessToObject."; + DLOG(ERROR) << "Could not AssignProcessToObject."; KillProcess(process_info.hProcess, kProcessKilledExitCode, true); return false; } @@ -902,7 +902,7 @@ size_t GetSystemCommitCharge() { PERFORMANCE_INFORMATION info; if (!InternalGetPerformanceInfo(&info, sizeof(info))) { - LOG(ERROR) << "Failed to fetch internal performance info."; + DLOG(ERROR) << "Failed to fetch internal performance info."; return 0; } return (info.CommitTotal * system_info.dwPageSize) / 1024; diff --git a/base/rand_util_posix.cc b/base/rand_util_posix.cc index 43dfd1e..f23330a 100644 --- a/base/rand_util_posix.cc +++ b/base/rand_util_posix.cc @@ -23,7 +23,7 @@ class URandomFd { public: URandomFd() { fd_ = open("/dev/urandom", O_RDONLY); - CHECK_GE(fd_, 0) << "Cannot open /dev/urandom: " << errno; + DCHECK_GE(fd_, 0) << "Cannot open /dev/urandom: " << errno; } ~URandomFd() { diff --git a/base/scoped_temp_dir.cc b/base/scoped_temp_dir.cc index fc886e5a..6a51d6d 100644 --- a/base/scoped_temp_dir.cc +++ b/base/scoped_temp_dir.cc @@ -12,7 +12,7 @@ ScopedTempDir::ScopedTempDir() { ScopedTempDir::~ScopedTempDir() { if (!path_.empty() && !Delete()) - LOG(WARNING) << "Could not delete temp dir in dtor."; + DLOG(WARNING) << "Could not delete temp dir in dtor."; } bool ScopedTempDir::CreateUniqueTempDir() { @@ -67,7 +67,7 @@ bool ScopedTempDir::Delete() { // We only clear the path if deleted the directory. path_.clear(); } else { - LOG(ERROR) << "ScopedTempDir unable to delete " << path_.value(); + DLOG(ERROR) << "ScopedTempDir unable to delete " << path_.value(); } return ret; diff --git a/base/sha1_win.cc b/base/sha1_win.cc index 2edfb3d..626f41b 100644 --- a/base/sha1_win.cc +++ b/base/sha1_win.cc @@ -18,20 +18,20 @@ std::string SHA1HashString(const std::string& str) { ScopedHCRYPTPROV provider; if (!CryptAcquireContext(provider.receive(), NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) { - LOG(ERROR) << "CryptAcquireContext failed: " << GetLastError(); + DLOG(ERROR) << "CryptAcquireContext failed: " << GetLastError(); return std::string(kSHA1Length, '\0'); } { ScopedHCRYPTHASH hash; if (!CryptCreateHash(provider, CALG_SHA1, 0, 0, hash.receive())) { - LOG(ERROR) << "CryptCreateHash failed: " << GetLastError(); + DLOG(ERROR) << "CryptCreateHash failed: " << GetLastError(); return std::string(kSHA1Length, '\0'); } if (!CryptHashData(hash, reinterpret_cast<CONST BYTE*>(str.data()), static_cast<DWORD>(str.length()), 0)) { - LOG(ERROR) << "CryptHashData failed: " << GetLastError(); + DLOG(ERROR) << "CryptHashData failed: " << GetLastError(); return std::string(kSHA1Length, '\0'); } @@ -40,7 +40,8 @@ std::string SHA1HashString(const std::string& str) { if (!CryptGetHashParam(hash, HP_HASHSIZE, reinterpret_cast<unsigned char*>(&hash_len), &buffer_size, 0)) { - LOG(ERROR) << "CryptGetHashParam(HP_HASHSIZE) failed: " << GetLastError(); + DLOG(ERROR) << "CryptGetHashParam(HP_HASHSIZE) failed: " + << GetLastError(); return std::string(kSHA1Length, '\0'); } @@ -50,13 +51,14 @@ std::string SHA1HashString(const std::string& str) { // but so that result.length() is correctly set to |hash_len|. reinterpret_cast<BYTE*>(WriteInto(&result, hash_len + 1)), &hash_len, 0))) { - LOG(ERROR) << "CryptGetHashParam(HP_HASHVAL) failed: " << GetLastError(); + DLOG(ERROR) << "CryptGetHashParam(HP_HASHVAL) failed: " + << GetLastError(); return std::string(kSHA1Length, '\0'); } if (hash_len != kSHA1Length) { - LOG(ERROR) << "Returned hash value is wrong length: " << hash_len - << " should be " << kSHA1Length; + DLOG(ERROR) << "Returned hash value is wrong length: " << hash_len + << " should be " << kSHA1Length; return std::string(kSHA1Length, '\0'); } diff --git a/base/shared_memory_posix.cc b/base/shared_memory_posix.cc index 942a04c..3e5699a 100644 --- a/base/shared_memory_posix.cc +++ b/base/shared_memory_posix.cc @@ -91,7 +91,7 @@ SharedMemoryHandle SharedMemory::NULLHandle() { void SharedMemory::CloseHandle(const SharedMemoryHandle& handle) { DCHECK_GE(handle.fd, 0); if (HANDLE_EINTR(close(handle.fd)) < 0) - PLOG(ERROR) << "close"; + DPLOG(ERROR) << "close"; } bool SharedMemory::CreateAndMapAnonymous(uint32 size) { @@ -175,7 +175,7 @@ bool SharedMemory::CreateNamed(const std::string& name, PLOG(ERROR) << "Unable to access(W_OK|X_OK) " << dir.value(); if (dir.value() == "/dev/shm") { LOG(FATAL) << "This is frequently caused by incorrect permissions on " - << "/dev/shm. Try 'sudo chmod 1777 /dev/shm' to fix."; + << "/dev/shm. Try 'sudo chmod 1777 /dev/shm' to fix."; } } #else diff --git a/base/shared_memory_win.cc b/base/shared_memory_win.cc index 526132c..3e5ad36 100644 --- a/base/shared_memory_win.cc +++ b/base/shared_memory_win.cc @@ -206,7 +206,7 @@ bool SharedMemory::Lock(uint32 timeout_ms, SECURITY_ATTRIBUTES* sec_attr) { name.append(L"lock"); lock_ = CreateMutex(sec_attr, FALSE, name.c_str()); if (lock_ == NULL) { - PLOG(ERROR) << "Could not create mutex."; + DPLOG(ERROR) << "Could not create mutex."; return false; // there is nothing good we can do here. } } diff --git a/base/sync_socket_posix.cc b/base/sync_socket_posix.cc index 82ad91c..f50d20b 100644 --- a/base/sync_socket_posix.cc +++ b/base/sync_socket_posix.cc @@ -69,11 +69,11 @@ bool SyncSocket::CreatePair(SyncSocket* pair[2]) { cleanup: if (handles[0] != kInvalidHandle) { if (HANDLE_EINTR(close(handles[0])) < 0) - PLOG(ERROR) << "close"; + DPLOG(ERROR) << "close"; } if (handles[1] != kInvalidHandle) { if (HANDLE_EINTR(close(handles[1])) < 0) - PLOG(ERROR) << "close"; + DPLOG(ERROR) << "close"; } delete tmp_sockets[0]; delete tmp_sockets[1]; @@ -86,7 +86,7 @@ bool SyncSocket::Close() { } int retval = HANDLE_EINTR(close(handle_)); if (retval < 0) - PLOG(ERROR) << "close"; + DPLOG(ERROR) << "close"; handle_ = kInvalidHandle; return (retval == 0); } diff --git a/base/synchronization/condition_variable_win.cc b/base/synchronization/condition_variable_win.cc index 3030178..7b9919a 100644 --- a/base/synchronization/condition_variable_win.cc +++ b/base/synchronization/condition_variable_win.cc @@ -117,7 +117,7 @@ ConditionVariable::Event* ConditionVariable::GetEventForWaiting() { cv_event = new Event(); cv_event->InitListElement(); allocation_counter_++; - CHECK(cv_event->handle()); + DCHECK(cv_event->handle()); } else { cv_event = recycling_list_.PopFront(); recycling_list_size_--; @@ -193,7 +193,7 @@ ConditionVariable::Event::~Event() { void ConditionVariable::Event::InitListElement() { DCHECK(!handle_); handle_ = CreateEvent(NULL, false, false, NULL); - CHECK(handle_); + DCHECK(handle_); } // Methods for use on lists. diff --git a/base/system_monitor/system_monitor.cc b/base/system_monitor/system_monitor.cc index 2631789..5131fbf 100644 --- a/base/system_monitor/system_monitor.cc +++ b/base/system_monitor/system_monitor.cc @@ -86,18 +86,18 @@ void SystemMonitor::RemoveObserver(PowerObserver* obs) { } void SystemMonitor::NotifyPowerStateChange() { - VLOG(1) << "PowerStateChange: " << (BatteryPower() ? "On" : "Off") - << " battery"; + DVLOG(1) << "PowerStateChange: " << (BatteryPower() ? "On" : "Off") + << " battery"; observer_list_->Notify(&PowerObserver::OnPowerStateChange, BatteryPower()); } void SystemMonitor::NotifySuspend() { - VLOG(1) << "Power Suspending"; + DVLOG(1) << "Power Suspending"; observer_list_->Notify(&PowerObserver::OnSuspend); } void SystemMonitor::NotifyResume() { - VLOG(1) << "Power Resuming"; + DVLOG(1) << "Power Resuming"; observer_list_->Notify(&PowerObserver::OnResume); } diff --git a/base/system_monitor/system_monitor_win.cc b/base/system_monitor/system_monitor_win.cc index 84f2b2e..a8cd54a 100644 --- a/base/system_monitor/system_monitor_win.cc +++ b/base/system_monitor/system_monitor_win.cc @@ -41,7 +41,7 @@ void SystemMonitor::ProcessWmPowerBroadcastMessage(int event_id) { bool SystemMonitor::IsBatteryPower() { SYSTEM_POWER_STATUS status; if (!GetSystemPowerStatus(&status)) { - LOG(ERROR) << "GetSystemPowerStatus failed: " << GetLastError(); + DLOG(ERROR) << "GetSystemPowerStatus failed: " << GetLastError(); return false; } return (status.ACLineStatus == 0); diff --git a/base/test/test_file_util_mac.cc b/base/test/test_file_util_mac.cc index 903b475..7145e51 100644 --- a/base/test/test_file_util_mac.cc +++ b/base/test/test_file_util_mac.cc @@ -19,27 +19,27 @@ bool EvictFileFromSystemCache(const FilePath& file) { int64 length; if (!file_util::GetFileSize(file, &length)) { - LOG(ERROR) << "failed to get size of " << file.value(); + DLOG(ERROR) << "failed to get size of " << file.value(); return false; } // When a file is empty, we do not need to evict it from cache. // In fact, an attempt to map it to memory will result in error. if (length == 0) { - LOG(WARNING) << "file size is zero, will not attempt to map to memory"; + DLOG(WARNING) << "file size is zero, will not attempt to map to memory"; return true; } file_util::MemoryMappedFile mapped_file; if (!mapped_file.Initialize(file)) { - LOG(WARNING) << "failed to memory map " << file.value(); + DLOG(WARNING) << "failed to memory map " << file.value(); return false; } if (msync(const_cast<uint8*>(mapped_file.data()), mapped_file.length(), MS_INVALIDATE) != 0) { - LOG(WARNING) << "failed to invalidate memory map of " << file.value() - << ", errno: " << errno; + DLOG(WARNING) << "failed to invalidate memory map of " << file.value() + << ", errno: " << errno; return false; } diff --git a/base/test/test_file_util_posix.cc b/base/test/test_file_util_posix.cc index cca17b59..0096c9e 100644 --- a/base/test/test_file_util_posix.cc +++ b/base/test/test_file_util_posix.cc @@ -73,8 +73,8 @@ bool CopyRecursiveDirNoCache(const FilePath& source_dir, FileEnumerator::FindInfo info; FilePath current = source_dir; if (stat(source_dir.value().c_str(), &info.stat) < 0) { - LOG(ERROR) << "CopyRecursiveDirNoCache() couldn't stat source directory: " - << source_dir.value() << " errno = " << errno; + DLOG(ERROR) << "CopyRecursiveDirNoCache() couldn't stat source directory: " + << source_dir.value() << " errno = " << errno; success = false; } @@ -92,8 +92,8 @@ bool CopyRecursiveDirNoCache(const FilePath& source_dir, if (S_ISDIR(info.stat.st_mode)) { if (mkdir(target_path.value().c_str(), info.stat.st_mode & 01777) != 0 && errno != EEXIST) { - LOG(ERROR) << "CopyRecursiveDirNoCache() couldn't create directory: " << - target_path.value() << " errno = " << errno; + DLOG(ERROR) << "CopyRecursiveDirNoCache() couldn't create directory: " + << target_path.value() << " errno = " << errno; success = false; } } else if (S_ISREG(info.stat.st_mode)) { @@ -101,13 +101,13 @@ bool CopyRecursiveDirNoCache(const FilePath& source_dir, success = EvictFileFromSystemCache(target_path); DCHECK(success); } else { - LOG(ERROR) << "CopyRecursiveDirNoCache() couldn't create file: " << - target_path.value(); + DLOG(ERROR) << "CopyRecursiveDirNoCache() couldn't create file: " + << target_path.value(); success = false; } } else { - LOG(WARNING) << "CopyRecursiveDirNoCache() skipping non-regular file: " << - current.value(); + DLOG(WARNING) << "CopyRecursiveDirNoCache() skipping non-regular file: " + << current.value(); } current = traversal.Next(); diff --git a/base/threading/non_thread_safe_unittest.cc b/base/threading/non_thread_safe_unittest.cc index 01efe28..3236278 100644 --- a/base/threading/non_thread_safe_unittest.cc +++ b/base/threading/non_thread_safe_unittest.cc @@ -20,7 +20,7 @@ class NonThreadSafeClass : public NonThreadSafe { // Verifies that it was called on the same thread as the constructor. void DoStuff() { - CHECK(CalledOnValidThread()); + DCHECK(CalledOnValidThread()); } void DetachFromThread() { diff --git a/base/threading/platform_thread_mac.mm b/base/threading/platform_thread_mac.mm index cff7a1f..ef807eb 100644 --- a/base/threading/platform_thread_mac.mm +++ b/base/threading/platform_thread_mac.mm @@ -77,7 +77,7 @@ void SetPriorityNormal(mach_port_t mach_thread_id) { THREAD_STANDARD_POLICY_COUNT); if (result != KERN_SUCCESS) - VLOG(1) << "thread_policy_set() failure: " << result; + DVLOG(1) << "thread_policy_set() failure: " << result; } // Enables time-contraint policy and priority suitable for low-latency, @@ -100,7 +100,7 @@ void SetPriorityRealtimeAudio(mach_port_t mach_thread_id) { (thread_policy_t)&policy, THREAD_EXTENDED_POLICY_COUNT); if (result != KERN_SUCCESS) { - VLOG(1) << "thread_policy_set() failure: " << result; + DVLOG(1) << "thread_policy_set() failure: " << result; return; } @@ -112,7 +112,7 @@ void SetPriorityRealtimeAudio(mach_port_t mach_thread_id) { (thread_policy_t)&precedence, THREAD_PRECEDENCE_POLICY_COUNT); if (result != KERN_SUCCESS) { - VLOG(1) << "thread_policy_set() failure: " << result; + DVLOG(1) << "thread_policy_set() failure: " << result; return; } @@ -156,7 +156,7 @@ void SetPriorityRealtimeAudio(mach_port_t mach_thread_id) { (thread_policy_t)&time_constraints, THREAD_TIME_CONSTRAINT_POLICY_COUNT); if (result != KERN_SUCCESS) - VLOG(1) << "thread_policy_set() failure: " << result; + DVLOG(1) << "thread_policy_set() failure: " << result; return; } diff --git a/base/threading/platform_thread_posix.cc b/base/threading/platform_thread_posix.cc index d1fb7bb..e6b8e64 100644 --- a/base/threading/platform_thread_posix.cc +++ b/base/threading/platform_thread_posix.cc @@ -186,14 +186,14 @@ void PlatformThread::SetName(const char* name) { int err = dynamic_pthread_setname_np(pthread_self(), shortened_name.c_str()); if (err < 0) - LOG(ERROR) << "pthread_setname_np: " << safe_strerror(err); + DLOG(ERROR) << "pthread_setname_np: " << safe_strerror(err); } else { // Implementing this function without glibc is simple enough. (We // don't do the name length clipping as above because it will be // truncated by the callee (see TASK_COMM_LEN above).) int err = prctl(PR_SET_NAME, name); if (err < 0) - PLOG(ERROR) << "prctl(PR_SET_NAME)"; + DPLOG(ERROR) << "prctl(PR_SET_NAME)"; } } #elif defined(OS_MACOSX) diff --git a/base/threading/simple_thread.cc b/base/threading/simple_thread.cc index 4441477..a5dd763 100644 --- a/base/threading/simple_thread.cc +++ b/base/threading/simple_thread.cc @@ -29,7 +29,7 @@ SimpleThread::~SimpleThread() { void SimpleThread::Start() { DCHECK(!HasBeenStarted()) << "Tried to Start a thread multiple times."; bool success = PlatformThread::Create(options_.stack_size(), this, &thread_); - CHECK(success); + DCHECK(success); event_.Wait(); // Wait for the thread to complete initialization. } diff --git a/base/threading/thread_checker_unittest.cc b/base/threading/thread_checker_unittest.cc index 2808048..e1e5715 100644 --- a/base/threading/thread_checker_unittest.cc +++ b/base/threading/thread_checker_unittest.cc @@ -20,7 +20,7 @@ class ThreadCheckerClass : public ThreadChecker { // Verifies that it was called on the same thread as the constructor. void DoStuff() { - CHECK(CalledOnValidThread()); + DCHECK(CalledOnValidThread()); } void DetachFromThread() { diff --git a/base/threading/thread_local_posix.cc b/base/threading/thread_local_posix.cc index 2071ad8..4951006 100644 --- a/base/threading/thread_local_posix.cc +++ b/base/threading/thread_local_posix.cc @@ -32,7 +32,7 @@ void* ThreadLocalPlatform::GetValueFromSlot(SlotType& slot) { // static void ThreadLocalPlatform::SetValueInSlot(SlotType& slot, void* value) { int error = pthread_setspecific(slot, value); - CHECK_EQ(error, 0); + DCHECK_EQ(error, 0); } } // namespace internal diff --git a/base/threading/thread_local_win.cc b/base/threading/thread_local_win.cc index 56d3a3a..32cceeb 100644 --- a/base/threading/thread_local_win.cc +++ b/base/threading/thread_local_win.cc @@ -33,7 +33,7 @@ void* ThreadLocalPlatform::GetValueFromSlot(SlotType& slot) { // static void ThreadLocalPlatform::SetValueInSlot(SlotType& slot, void* value) { if (!TlsSetValue(slot, value)) { - LOG(FATAL) << "Failed to TlsSetValue()."; + DLOG(FATAL) << "Failed to TlsSetValue()."; } } diff --git a/base/vlog.cc b/base/vlog.cc index 41bf2a5..332de38 100644 --- a/base/vlog.cc +++ b/base/vlog.cc @@ -52,23 +52,23 @@ VlogInfo::VlogInfo(const std::string& v_switch, if (base::StringToInt(v_switch, &vlog_level)) { SetMaxVlogLevel(vlog_level); } else { - LOG(WARNING) << "Could not parse v switch \"" << v_switch << "\""; + DLOG(WARNING) << "Could not parse v switch \"" << v_switch << "\""; } } std::vector<KVPair> kv_pairs; if (!base::SplitStringIntoKeyValuePairs( vmodule_switch, '=', ',', &kv_pairs)) { - LOG(WARNING) << "Could not fully parse vmodule switch \"" - << vmodule_switch << "\""; + DLOG(WARNING) << "Could not fully parse vmodule switch \"" + << vmodule_switch << "\""; } for (std::vector<KVPair>::const_iterator it = kv_pairs.begin(); it != kv_pairs.end(); ++it) { VmodulePattern pattern(it->first); if (!base::StringToInt(it->second, &pattern.vlog_level)) { - LOG(WARNING) << "Parsed vlog level for \"" - << it->first << "=" << it->second - << "\" as " << pattern.vlog_level; + DLOG(WARNING) << "Parsed vlog level for \"" + << it->first << "=" << it->second + << "\" as " << pattern.vlog_level; } vmodule_levels_.push_back(pattern); } diff --git a/base/win/i18n.cc b/base/win/i18n.cc index 59480f2..9e523a1 100644 --- a/base/win/i18n.cc +++ b/base/win/i18n.cc @@ -75,7 +75,7 @@ bool GetMUIPreferredUILanguageList(LanguageFunction function, ULONG flags, << "Failed getting size of preferred UI languages."; } } else { - VLOG(2) << "MUI not available."; + DVLOG(2) << "MUI not available."; } } else { NOTREACHED() << "kernel32.dll not found."; |