| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/logging.h" | 5 #include "base/logging.h" |
| 6 | 6 |
| 7 #include <limits.h> | 7 #include <limits.h> |
| 8 #include <stdint.h> |
| 9 |
| 10 #include "base/macros.h" |
| 11 #include "build/build_config.h" |
| 8 | 12 |
| 9 #if defined(OS_WIN) | 13 #if defined(OS_WIN) |
| 10 #include <io.h> | 14 #include <io.h> |
| 11 #include <windows.h> | 15 #include <windows.h> |
| 12 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
| 13 #include "base/files/file_util.h" | 17 #include "base/files/file_util.h" |
| 14 typedef HANDLE FileHandle; | 18 typedef HANDLE FileHandle; |
| 15 typedef HANDLE MutexHandle; | 19 typedef HANDLE MutexHandle; |
| 16 // Windows warns on using write(). It prefers _write(). | 20 // Windows warns on using write(). It prefers _write(). |
| 17 #define write(fd, buf, count) _write(fd, buf, static_cast<unsigned int>(count)) | 21 #define write(fd, buf, count) _write(fd, buf, static_cast<unsigned int>(count)) |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 bool show_error_dialogs = false; | 125 bool show_error_dialogs = false; |
| 122 | 126 |
| 123 // An assert handler override specified by the client to be called instead of | 127 // An assert handler override specified by the client to be called instead of |
| 124 // the debug message dialog and process termination. | 128 // the debug message dialog and process termination. |
| 125 LogAssertHandlerFunction log_assert_handler = nullptr; | 129 LogAssertHandlerFunction log_assert_handler = nullptr; |
| 126 // A log message handler that gets notified of every log message we process. | 130 // A log message handler that gets notified of every log message we process. |
| 127 LogMessageHandlerFunction log_message_handler = nullptr; | 131 LogMessageHandlerFunction log_message_handler = nullptr; |
| 128 | 132 |
| 129 // Helper functions to wrap platform differences. | 133 // Helper functions to wrap platform differences. |
| 130 | 134 |
| 131 int32 CurrentProcessId() { | 135 int32_t CurrentProcessId() { |
| 132 #if defined(OS_WIN) | 136 #if defined(OS_WIN) |
| 133 return GetCurrentProcessId(); | 137 return GetCurrentProcessId(); |
| 134 #elif defined(OS_POSIX) | 138 #elif defined(OS_POSIX) |
| 135 return getpid(); | 139 return getpid(); |
| 136 #endif | 140 #endif |
| 137 } | 141 } |
| 138 | 142 |
| 139 uint64 TickCount() { | 143 uint64_t TickCount() { |
| 140 #if defined(OS_WIN) | 144 #if defined(OS_WIN) |
| 141 return GetTickCount(); | 145 return GetTickCount(); |
| 142 #elif defined(OS_MACOSX) | 146 #elif defined(OS_MACOSX) |
| 143 return mach_absolute_time(); | 147 return mach_absolute_time(); |
| 144 #elif defined(OS_NACL) | 148 #elif defined(OS_NACL) |
| 145 // NaCl sadly does not have _POSIX_TIMERS enabled in sys/features.h | 149 // NaCl sadly does not have _POSIX_TIMERS enabled in sys/features.h |
| 146 // So we have to use clock() for now. | 150 // So we have to use clock() for now. |
| 147 return clock(); | 151 return clock(); |
| 148 #elif defined(OS_POSIX) | 152 #elif defined(OS_POSIX) |
| 149 struct timespec ts; | 153 struct timespec ts; |
| 150 clock_gettime(CLOCK_MONOTONIC, &ts); | 154 clock_gettime(CLOCK_MONOTONIC, &ts); |
| 151 | 155 |
| 152 uint64 absolute_micro = | 156 uint64_t absolute_micro = static_cast<int64_t>(ts.tv_sec) * 1000000 + |
| 153 static_cast<int64>(ts.tv_sec) * 1000000 + | 157 static_cast<int64_t>(ts.tv_nsec) / 1000; |
| 154 static_cast<int64>(ts.tv_nsec) / 1000; | |
| 155 | 158 |
| 156 return absolute_micro; | 159 return absolute_micro; |
| 157 #endif | 160 #endif |
| 158 } | 161 } |
| 159 | 162 |
| 160 void DeleteFilePath(const PathString& log_name) { | 163 void DeleteFilePath(const PathString& log_name) { |
| 161 #if defined(OS_WIN) | 164 #if defined(OS_WIN) |
| 162 DeleteFile(log_name.c_str()); | 165 DeleteFile(log_name.c_str()); |
| 163 #elif defined(OS_NACL) | 166 #elif defined(OS_NACL) |
| 164 // Do nothing; unlink() isn't supported on NaCl. | 167 // Do nothing; unlink() isn't supported on NaCl. |
| (...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 907 BASE_EXPORT void LogErrorNotReached(const char* file, int line) { | 910 BASE_EXPORT void LogErrorNotReached(const char* file, int line) { |
| 908 LogMessage(file, line, LOG_ERROR).stream() | 911 LogMessage(file, line, LOG_ERROR).stream() |
| 909 << "NOTREACHED() hit."; | 912 << "NOTREACHED() hit."; |
| 910 } | 913 } |
| 911 | 914 |
| 912 } // namespace logging | 915 } // namespace logging |
| 913 | 916 |
| 914 std::ostream& std::operator<<(std::ostream& out, const wchar_t* wstr) { | 917 std::ostream& std::operator<<(std::ostream& out, const wchar_t* wstr) { |
| 915 return out << base::WideToUTF8(wstr); | 918 return out << base::WideToUTF8(wstr); |
| 916 } | 919 } |
| OLD | NEW |