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

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

Issue 9333003: Use FILE thread for disk operations in TraceSubscriberStdio (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Now using SequencedWorkerPool Created 8 years, 10 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
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 62
63 // WebUIMessageHandler implementation. 63 // WebUIMessageHandler implementation.
64 virtual void RegisterMessages(); 64 virtual void RegisterMessages();
65 65
66 // SelectFileDialog::Listener implementation 66 // SelectFileDialog::Listener implementation
67 virtual void FileSelected(const FilePath& path, int index, void* params); 67 virtual void FileSelected(const FilePath& path, int index, void* params);
68 virtual void FileSelectionCanceled(void* params); 68 virtual void FileSelectionCanceled(void* params);
69 69
70 // TraceSubscriber implementation. 70 // TraceSubscriber implementation.
71 virtual void OnEndTracingComplete(); 71 virtual void OnEndTracingComplete();
72 virtual void OnTraceDataCollected(const std::string& trace_fragment); 72 virtual void OnTraceDataCollected(
73 const scoped_refptr<base::RefCountedString>& trace_fragment);
73 virtual void OnTraceBufferPercentFullReply(float percent_full); 74 virtual void OnTraceBufferPercentFullReply(float percent_full);
74 75
75 // GpuDataManager::Observer implementation. 76 // GpuDataManager::Observer implementation.
76 virtual void OnGpuInfoUpdate() OVERRIDE; 77 virtual void OnGpuInfoUpdate() OVERRIDE;
77 78
78 // Messages. 79 // Messages.
79 void OnTracingControllerInitialized(const ListValue* list); 80 void OnTracingControllerInitialized(const ListValue* list);
80 void OnBeginTracing(const ListValue* list); 81 void OnBeginTracing(const ListValue* list);
81 void OnEndTracingAsync(const ListValue* list); 82 void OnEndTracingAsync(const ListValue* list);
82 void OnBeginRequestBufferPercentFull(const ListValue* list); 83 void OnBeginRequestBufferPercentFull(const ListValue* list);
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 } 374 }
374 } 375 }
375 376
376 void TracingMessageHandler::OnEndTracingComplete() { 377 void TracingMessageHandler::OnEndTracingComplete() {
377 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 378 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
378 trace_enabled_ = false; 379 trace_enabled_ = false;
379 web_ui()->CallJavascriptFunction("tracingController.onEndTracingComplete"); 380 web_ui()->CallJavascriptFunction("tracingController.onEndTracingComplete");
380 } 381 }
381 382
382 void TracingMessageHandler::OnTraceDataCollected( 383 void TracingMessageHandler::OnTraceDataCollected(
383 const std::string& trace_fragment) { 384 const scoped_refptr<base::RefCountedString>& trace_fragment) {
384 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 385 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
385 386
386 base::debug::TraceResultBuffer::SimpleOutput output; 387 base::debug::TraceResultBuffer::SimpleOutput output;
387 base::debug::TraceResultBuffer trace_buffer; 388 base::debug::TraceResultBuffer trace_buffer;
388 trace_buffer.SetOutputCallback(output.GetCallback()); 389 trace_buffer.SetOutputCallback(output.GetCallback());
389 output.Append("tracingController.onTraceDataCollected("); 390 output.Append("tracingController.onTraceDataCollected(");
390 trace_buffer.Start(); 391 trace_buffer.Start();
391 trace_buffer.AddFragment(trace_fragment); 392 trace_buffer.AddFragment(trace_fragment->data());
392 trace_buffer.Finish(); 393 trace_buffer.Finish();
393 output.Append(");"); 394 output.Append(");");
394 395
395 web_ui()->GetWebContents()->GetRenderViewHost()-> 396 web_ui()->GetWebContents()->GetRenderViewHost()->
396 ExecuteJavascriptInWebFrame(string16(), UTF8ToUTF16(output.json_output)); 397 ExecuteJavascriptInWebFrame(string16(), UTF8ToUTF16(output.json_output));
397 } 398 }
398 399
399 void TracingMessageHandler::OnTraceBufferPercentFullReply(float percent_full) { 400 void TracingMessageHandler::OnTraceBufferPercentFullReply(float percent_full) {
400 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 401 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
401 web_ui()->CallJavascriptFunction( 402 web_ui()->CallJavascriptFunction(
(...skipping 10 matching lines...) Expand all
412 // 413 //
413 //////////////////////////////////////////////////////////////////////////////// 414 ////////////////////////////////////////////////////////////////////////////////
414 415
415 TracingUI::TracingUI(content::WebUI* web_ui) : WebUIController(web_ui) { 416 TracingUI::TracingUI(content::WebUI* web_ui) : WebUIController(web_ui) {
416 web_ui->AddMessageHandler(new TracingMessageHandler()); 417 web_ui->AddMessageHandler(new TracingMessageHandler());
417 418
418 // Set up the chrome://tracing/ source. 419 // Set up the chrome://tracing/ source.
419 Profile::FromWebUI(web_ui)-> 420 Profile::FromWebUI(web_ui)->
420 GetChromeURLDataManager()->AddDataSource(CreateTracingHTMLSource()); 421 GetChromeURLDataManager()->AddDataSource(CreateTracingHTMLSource());
421 } 422 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698