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 "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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 109 SelectFileDialog::Type select_trace_file_dialog_type_; | 109 SelectFileDialog::Type select_trace_file_dialog_type_; |
| 110 | 110 |
| 111 // The trace data that is to be written to the file on saving. | 111 // The trace data that is to be written to the file on saving. |
| 112 scoped_ptr<std::string> trace_data_to_save_; | 112 scoped_ptr<std::string> trace_data_to_save_; |
| 113 | 113 |
| 114 // True while tracing is active. | 114 // True while tracing is active. |
| 115 bool trace_enabled_; | 115 bool trace_enabled_; |
| 116 | 116 |
| 117 // True while system tracing is active. | 117 // True while system tracing is active. |
| 118 bool system_trace_in_progress_; | 118 bool system_trace_in_progress_; |
| 119 | 119 |
|
Dan Beam
2012/04/21 02:53:07
doc comment
| |
| 120 bool observing_; | |
| 121 | |
| 120 void OnEndSystemTracingAck( | 122 void OnEndSystemTracingAck( |
| 121 const scoped_refptr<base::RefCountedString>& events_str_ptr); | 123 const scoped_refptr<base::RefCountedString>& events_str_ptr); |
| 122 | 124 |
| 123 DISALLOW_COPY_AND_ASSIGN(TracingMessageHandler); | 125 DISALLOW_COPY_AND_ASSIGN(TracingMessageHandler); |
| 124 }; | 126 }; |
| 125 | 127 |
| 126 // A proxy passed to the Read and Write tasks used when loading or saving trace | 128 // A proxy passed to the Read and Write tasks used when loading or saving trace |
| 127 // data. | 129 // data. |
| 128 class TaskProxy : public base::RefCountedThreadSafe<TaskProxy> { | 130 class TaskProxy : public base::RefCountedThreadSafe<TaskProxy> { |
| 129 public: | 131 public: |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 151 | 153 |
| 152 //////////////////////////////////////////////////////////////////////////////// | 154 //////////////////////////////////////////////////////////////////////////////// |
| 153 // | 155 // |
| 154 // TracingMessageHandler | 156 // TracingMessageHandler |
| 155 // | 157 // |
| 156 //////////////////////////////////////////////////////////////////////////////// | 158 //////////////////////////////////////////////////////////////////////////////// |
| 157 | 159 |
| 158 TracingMessageHandler::TracingMessageHandler() | 160 TracingMessageHandler::TracingMessageHandler() |
| 159 : select_trace_file_dialog_type_(SelectFileDialog::SELECT_NONE), | 161 : select_trace_file_dialog_type_(SelectFileDialog::SELECT_NONE), |
| 160 trace_enabled_(false), | 162 trace_enabled_(false), |
| 161 system_trace_in_progress_(false) { | 163 system_trace_in_progress_(false), |
| 164 observing_(true) { | |
|
stuartmorgan
2012/04/24 09:12:20
Same issue here.
Evan Stade
2012/04/24 17:52:40
Done.
| |
| 162 } | 165 } |
| 163 | 166 |
| 164 TracingMessageHandler::~TracingMessageHandler() { | 167 TracingMessageHandler::~TracingMessageHandler() { |
| 165 GpuDataManager::GetInstance()->RemoveObserver(this); | 168 GpuDataManager::GetInstance()->RemoveObserver(this); |
| 166 | 169 |
| 167 if (select_trace_file_dialog_) | 170 if (select_trace_file_dialog_) |
| 168 select_trace_file_dialog_->ListenerDestroyed(); | 171 select_trace_file_dialog_->ListenerDestroyed(); |
| 169 | 172 |
| 170 // If we are the current subscriber, this will result in ending tracing. | 173 // If we are the current subscriber, this will result in ending tracing. |
| 171 TraceController::GetInstance()->CancelSubscriber(this); | 174 TraceController::GetInstance()->CancelSubscriber(this); |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 201 web_ui()->RegisterMessageCallback("saveTraceFile", | 204 web_ui()->RegisterMessageCallback("saveTraceFile", |
| 202 base::Bind(&TracingMessageHandler::OnSaveTraceFile, | 205 base::Bind(&TracingMessageHandler::OnSaveTraceFile, |
| 203 base::Unretained(this))); | 206 base::Unretained(this))); |
| 204 } | 207 } |
| 205 | 208 |
| 206 void TracingMessageHandler::OnTracingControllerInitialized( | 209 void TracingMessageHandler::OnTracingControllerInitialized( |
| 207 const ListValue* args) { | 210 const ListValue* args) { |
| 208 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 211 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 209 | 212 |
| 210 // Watch for changes in GPUInfo | 213 // Watch for changes in GPUInfo |
| 211 GpuDataManager::GetInstance()->AddObserver(this); | 214 if (!observing_) |
| 215 GpuDataManager::GetInstance()->AddObserver(this); | |
| 216 observing_ = true; | |
| 212 | 217 |
| 213 // Tell GpuDataManager it should have full GpuInfo. If the | 218 // Tell GpuDataManager it should have full GpuInfo. If the |
| 214 // Gpu process has not run yet, this will trigger its launch. | 219 // Gpu process has not run yet, this will trigger its launch. |
| 215 GpuDataManager::GetInstance()->RequestCompleteGpuInfoIfNeeded(); | 220 GpuDataManager::GetInstance()->RequestCompleteGpuInfoIfNeeded(); |
| 216 | 221 |
| 217 // Run callback immediately in case the info is ready and no update in the | 222 // Run callback immediately in case the info is ready and no update in the |
| 218 // future. | 223 // future. |
| 219 OnGpuInfoUpdate(); | 224 OnGpuInfoUpdate(); |
| 220 | 225 |
| 221 // Send the client info to the tracingController | 226 // Send the client info to the tracingController |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 480 // | 485 // |
| 481 //////////////////////////////////////////////////////////////////////////////// | 486 //////////////////////////////////////////////////////////////////////////////// |
| 482 | 487 |
| 483 TracingUI::TracingUI(content::WebUI* web_ui) : WebUIController(web_ui) { | 488 TracingUI::TracingUI(content::WebUI* web_ui) : WebUIController(web_ui) { |
| 484 web_ui->AddMessageHandler(new TracingMessageHandler()); | 489 web_ui->AddMessageHandler(new TracingMessageHandler()); |
| 485 | 490 |
| 486 // Set up the chrome://tracing/ source. | 491 // Set up the chrome://tracing/ source. |
| 487 Profile::FromWebUI(web_ui)-> | 492 Profile::FromWebUI(web_ui)-> |
| 488 GetChromeURLDataManager()->AddDataSource(CreateTracingHTMLSource()); | 493 GetChromeURLDataManager()->AddDataSource(CreateTracingHTMLSource()); |
| 489 } | 494 } |
| OLD | NEW |