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/location.h" | 8 #include "base/location.h" |
9 #include "base/memory/ref_counted_memory.h" | 9 #include "base/memory/ref_counted_memory.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 } | 89 } |
90 } | 90 } |
91 | 91 |
92 void TracingManager::StartTracing() { | 92 void TracingManager::StartTracing() { |
93 content::TracingController::GetInstance()->StartTracing( | 93 content::TracingController::GetInstance()->StartTracing( |
94 base::trace_event::TraceConfig(), | 94 base::trace_event::TraceConfig(), |
95 content::TracingController::StartTracingDoneCallback()); | 95 content::TracingController::StartTracingDoneCallback()); |
96 } | 96 } |
97 | 97 |
98 void TracingManager::OnTraceDataCollected( | 98 void TracingManager::OnTraceDataCollected( |
99 scoped_ptr<const base::DictionaryValue> metadata, | 99 std::unique_ptr<const base::DictionaryValue> metadata, |
100 base::RefCountedString* trace_data) { | 100 base::RefCountedString* trace_data) { |
101 if (!current_trace_id_) | 101 if (!current_trace_id_) |
102 return; | 102 return; |
103 | 103 |
104 std::string output_val; | 104 std::string output_val; |
105 feedback_util::ZipString( | 105 feedback_util::ZipString( |
106 base::FilePath(kTracingFilename), trace_data->data(), &output_val); | 106 base::FilePath(kTracingFilename), trace_data->data(), &output_val); |
107 | 107 |
108 scoped_refptr<base::RefCountedString> output( | 108 scoped_refptr<base::RefCountedString> output( |
109 base::RefCountedString::TakeString(&output_val)); | 109 base::RefCountedString::TakeString(&output_val)); |
110 | 110 |
111 trace_data_[current_trace_id_] = output; | 111 trace_data_[current_trace_id_] = output; |
112 | 112 |
113 if (!trace_callback_.is_null()) { | 113 if (!trace_callback_.is_null()) { |
114 trace_callback_.Run(output); | 114 trace_callback_.Run(output); |
115 trace_callback_.Reset(); | 115 trace_callback_.Reset(); |
116 } | 116 } |
117 | 117 |
118 current_trace_id_ = 0; | 118 current_trace_id_ = 0; |
119 | 119 |
120 // Tracing has to be restarted asynchronous, so the TracingController can | 120 // Tracing has to be restarted asynchronous, so the TracingController can |
121 // clean up. | 121 // clean up. |
122 base::ThreadTaskRunnerHandle::Get()->PostTask( | 122 base::ThreadTaskRunnerHandle::Get()->PostTask( |
123 FROM_HERE, base::Bind(&TracingManager::StartTracing, | 123 FROM_HERE, base::Bind(&TracingManager::StartTracing, |
124 weak_ptr_factory_.GetWeakPtr())); | 124 weak_ptr_factory_.GetWeakPtr())); |
125 } | 125 } |
126 | 126 |
127 // static | 127 // static |
128 scoped_ptr<TracingManager> TracingManager::Create() { | 128 std::unique_ptr<TracingManager> TracingManager::Create() { |
129 if (g_tracing_manager) | 129 if (g_tracing_manager) |
130 return scoped_ptr<TracingManager>(); | 130 return std::unique_ptr<TracingManager>(); |
131 return scoped_ptr<TracingManager>(new TracingManager()); | 131 return std::unique_ptr<TracingManager>(new TracingManager()); |
132 } | 132 } |
133 | 133 |
134 TracingManager* TracingManager::Get() { | 134 TracingManager* TracingManager::Get() { |
135 return g_tracing_manager; | 135 return g_tracing_manager; |
136 } | 136 } |
OLD | NEW |