Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/tracing/tracing_ui.h" | 5 #include "content/browser/tracing/tracing_ui.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 365 web_ui()->GetWebContents()->GetView()->GetTopLevelNativeWindow(), NULL); | 365 web_ui()->GetWebContents()->GetView()->GetTopLevelNativeWindow(), NULL); |
| 366 } | 366 } |
| 367 | 367 |
| 368 void TracingMessageHandler::SaveTraceFileComplete() { | 368 void TracingMessageHandler::SaveTraceFileComplete() { |
| 369 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 369 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 370 web_ui()->CallJavascriptFunction("tracingController.onSaveTraceFileComplete"); | 370 web_ui()->CallJavascriptFunction("tracingController.onSaveTraceFileComplete"); |
| 371 } | 371 } |
| 372 | 372 |
| 373 void TracingMessageHandler::OnBeginTracing(const base::ListValue* args) { | 373 void TracingMessageHandler::OnBeginTracing(const base::ListValue* args) { |
| 374 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 374 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 375 DCHECK_EQ(args->GetSize(), (size_t) 2); | 375 DCHECK_GE(args->GetSize(), (size_t) 2); |
| 376 DCHECK_LE(args->GetSize(), (size_t) 3); | |
| 376 | 377 |
| 377 bool system_tracing_requested = false; | 378 bool system_tracing_requested = false; |
| 378 bool ok = args->GetBoolean(0, &system_tracing_requested); | 379 bool ok = args->GetBoolean(0, &system_tracing_requested); |
| 379 DCHECK(ok); | 380 DCHECK(ok); |
| 380 | 381 |
| 381 std::string chrome_categories; | 382 std::string chrome_categories; |
| 382 ok = args->GetString(1, &chrome_categories); | 383 ok = args->GetString(1, &chrome_categories); |
| 383 DCHECK(ok); | 384 DCHECK(ok); |
| 384 | 385 |
| 386 base::debug::TraceLog::TraceMode mode = base::debug::TraceLog::UNTIL_FULL; | |
| 387 if (args->GetSize() == 3) { | |
|
nduca
2013/02/21 05:40:16
would be less fragile if you wrote >= 3
dsinclair
2013/02/21 16:26:04
Done.
| |
| 388 std::string mode_; | |
| 389 ok = args->GetString(2, &mode_); | |
| 390 DCHECK(ok); | |
| 391 mode = base::debug::TraceLog::TraceModeFromString(mode_); | |
|
nduca
2013/02/21 05:40:16
might check with pavel, but i think you need to do
pfeldman
2013/02/21 05:49:24
Yep, you should have local conversion barrier in t
dsinclair
2013/02/21 16:26:04
Done.
dsinclair
2013/02/21 16:26:04
Done.
I've made it a comma separated list, so dev
| |
| 392 } | |
| 393 | |
| 385 trace_enabled_ = true; | 394 trace_enabled_ = true; |
| 386 // TODO(jbates) This may fail, but that's OK for current use cases. | 395 // TODO(jbates) This may fail, but that's OK for current use cases. |
| 387 // Ex: Multiple about:gpu traces can not trace simultaneously. | 396 // Ex: Multiple about:gpu traces can not trace simultaneously. |
| 388 // TODO(nduca) send feedback to javascript about whether or not BeginTracing | 397 // TODO(nduca) send feedback to javascript about whether or not BeginTracing |
| 389 // was successful. | 398 // was successful. |
| 390 TraceController::GetInstance()->BeginTracing(this, chrome_categories); | 399 TraceController::GetInstance()->BeginTracing(this, chrome_categories, mode); |
| 391 | 400 |
| 392 if (system_tracing_requested) { | 401 if (system_tracing_requested) { |
| 393 #if defined(OS_CHROMEOS) | 402 #if defined(OS_CHROMEOS) |
| 394 DCHECK(!system_trace_in_progress_); | 403 DCHECK(!system_trace_in_progress_); |
| 395 chromeos::DBusThreadManager::Get()->GetDebugDaemonClient()-> | 404 chromeos::DBusThreadManager::Get()->GetDebugDaemonClient()-> |
| 396 StartSystemTracing(); | 405 StartSystemTracing(); |
| 397 // TODO(sleffler) async, could wait for completion | 406 // TODO(sleffler) async, could wait for completion |
| 398 system_trace_in_progress_ = true; | 407 system_trace_in_progress_ = true; |
| 399 #endif | 408 #endif |
| 400 } | 409 } |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 484 TracingUI::TracingUI(WebUI* web_ui) : WebUIController(web_ui) { | 493 TracingUI::TracingUI(WebUI* web_ui) : WebUIController(web_ui) { |
| 485 web_ui->AddMessageHandler(new TracingMessageHandler()); | 494 web_ui->AddMessageHandler(new TracingMessageHandler()); |
| 486 | 495 |
| 487 // Set up the chrome://tracing/ source. | 496 // Set up the chrome://tracing/ source. |
| 488 BrowserContext* browser_context = | 497 BrowserContext* browser_context = |
| 489 web_ui->GetWebContents()->GetBrowserContext(); | 498 web_ui->GetWebContents()->GetBrowserContext(); |
| 490 WebUIDataSource::Add(browser_context, CreateTracingHTMLSource()); | 499 WebUIDataSource::Add(browser_context, CreateTracingHTMLSource()); |
| 491 } | 500 } |
| 492 | 501 |
| 493 } // namespace content | 502 } // namespace content |
| OLD | NEW |