Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(228)

Side by Side Diff: base/logging.cc

Issue 9252014: Temporarily revert 117127 for perf analysis. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | base/threading/platform_thread_posix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <io.h> 8 #include <io.h>
9 #include <windows.h> 9 #include <windows.h>
10 typedef HANDLE FileHandle; 10 typedef HANDLE FileHandle;
11 typedef HANDLE MutexHandle; 11 typedef HANDLE MutexHandle;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #include <iomanip> 44 #include <iomanip>
45 #include <ostream> 45 #include <ostream>
46 46
47 #include "base/base_switches.h" 47 #include "base/base_switches.h"
48 #include "base/command_line.h" 48 #include "base/command_line.h"
49 #include "base/debug/debugger.h" 49 #include "base/debug/debugger.h"
50 #include "base/debug/stack_trace.h" 50 #include "base/debug/stack_trace.h"
51 #include "base/eintr_wrapper.h" 51 #include "base/eintr_wrapper.h"
52 #include "base/string_piece.h" 52 #include "base/string_piece.h"
53 #include "base/synchronization/lock_impl.h" 53 #include "base/synchronization/lock_impl.h"
54 #include "base/threading/platform_thread.h"
55 #include "base/utf_string_conversions.h" 54 #include "base/utf_string_conversions.h"
56 #include "base/vlog.h" 55 #include "base/vlog.h"
57 #if defined(OS_POSIX) 56 #if defined(OS_POSIX)
58 #include "base/safe_strerror_posix.h" 57 #include "base/safe_strerror_posix.h"
59 #endif 58 #endif
60 59
61 #if defined(OS_ANDROID) 60 #if defined(OS_ANDROID)
62 #include <android/log.h> 61 #include <android/log.h>
63 #endif 62 #endif
64 63
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 // Helper functions to wrap platform differences. 122 // Helper functions to wrap platform differences.
124 123
125 int32 CurrentProcessId() { 124 int32 CurrentProcessId() {
126 #if defined(OS_WIN) 125 #if defined(OS_WIN)
127 return GetCurrentProcessId(); 126 return GetCurrentProcessId();
128 #elif defined(OS_POSIX) 127 #elif defined(OS_POSIX)
129 return getpid(); 128 return getpid();
130 #endif 129 #endif
131 } 130 }
132 131
132 int32 CurrentThreadId() {
133 #if defined(OS_WIN)
134 return GetCurrentThreadId();
135 #elif defined(OS_MACOSX)
136 return mach_thread_self();
137 #elif defined(OS_LINUX)
138 return syscall(__NR_gettid);
139 #elif defined(OS_ANDROID)
140 return gettid();
141 #elif defined(OS_NACL)
142 return pthread_self();
143 #elif defined(OS_POSIX)
144 return reinterpret_cast<int64>(pthread_self());
145 #endif
146 }
147
133 uint64 TickCount() { 148 uint64 TickCount() {
134 #if defined(OS_WIN) 149 #if defined(OS_WIN)
135 return GetTickCount(); 150 return GetTickCount();
136 #elif defined(OS_MACOSX) 151 #elif defined(OS_MACOSX)
137 return mach_absolute_time(); 152 return mach_absolute_time();
138 #elif defined(OS_NACL) 153 #elif defined(OS_NACL)
139 // NaCl sadly does not have _POSIX_TIMERS enabled in sys/features.h 154 // NaCl sadly does not have _POSIX_TIMERS enabled in sys/features.h
140 // So we have to use clock() for now. 155 // So we have to use clock() for now.
141 return clock(); 156 return clock();
142 #elif defined(OS_POSIX) 157 #elif defined(OS_POSIX)
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 size_t last_slash_pos = filename.find_last_of("\\/"); 683 size_t last_slash_pos = filename.find_last_of("\\/");
669 if (last_slash_pos != base::StringPiece::npos) 684 if (last_slash_pos != base::StringPiece::npos)
670 filename.remove_prefix(last_slash_pos + 1); 685 filename.remove_prefix(last_slash_pos + 1);
671 686
672 // TODO(darin): It might be nice if the columns were fixed width. 687 // TODO(darin): It might be nice if the columns were fixed width.
673 688
674 stream_ << '['; 689 stream_ << '[';
675 if (log_process_id) 690 if (log_process_id)
676 stream_ << CurrentProcessId() << ':'; 691 stream_ << CurrentProcessId() << ':';
677 if (log_thread_id) 692 if (log_thread_id)
678 stream_ << base::PlatformThread::CurrentId() << ':'; 693 stream_ << CurrentThreadId() << ':';
679 if (log_timestamp) { 694 if (log_timestamp) {
680 time_t t = time(NULL); 695 time_t t = time(NULL);
681 struct tm local_time = {0}; 696 struct tm local_time = {0};
682 #if _MSC_VER >= 1400 697 #if _MSC_VER >= 1400
683 localtime_s(&local_time, &t); 698 localtime_s(&local_time, &t);
684 #else 699 #else
685 localtime_r(&t, &local_time); 700 localtime_r(&t, &local_time);
686 #endif 701 #endif
687 struct tm* tm_time = &local_time; 702 struct tm* tm_time = &local_time;
688 stream_ << std::setfill('0') 703 stream_ << std::setfill('0')
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 860
846 // This was defined at the beginnig of this file. 861 // This was defined at the beginnig of this file.
847 #undef write 862 #undef write
848 863
849 std::ostream& operator<<(std::ostream& o, const StringPiece& piece) { 864 std::ostream& operator<<(std::ostream& o, const StringPiece& piece) {
850 o.write(piece.data(), static_cast<std::streamsize>(piece.size())); 865 o.write(piece.data(), static_cast<std::streamsize>(piece.size()));
851 return o; 866 return o;
852 } 867 }
853 868
854 } // namespace base 869 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/threading/platform_thread_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698