| 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" |
| 10 #include "base/bind_helpers.h" |
| 11 #include "base/callback_old.h" |
| 9 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 10 #include "base/file_util.h" | 13 #include "base/file_util.h" |
| 11 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/string_number_conversions.h" | 15 #include "base/string_number_conversions.h" |
| 13 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/ui/shell_dialogs.h" | 18 #include "chrome/browser/ui/shell_dialogs.h" |
| 16 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" | 19 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" |
| 17 #include "chrome/common/chrome_version_info.h" | 20 #include "chrome/common/chrome_version_info.h" |
| 18 #include "chrome/common/url_constants.h" | 21 #include "chrome/common/url_constants.h" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 | 164 |
| 162 WebUIMessageHandler* TracingMessageHandler::Attach(WebUI* web_ui) { | 165 WebUIMessageHandler* TracingMessageHandler::Attach(WebUI* web_ui) { |
| 163 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 166 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 164 WebUIMessageHandler* result = WebUIMessageHandler::Attach(web_ui); | 167 WebUIMessageHandler* result = WebUIMessageHandler::Attach(web_ui); |
| 165 return result; | 168 return result; |
| 166 } | 169 } |
| 167 | 170 |
| 168 void TracingMessageHandler::RegisterMessages() { | 171 void TracingMessageHandler::RegisterMessages() { |
| 169 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 172 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 170 | 173 |
| 171 web_ui_->RegisterMessageCallback( | 174 web_ui_->RegisterMessageCallback("tracingControllerInitialized", |
| 172 "tracingControllerInitialized", | 175 base::Bind(&TracingMessageHandler::OnTracingControllerInitialized, |
| 173 NewCallback(this, | 176 base::Unretained(this))); |
| 174 &TracingMessageHandler::OnTracingControllerInitialized)); | 177 web_ui_->RegisterMessageCallback("beginTracing", |
| 175 web_ui_->RegisterMessageCallback( | 178 base::Bind(&TracingMessageHandler::OnBeginTracing, |
| 176 "beginTracing", | 179 base::Unretained(this))); |
| 177 NewCallback(this, &TracingMessageHandler::OnBeginTracing)); | 180 web_ui_->RegisterMessageCallback("endTracingAsync", |
| 178 web_ui_->RegisterMessageCallback( | 181 base::Bind(&TracingMessageHandler::OnEndTracingAsync, |
| 179 "endTracingAsync", | 182 base::Unretained(this))); |
| 180 NewCallback(this, &TracingMessageHandler::OnEndTracingAsync)); | 183 web_ui_->RegisterMessageCallback("beginRequestBufferPercentFull", |
| 181 web_ui_->RegisterMessageCallback( | 184 base::Bind(&TracingMessageHandler::OnBeginRequestBufferPercentFull, |
| 182 "beginRequestBufferPercentFull", | 185 base::Unretained(this))); |
| 183 NewCallback(this, | 186 web_ui_->RegisterMessageCallback("loadTraceFile", |
| 184 &TracingMessageHandler::OnBeginRequestBufferPercentFull)); | 187 base::Bind(&TracingMessageHandler::OnLoadTraceFile, |
| 185 web_ui_->RegisterMessageCallback( | 188 base::Unretained(this))); |
| 186 "loadTraceFile", | 189 web_ui_->RegisterMessageCallback("saveTraceFile", |
| 187 NewCallback(this, &TracingMessageHandler::OnLoadTraceFile)); | 190 base::Bind(&TracingMessageHandler::OnSaveTraceFile, |
| 188 web_ui_->RegisterMessageCallback( | 191 base::Unretained(this))); |
| 189 "saveTraceFile", | |
| 190 NewCallback(this, &TracingMessageHandler::OnSaveTraceFile)); | |
| 191 } | 192 } |
| 192 | 193 |
| 193 void TracingMessageHandler::OnTracingControllerInitialized( | 194 void TracingMessageHandler::OnTracingControllerInitialized( |
| 194 const ListValue* args) { | 195 const ListValue* args) { |
| 195 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 196 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 196 | 197 |
| 197 DCHECK(!gpu_info_update_callback_); | 198 DCHECK(!gpu_info_update_callback_); |
| 198 | 199 |
| 199 // Watch for changes in GPUInfo | 200 // Watch for changes in GPUInfo |
| 200 gpu_info_update_callback_ = | 201 gpu_info_update_callback_ = |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 // | 458 // |
| 458 //////////////////////////////////////////////////////////////////////////////// | 459 //////////////////////////////////////////////////////////////////////////////// |
| 459 | 460 |
| 460 TracingUI::TracingUI(TabContents* contents) : ChromeWebUI(contents) { | 461 TracingUI::TracingUI(TabContents* contents) : ChromeWebUI(contents) { |
| 461 AddMessageHandler((new TracingMessageHandler())->Attach(this)); | 462 AddMessageHandler((new TracingMessageHandler())->Attach(this)); |
| 462 | 463 |
| 463 // Set up the chrome://tracing/ source. | 464 // Set up the chrome://tracing/ source. |
| 464 Profile::FromBrowserContext(contents->browser_context())-> | 465 Profile::FromBrowserContext(contents->browser_context())-> |
| 465 GetChromeURLDataManager()->AddDataSource(CreateTracingHTMLSource()); | 466 GetChromeURLDataManager()->AddDataSource(CreateTracingHTMLSource()); |
| 466 } | 467 } |
| OLD | NEW |