Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(571)

Side by Side Diff: chrome/browser/ui/webui/tracing_ui.cc

Issue 10154004: re-use WebUIs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: WeakPtr solution Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/webui/options2/options_ui2.cc ('k') | chrome/browser/ui/webui/uber/uber_ui.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 111
112 // The trace data that is to be written to the file on saving. 112 // The trace data that is to be written to the file on saving.
113 scoped_ptr<std::string> trace_data_to_save_; 113 scoped_ptr<std::string> trace_data_to_save_;
114 114
115 // True while tracing is active. 115 // True while tracing is active.
116 bool trace_enabled_; 116 bool trace_enabled_;
117 117
118 // True while system tracing is active. 118 // True while system tracing is active.
119 bool system_trace_in_progress_; 119 bool system_trace_in_progress_;
120 120
121 // True if observing the GpuDataManager (re-attaching as observer would
122 // DCHECK).
123 bool observing_;
124
121 void OnEndSystemTracingAck( 125 void OnEndSystemTracingAck(
122 const scoped_refptr<base::RefCountedString>& events_str_ptr); 126 const scoped_refptr<base::RefCountedString>& events_str_ptr);
123 127
124 DISALLOW_COPY_AND_ASSIGN(TracingMessageHandler); 128 DISALLOW_COPY_AND_ASSIGN(TracingMessageHandler);
125 }; 129 };
126 130
127 // A proxy passed to the Read and Write tasks used when loading or saving trace 131 // A proxy passed to the Read and Write tasks used when loading or saving trace
128 // data. 132 // data.
129 class TaskProxy : public base::RefCountedThreadSafe<TaskProxy> { 133 class TaskProxy : public base::RefCountedThreadSafe<TaskProxy> {
130 public: 134 public:
(...skipping 22 matching lines...) Expand all
153 157
154 //////////////////////////////////////////////////////////////////////////////// 158 ////////////////////////////////////////////////////////////////////////////////
155 // 159 //
156 // TracingMessageHandler 160 // TracingMessageHandler
157 // 161 //
158 //////////////////////////////////////////////////////////////////////////////// 162 ////////////////////////////////////////////////////////////////////////////////
159 163
160 TracingMessageHandler::TracingMessageHandler() 164 TracingMessageHandler::TracingMessageHandler()
161 : select_trace_file_dialog_type_(SelectFileDialog::SELECT_NONE), 165 : select_trace_file_dialog_type_(SelectFileDialog::SELECT_NONE),
162 trace_enabled_(false), 166 trace_enabled_(false),
163 system_trace_in_progress_(false) { 167 system_trace_in_progress_(false),
168 observing_(false) {
164 } 169 }
165 170
166 TracingMessageHandler::~TracingMessageHandler() { 171 TracingMessageHandler::~TracingMessageHandler() {
167 GpuDataManager::GetInstance()->RemoveObserver(this); 172 GpuDataManager::GetInstance()->RemoveObserver(this);
168 173
169 if (select_trace_file_dialog_) 174 if (select_trace_file_dialog_)
170 select_trace_file_dialog_->ListenerDestroyed(); 175 select_trace_file_dialog_->ListenerDestroyed();
171 176
172 // If we are the current subscriber, this will result in ending tracing. 177 // If we are the current subscriber, this will result in ending tracing.
173 TraceController::GetInstance()->CancelSubscriber(this); 178 TraceController::GetInstance()->CancelSubscriber(this);
(...skipping 29 matching lines...) Expand all
203 web_ui()->RegisterMessageCallback("saveTraceFile", 208 web_ui()->RegisterMessageCallback("saveTraceFile",
204 base::Bind(&TracingMessageHandler::OnSaveTraceFile, 209 base::Bind(&TracingMessageHandler::OnSaveTraceFile,
205 base::Unretained(this))); 210 base::Unretained(this)));
206 } 211 }
207 212
208 void TracingMessageHandler::OnTracingControllerInitialized( 213 void TracingMessageHandler::OnTracingControllerInitialized(
209 const ListValue* args) { 214 const ListValue* args) {
210 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 215 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
211 216
212 // Watch for changes in GPUInfo 217 // Watch for changes in GPUInfo
213 GpuDataManager::GetInstance()->AddObserver(this); 218 if (!observing_)
219 GpuDataManager::GetInstance()->AddObserver(this);
220 observing_ = true;
214 221
215 // Tell GpuDataManager it should have full GpuInfo. If the 222 // Tell GpuDataManager it should have full GpuInfo. If the
216 // Gpu process has not run yet, this will trigger its launch. 223 // Gpu process has not run yet, this will trigger its launch.
217 GpuDataManager::GetInstance()->RequestCompleteGpuInfoIfNeeded(); 224 GpuDataManager::GetInstance()->RequestCompleteGpuInfoIfNeeded();
218 225
219 // Run callback immediately in case the info is ready and no update in the 226 // Run callback immediately in case the info is ready and no update in the
220 // future. 227 // future.
221 OnGpuInfoUpdate(); 228 OnGpuInfoUpdate();
222 229
223 // Send the client info to the tracingController 230 // Send the client info to the tracingController
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 // 489 //
483 //////////////////////////////////////////////////////////////////////////////// 490 ////////////////////////////////////////////////////////////////////////////////
484 491
485 TracingUI::TracingUI(content::WebUI* web_ui) : WebUIController(web_ui) { 492 TracingUI::TracingUI(content::WebUI* web_ui) : WebUIController(web_ui) {
486 web_ui->AddMessageHandler(new TracingMessageHandler()); 493 web_ui->AddMessageHandler(new TracingMessageHandler());
487 494
488 // Set up the chrome://tracing/ source. 495 // Set up the chrome://tracing/ source.
489 Profile* profile = Profile::FromWebUI(web_ui); 496 Profile* profile = Profile::FromWebUI(web_ui);
490 ChromeURLDataManager::AddDataSource(profile, CreateTracingHTMLSource()); 497 ChromeURLDataManager::AddDataSource(profile, CreateTracingHTMLSource());
491 } 498 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options2/options_ui2.cc ('k') | chrome/browser/ui/webui/uber/uber_ui.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698