OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/trace_event.h" | 5 #include "base/trace_event.h" |
6 | 6 |
7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 "BEGIN", | 22 "BEGIN", |
23 "END", | 23 "END", |
24 "INSTANT" | 24 "INSTANT" |
25 }; | 25 }; |
26 | 26 |
27 static const FilePath::CharType* kLogFileName = | 27 static const FilePath::CharType* kLogFileName = |
28 FILE_PATH_LITERAL("trace_%d.log"); | 28 FILE_PATH_LITERAL("trace_%d.log"); |
29 | 29 |
30 TraceLog::TraceLog() : enabled_(false), log_file_(NULL) { | 30 TraceLog::TraceLog() : enabled_(false), log_file_(NULL) { |
31 base::ProcessHandle proc = base::GetCurrentProcessHandle(); | 31 base::ProcessHandle proc = base::GetCurrentProcessHandle(); |
| 32 #if !defined(OS_MACOSX) |
32 process_metrics_.reset(base::ProcessMetrics::CreateProcessMetrics(proc)); | 33 process_metrics_.reset(base::ProcessMetrics::CreateProcessMetrics(proc)); |
| 34 #else |
| 35 // The default port provider is sufficient to get data for the current |
| 36 // process. |
| 37 process_metrics_.reset(base::ProcessMetrics::CreateProcessMetrics(proc, |
| 38 NULL)); |
| 39 #endif |
33 } | 40 } |
34 | 41 |
35 TraceLog::~TraceLog() { | 42 TraceLog::~TraceLog() { |
36 Stop(); | 43 Stop(); |
37 } | 44 } |
38 | 45 |
39 // static | 46 // static |
40 bool TraceLog::IsTracing() { | 47 bool TraceLog::IsTracing() { |
41 TraceLog* trace = Singleton<TraceLog>::get(); | 48 TraceLog* trace = Singleton<TraceLog>::get(); |
42 return trace->enabled_; | 49 return trace->enabled_; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 Log(msg); | 155 Log(msg); |
149 } | 156 } |
150 | 157 |
151 void TraceLog::Log(const std::string& msg) { | 158 void TraceLog::Log(const std::string& msg) { |
152 AutoLock lock(file_lock_); | 159 AutoLock lock(file_lock_); |
153 | 160 |
154 fprintf(log_file_, "%s", msg.c_str()); | 161 fprintf(log_file_, "%s", msg.c_str()); |
155 } | 162 } |
156 | 163 |
157 } // namespace base | 164 } // namespace base |
OLD | NEW |