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

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

Issue 9694028: Add a Content API around TracingController. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix linux Created 8 years, 9 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"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/debug/trace_event.h"
12 #include "base/file_util.h" 13 #include "base/file_util.h"
13 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
14 #include "base/string_number_conversions.h" 15 #include "base/string_number_conversions.h"
15 #include "base/utf_string_conversions.h" 16 #include "base/utf_string_conversions.h"
16 #include "chrome/browser/gpu_blacklist.h" 17 #include "chrome/browser/gpu_blacklist.h"
17 #include "chrome/browser/gpu_util.h" 18 #include "chrome/browser/gpu_util.h"
18 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/ui/select_file_dialog.h" 20 #include "chrome/browser/ui/select_file_dialog.h"
20 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" 21 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
21 #include "chrome/common/chrome_version_info.h" 22 #include "chrome/common/chrome_version_info.h"
22 #include "chrome/common/url_constants.h" 23 #include "chrome/common/url_constants.h"
23 #include "content/browser/trace_controller.h"
24 #include "content/public/browser/browser_thread.h" 24 #include "content/public/browser/browser_thread.h"
25 #include "content/public/browser/gpu_data_manager.h" 25 #include "content/public/browser/gpu_data_manager.h"
26 #include "content/public/browser/gpu_data_manager_observer.h" 26 #include "content/public/browser/gpu_data_manager_observer.h"
27 #include "content/public/browser/render_view_host.h" 27 #include "content/public/browser/render_view_host.h"
28 #include "content/public/browser/trace_controller.h"
29 #include "content/public/browser/trace_subscriber.h"
28 #include "content/public/browser/web_contents.h" 30 #include "content/public/browser/web_contents.h"
29 #include "content/public/browser/web_contents_view.h" 31 #include "content/public/browser/web_contents_view.h"
30 #include "content/public/browser/web_ui.h" 32 #include "content/public/browser/web_ui.h"
31 #include "content/public/browser/web_ui_message_handler.h" 33 #include "content/public/browser/web_ui_message_handler.h"
32 #include "grit/browser_resources.h" 34 #include "grit/browser_resources.h"
33 #include "grit/generated_resources.h" 35 #include "grit/generated_resources.h"
34 #include "ui/base/l10n/l10n_util.h" 36 #include "ui/base/l10n/l10n_util.h"
35 37
36 using content::BrowserThread; 38 using content::BrowserThread;
37 using content::GpuDataManager; 39 using content::GpuDataManager;
40 using content::TraceController;
38 using content::WebContents; 41 using content::WebContents;
39 using content::WebUIMessageHandler; 42 using content::WebUIMessageHandler;
40 43
41 namespace { 44 namespace {
42 45
43 ChromeWebUIDataSource* CreateTracingHTMLSource() { 46 ChromeWebUIDataSource* CreateTracingHTMLSource() {
44 ChromeWebUIDataSource* source = 47 ChromeWebUIDataSource* source =
45 new ChromeWebUIDataSource(chrome::kChromeUITracingHost); 48 new ChromeWebUIDataSource(chrome::kChromeUITracingHost);
46 49
47 source->set_json_path("strings.js"); 50 source->set_json_path("strings.js");
48 source->add_resource_path("tracing.js", IDR_TRACING_JS); 51 source->add_resource_path("tracing.js", IDR_TRACING_JS);
49 source->set_default_resource(IDR_TRACING_HTML); 52 source->set_default_resource(IDR_TRACING_HTML);
50 source->AddLocalizedString("tracingTitle", IDS_TRACING_TITLE); 53 source->AddLocalizedString("tracingTitle", IDS_TRACING_TITLE);
51 return source; 54 return source;
52 } 55 }
53 56
54 // This class receives javascript messages from the renderer. 57 // This class receives javascript messages from the renderer.
55 // Note that the WebUI infrastructure runs on the UI thread, therefore all of 58 // Note that the WebUI infrastructure runs on the UI thread, therefore all of
56 // this class's methods are expected to run on the UI thread. 59 // this class's methods are expected to run on the UI thread.
57 class TracingMessageHandler 60 class TracingMessageHandler
58 : public WebUIMessageHandler, 61 : public WebUIMessageHandler,
59 public SelectFileDialog::Listener, 62 public SelectFileDialog::Listener,
60 public base::SupportsWeakPtr<TracingMessageHandler>, 63 public base::SupportsWeakPtr<TracingMessageHandler>,
61 public TraceSubscriber, 64 public content::TraceSubscriber,
62 public content::GpuDataManagerObserver { 65 public content::GpuDataManagerObserver {
63 public: 66 public:
64 TracingMessageHandler(); 67 TracingMessageHandler();
65 virtual ~TracingMessageHandler(); 68 virtual ~TracingMessageHandler();
66 69
67 // WebUIMessageHandler implementation. 70 // WebUIMessageHandler implementation.
68 virtual void RegisterMessages(); 71 virtual void RegisterMessages();
69 72
70 // SelectFileDialog::Listener implementation 73 // SelectFileDialog::Listener implementation
71 virtual void FileSelected(const FilePath& path, int index, void* params); 74 virtual void FileSelected(const FilePath& path, int index, void* params);
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 // 415 //
413 //////////////////////////////////////////////////////////////////////////////// 416 ////////////////////////////////////////////////////////////////////////////////
414 417
415 TracingUI::TracingUI(content::WebUI* web_ui) : WebUIController(web_ui) { 418 TracingUI::TracingUI(content::WebUI* web_ui) : WebUIController(web_ui) {
416 web_ui->AddMessageHandler(new TracingMessageHandler()); 419 web_ui->AddMessageHandler(new TracingMessageHandler());
417 420
418 // Set up the chrome://tracing/ source. 421 // Set up the chrome://tracing/ source.
419 Profile::FromWebUI(web_ui)-> 422 Profile::FromWebUI(web_ui)->
420 GetChromeURLDataManager()->AddDataSource(CreateTracingHTMLSource()); 423 GetChromeURLDataManager()->AddDataSource(CreateTracingHTMLSource());
421 } 424 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698