| 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::Options options = |
| 387 base::debug::TraceLog::RECORD_UNTIL_FULL; |
| 388 if (args->GetSize() >= 3) { |
| 389 std::string options_; |
| 390 ok = args->GetString(2, &options_); |
| 391 DCHECK(ok); |
| 392 options = base::debug::TraceLog::TraceOptionsFromString(options_); |
| 393 } |
| 394 |
| 385 trace_enabled_ = true; | 395 trace_enabled_ = true; |
| 386 // TODO(jbates) This may fail, but that's OK for current use cases. | 396 // TODO(jbates) This may fail, but that's OK for current use cases. |
| 387 // Ex: Multiple about:gpu traces can not trace simultaneously. | 397 // Ex: Multiple about:gpu traces can not trace simultaneously. |
| 388 // TODO(nduca) send feedback to javascript about whether or not BeginTracing | 398 // TODO(nduca) send feedback to javascript about whether or not BeginTracing |
| 389 // was successful. | 399 // was successful. |
| 390 TraceController::GetInstance()->BeginTracing(this, chrome_categories); | 400 TraceController::GetInstance()->BeginTracing(this, chrome_categories, |
| 401 options); |
| 391 | 402 |
| 392 if (system_tracing_requested) { | 403 if (system_tracing_requested) { |
| 393 #if defined(OS_CHROMEOS) | 404 #if defined(OS_CHROMEOS) |
| 394 DCHECK(!system_trace_in_progress_); | 405 DCHECK(!system_trace_in_progress_); |
| 395 chromeos::DBusThreadManager::Get()->GetDebugDaemonClient()-> | 406 chromeos::DBusThreadManager::Get()->GetDebugDaemonClient()-> |
| 396 StartSystemTracing(); | 407 StartSystemTracing(); |
| 397 // TODO(sleffler) async, could wait for completion | 408 // TODO(sleffler) async, could wait for completion |
| 398 system_trace_in_progress_ = true; | 409 system_trace_in_progress_ = true; |
| 399 #endif | 410 #endif |
| 400 } | 411 } |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 TracingUI::TracingUI(WebUI* web_ui) : WebUIController(web_ui) { | 495 TracingUI::TracingUI(WebUI* web_ui) : WebUIController(web_ui) { |
| 485 web_ui->AddMessageHandler(new TracingMessageHandler()); | 496 web_ui->AddMessageHandler(new TracingMessageHandler()); |
| 486 | 497 |
| 487 // Set up the chrome://tracing/ source. | 498 // Set up the chrome://tracing/ source. |
| 488 BrowserContext* browser_context = | 499 BrowserContext* browser_context = |
| 489 web_ui->GetWebContents()->GetBrowserContext(); | 500 web_ui->GetWebContents()->GetBrowserContext(); |
| 490 WebUIDataSource::Add(browser_context, CreateTracingHTMLSource()); | 501 WebUIDataSource::Add(browser_context, CreateTracingHTMLSource()); |
| 491 } | 502 } |
| 492 | 503 |
| 493 } // namespace content | 504 } // namespace content |
| OLD | NEW |