| 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) | |
| 33 process_metrics_.reset(base::ProcessMetrics::CreateProcessMetrics(proc)); | 32 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 | |
| 40 } | 33 } |
| 41 | 34 |
| 42 TraceLog::~TraceLog() { | 35 TraceLog::~TraceLog() { |
| 43 Stop(); | 36 Stop(); |
| 44 } | 37 } |
| 45 | 38 |
| 46 // static | 39 // static |
| 47 bool TraceLog::IsTracing() { | 40 bool TraceLog::IsTracing() { |
| 48 TraceLog* trace = Singleton<TraceLog>::get(); | 41 TraceLog* trace = Singleton<TraceLog>::get(); |
| 49 return trace->enabled_; | 42 return trace->enabled_; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 Log(msg); | 148 Log(msg); |
| 156 } | 149 } |
| 157 | 150 |
| 158 void TraceLog::Log(const std::string& msg) { | 151 void TraceLog::Log(const std::string& msg) { |
| 159 AutoLock lock(file_lock_); | 152 AutoLock lock(file_lock_); |
| 160 | 153 |
| 161 fprintf(log_file_, "%s", msg.c_str()); | 154 fprintf(log_file_, "%s", msg.c_str()); |
| 162 } | 155 } |
| 163 | 156 |
| 164 } // namespace base | 157 } // namespace base |
| OLD | NEW |