Chromium Code Reviews| 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 "chrome/browser/ui/webui/tracing_ui.h" | 5 #include "chrome/browser/ui/webui/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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 // WebUIMessageHandler implementation. | 56 // WebUIMessageHandler implementation. |
| 57 virtual WebUIMessageHandler* Attach(WebUI* web_ui); | 57 virtual WebUIMessageHandler* Attach(WebUI* web_ui); |
| 58 virtual void RegisterMessages(); | 58 virtual void RegisterMessages(); |
| 59 | 59 |
| 60 // SelectFileDialog::Listener implementation | 60 // SelectFileDialog::Listener implementation |
| 61 virtual void FileSelected(const FilePath& path, int index, void* params); | 61 virtual void FileSelected(const FilePath& path, int index, void* params); |
| 62 virtual void FileSelectionCanceled(void* params); | 62 virtual void FileSelectionCanceled(void* params); |
| 63 | 63 |
| 64 // TraceSubscriber implementation. | 64 // TraceSubscriber implementation. |
| 65 virtual void OnEndTracingComplete(); | 65 virtual void OnEndTracingComplete(); |
| 66 virtual void OnTraceDataCollected(const std::string& json_events); | 66 virtual void OnTraceDataCollected(const std::string& trace_fragment); |
| 67 virtual void OnTraceBufferPercentFullReply(float percent_full); | 67 virtual void OnTraceBufferPercentFullReply(float percent_full); |
| 68 | 68 |
| 69 // Messages. | 69 // Messages. |
| 70 void OnTracingControllerInitialized(const ListValue* list); | 70 void OnTracingControllerInitialized(const ListValue* list); |
| 71 void OnBeginTracing(const ListValue* list); | 71 void OnBeginTracing(const ListValue* list); |
| 72 void OnEndTracingAsync(const ListValue* list); | 72 void OnEndTracingAsync(const ListValue* list); |
| 73 void OnBeginRequestBufferPercentFull(const ListValue* list); | 73 void OnBeginRequestBufferPercentFull(const ListValue* list); |
| 74 void OnLoadTraceFile(const ListValue* list); | 74 void OnLoadTraceFile(const ListValue* list); |
| 75 void OnSaveTraceFile(const ListValue* list); | 75 void OnSaveTraceFile(const ListValue* list); |
| 76 | 76 |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 412 } | 412 } |
| 413 } | 413 } |
| 414 | 414 |
| 415 void TracingMessageHandler::OnEndTracingComplete() { | 415 void TracingMessageHandler::OnEndTracingComplete() { |
| 416 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 416 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 417 trace_enabled_ = false; | 417 trace_enabled_ = false; |
| 418 web_ui_->CallJavascriptFunction("tracingController.onEndTracingComplete"); | 418 web_ui_->CallJavascriptFunction("tracingController.onEndTracingComplete"); |
| 419 } | 419 } |
| 420 | 420 |
| 421 void TracingMessageHandler::OnTraceDataCollected( | 421 void TracingMessageHandler::OnTraceDataCollected( |
| 422 const std::string& json_events) { | 422 const std::string& trace_fragment) { |
| 423 std::string json_events; | |
| 424 base::debug::TraceResultBuffer trace_buffer_; | |
|
nduca
2011/10/20 00:28:03
I wasn't expecting this. Was expecting the trace_b
jbates
2011/10/20 22:18:49
It's better for memory performance to pass these t
nduca
2011/10/20 23:20:05
Now that you have an output callback, use that ins
jbates
2011/10/20 23:55:13
Since you've spent more time in the javascript sid
| |
| 425 trace_buffer_.AddFragment(trace_fragment); | |
| 426 trace_buffer_.GetJSON(&json_events); | |
| 423 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 427 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 424 std::string javascript = "tracingController.onTraceDataCollected(" | 428 std::string javascript = "tracingController.onTraceDataCollected(" |
| 425 + json_events + ");"; | 429 + json_events + ");"; |
| 426 | 430 |
| 427 web_ui_->tab_contents()->render_view_host()-> | 431 web_ui_->tab_contents()->render_view_host()-> |
| 428 ExecuteJavascriptInWebFrame(string16(), UTF8ToUTF16(javascript)); | 432 ExecuteJavascriptInWebFrame(string16(), UTF8ToUTF16(javascript)); |
| 429 } | 433 } |
| 430 | 434 |
| 431 void TracingMessageHandler::OnTraceBufferPercentFullReply(float percent_full) { | 435 void TracingMessageHandler::OnTraceBufferPercentFullReply(float percent_full) { |
| 432 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 436 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 444 // | 448 // |
| 445 //////////////////////////////////////////////////////////////////////////////// | 449 //////////////////////////////////////////////////////////////////////////////// |
| 446 | 450 |
| 447 TracingUI::TracingUI(TabContents* contents) : ChromeWebUI(contents) { | 451 TracingUI::TracingUI(TabContents* contents) : ChromeWebUI(contents) { |
| 448 AddMessageHandler((new TracingMessageHandler())->Attach(this)); | 452 AddMessageHandler((new TracingMessageHandler())->Attach(this)); |
| 449 | 453 |
| 450 // Set up the chrome://tracing/ source. | 454 // Set up the chrome://tracing/ source. |
| 451 Profile::FromBrowserContext(contents->browser_context())-> | 455 Profile::FromBrowserContext(contents->browser_context())-> |
| 452 GetChromeURLDataManager()->AddDataSource(CreateTracingHTMLSource()); | 456 GetChromeURLDataManager()->AddDataSource(CreateTracingHTMLSource()); |
| 453 } | 457 } |
| OLD | NEW |