| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/feedback/tracing_manager.h" | 5 #include "components/feedback/tracing_manager.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/memory/ref_counted_memory.h" | 10 #include "base/memory/ref_counted_memory.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 // If the trace has already been requested, provide an empty string. | 84 // If the trace has already been requested, provide an empty string. |
| 85 if (!trace_callback_.is_null()) { | 85 if (!trace_callback_.is_null()) { |
| 86 trace_callback_.Run(scoped_refptr<base::RefCountedString>()); | 86 trace_callback_.Run(scoped_refptr<base::RefCountedString>()); |
| 87 trace_callback_.Reset(); | 87 trace_callback_.Reset(); |
| 88 } | 88 } |
| 89 } | 89 } |
| 90 } | 90 } |
| 91 | 91 |
| 92 void TracingManager::StartTracing() { | 92 void TracingManager::StartTracing() { |
| 93 content::TracingController::GetInstance()->EnableRecording( | 93 content::TracingController::GetInstance()->EnableRecording( |
| 94 "", content::TracingController::DEFAULT_OPTIONS, | 94 base::debug::CategoryFilter(), |
| 95 base::debug::TraceOptions(), |
| 95 content::TracingController::EnableRecordingDoneCallback()); | 96 content::TracingController::EnableRecordingDoneCallback()); |
| 96 } | 97 } |
| 97 | 98 |
| 98 void TracingManager::OnTraceDataCollected(const base::FilePath& path) { | 99 void TracingManager::OnTraceDataCollected(const base::FilePath& path) { |
| 99 if (!current_trace_id_) | 100 if (!current_trace_id_) |
| 100 return; | 101 return; |
| 101 | 102 |
| 102 std::string data; | 103 std::string data; |
| 103 if (!base::ReadFileToString(path, &data)) { | 104 if (!base::ReadFileToString(path, &data)) { |
| 104 LOG(ERROR) << "Failed to read trace data from: " << path.value(); | 105 LOG(ERROR) << "Failed to read trace data from: " << path.value(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 133 // static | 134 // static |
| 134 scoped_ptr<TracingManager> TracingManager::Create() { | 135 scoped_ptr<TracingManager> TracingManager::Create() { |
| 135 if (g_tracing_manager) | 136 if (g_tracing_manager) |
| 136 return scoped_ptr<TracingManager>(); | 137 return scoped_ptr<TracingManager>(); |
| 137 return scoped_ptr<TracingManager>(new TracingManager()); | 138 return scoped_ptr<TracingManager>(new TracingManager()); |
| 138 } | 139 } |
| 139 | 140 |
| 140 TracingManager* TracingManager::Get() { | 141 TracingManager* TracingManager::Get() { |
| 141 return g_tracing_manager; | 142 return g_tracing_manager; |
| 142 } | 143 } |
| OLD | NEW |