| OLD | NEW |
| 1 // Copyright (c) 2011 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 "content/browser/trace_controller.h" | 5 #include "content/browser/trace_controller.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "content/browser/browser_message_filter.h" | 9 #include "content/browser/browser_message_filter.h" |
| 10 #include "content/browser/trace_message_filter.h" | 10 #include "content/browser/trace_message_filter.h" |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 std::vector<std::string> categories; | 217 std::vector<std::string> categories; |
| 218 base::debug::TraceLog::GetInstance()->GetKnownCategories(&categories); | 218 base::debug::TraceLog::GetInstance()->GetKnownCategories(&categories); |
| 219 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 219 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 220 base::Bind(&TraceController::OnEndTracingAck, base::Unretained(this), | 220 base::Bind(&TraceController::OnEndTracingAck, base::Unretained(this), |
| 221 categories)); | 221 categories)); |
| 222 } | 222 } |
| 223 } | 223 } |
| 224 | 224 |
| 225 void TraceController::OnTraceDataCollected( | 225 void TraceController::OnTraceDataCollected( |
| 226 const scoped_refptr<base::debug::TraceLog::RefCountedString>& | 226 const scoped_refptr<base::debug::TraceLog::RefCountedString>& |
| 227 events_str_ptr) { | 227 json_events_str_ptr) { |
| 228 // OnTraceDataCollected may be called from any browser thread, either by the | 228 // OnTraceDataCollected may be called from any browser thread, either by the |
| 229 // local event trace system or from child processes via TraceMessageFilter. | 229 // local event trace system or from child processes via TraceMessageFilter. |
| 230 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 230 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| 231 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 231 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 232 base::Bind(&TraceController::OnTraceDataCollected, | 232 base::Bind(&TraceController::OnTraceDataCollected, |
| 233 base::Unretained(this), events_str_ptr)); | 233 base::Unretained(this), json_events_str_ptr)); |
| 234 return; | 234 return; |
| 235 } | 235 } |
| 236 | 236 |
| 237 // Drop trace events if we are just getting categories. | 237 // Drop trace events if we are just getting categories. |
| 238 if (subscriber_ && !is_get_categories_) | 238 if (subscriber_ && !is_get_categories_) |
| 239 subscriber_->OnTraceDataCollected(events_str_ptr->data); | 239 subscriber_->OnTraceDataCollected(json_events_str_ptr->data); |
| 240 } | 240 } |
| 241 | 241 |
| 242 void TraceController::OnTraceBufferFull() { | 242 void TraceController::OnTraceBufferFull() { |
| 243 // OnTraceBufferFull may be called from any browser thread, either by the | 243 // OnTraceBufferFull may be called from any browser thread, either by the |
| 244 // local event trace system or from child processes via TraceMessageFilter. | 244 // local event trace system or from child processes via TraceMessageFilter. |
| 245 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 245 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| 246 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 246 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 247 base::Bind(&TraceController::OnTraceBufferFull, | 247 base::Bind(&TraceController::OnTraceBufferFull, |
| 248 base::Unretained(this))); | 248 base::Unretained(this))); |
| 249 return; | 249 return; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 276 if (pending_bpf_ack_count_ == 1) { | 276 if (pending_bpf_ack_count_ == 1) { |
| 277 // The last ack represents local trace, so we need to ack it now. Note that | 277 // The last ack represents local trace, so we need to ack it now. Note that |
| 278 // this code only executes if there were child processes. | 278 // this code only executes if there were child processes. |
| 279 float bpf = base::debug::TraceLog::GetInstance()->GetBufferPercentFull(); | 279 float bpf = base::debug::TraceLog::GetInstance()->GetBufferPercentFull(); |
| 280 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 280 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 281 base::Bind(&TraceController::OnTraceBufferPercentFullReply, | 281 base::Bind(&TraceController::OnTraceBufferPercentFullReply, |
| 282 base::Unretained(this), bpf)); | 282 base::Unretained(this), bpf)); |
| 283 } | 283 } |
| 284 } | 284 } |
| 285 | 285 |
| OLD | NEW |