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

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

Issue 9003014: Replace WebUI::tab_contents() with web_contents() and switch all users to use web_contents.h inst... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 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/profiler_ui.h ('k') | chrome/browser/ui/webui/quota_internals_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) 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/profiler_ui.h" 5 #include "chrome/browser/ui/webui/profiler_ui.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 // When testing the javacript code, it is cumbersome to have to keep 9 // When testing the javacript code, it is cumbersome to have to keep
10 // re-building the resouces package and reloading the browser. To solve 10 // re-building the resouces package and reloading the browser. To solve
11 // this, enable the following flag to read the webapp's source files 11 // this, enable the following flag to read the webapp's source files
12 // directly off disk, so all you have to do is refresh the page to 12 // directly off disk, so all you have to do is refresh the page to
13 // test the modifications. 13 // test the modifications.
14 //#define USE_SOURCE_FILES_DIRECTLY 14 //#define USE_SOURCE_FILES_DIRECTLY
15 15
16 #include "base/bind.h" 16 #include "base/bind.h"
17 #include "base/tracked_objects.h" 17 #include "base/tracked_objects.h"
18 #include "chrome/browser/metrics/tracking_synchronizer.h" 18 #include "chrome/browser/metrics/tracking_synchronizer.h"
19 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" 20 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
21 #include "chrome/common/url_constants.h" 21 #include "chrome/common/url_constants.h"
22 #include "content/browser/tab_contents/tab_contents.h"
23 #include "content/browser/trace_controller.h" 22 #include "content/browser/trace_controller.h"
24 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
24 #include "content/public/browser/web_contents.h"
25 #include "grit/browser_resources.h" 25 #include "grit/browser_resources.h"
26 #include "grit/generated_resources.h" 26 #include "grit/generated_resources.h"
27 27
28 #ifdef USE_SOURCE_FILES_DIRECTLY 28 #ifdef USE_SOURCE_FILES_DIRECTLY
29 #include "base/base_paths.h" 29 #include "base/base_paths.h"
30 #include "base/file_util.h" 30 #include "base/file_util.h"
31 #include "base/memory/ref_counted_memory.h" 31 #include "base/memory/ref_counted_memory.h"
32 #include "base/path_service.h" 32 #include "base/path_service.h"
33 #endif // USE_SOURCE_FILES_DIRECTLY 33 #endif // USE_SOURCE_FILES_DIRECTLY
34 34
35 using chrome_browser_metrics::TrackingSynchronizer;
35 using content::BrowserThread; 36 using content::BrowserThread;
36 using chrome_browser_metrics::TrackingSynchronizer; 37 using content::WebContents;
37 38
38 namespace { 39 namespace {
39 40
40 #ifdef USE_SOURCE_FILES_DIRECTLY 41 #ifdef USE_SOURCE_FILES_DIRECTLY
41 42
42 class ProfilerWebUIDataSource : public ChromeURLDataManager::DataSource { 43 class ProfilerWebUIDataSource : public ChromeURLDataManager::DataSource {
43 public: 44 public:
44 ProfilerWebUIDataSource() 45 ProfilerWebUIDataSource()
45 : DataSource(chrome::kChromeUIProfilerHost, MessageLoop::current()) { 46 : DataSource(chrome::kChromeUIProfilerHost, MessageLoop::current()) {
46 } 47 }
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 ProfilerUI* profiler_ui = reinterpret_cast<ProfilerUI*>(web_ui()); 135 ProfilerUI* profiler_ui = reinterpret_cast<ProfilerUI*>(web_ui());
135 profiler_ui->GetData(); 136 profiler_ui->GetData();
136 } 137 }
137 138
138 void ProfilerMessageHandler::OnResetData(const ListValue* list) { 139 void ProfilerMessageHandler::OnResetData(const ListValue* list) {
139 tracked_objects::ThreadData::ResetAllThreadData(); 140 tracked_objects::ThreadData::ResetAllThreadData();
140 } 141 }
141 142
142 } // namespace 143 } // namespace
143 144
144 ProfilerUI::ProfilerUI(TabContents* contents) : ChromeWebUI(contents) { 145 ProfilerUI::ProfilerUI(WebContents* contents) : ChromeWebUI(contents) {
145 ui_weak_ptr_factory_.reset(new base::WeakPtrFactory<ProfilerUI>(this)); 146 ui_weak_ptr_factory_.reset(new base::WeakPtrFactory<ProfilerUI>(this));
146 ui_weak_ptr_ = ui_weak_ptr_factory_->GetWeakPtr(); 147 ui_weak_ptr_ = ui_weak_ptr_factory_->GetWeakPtr();
147 148
148 AddMessageHandler(new ProfilerMessageHandler()); 149 AddMessageHandler(new ProfilerMessageHandler());
149 150
150 // Set up the chrome://profiler/ source. 151 // Set up the chrome://profiler/ source.
151 Profile::FromBrowserContext(contents->GetBrowserContext())-> 152 Profile::FromBrowserContext(contents->GetBrowserContext())->
152 GetChromeURLDataManager()->AddDataSource(CreateProfilerHTMLSource()); 153 GetChromeURLDataManager()->AddDataSource(CreateProfilerHTMLSource());
153 } 154 }
154 155
155 ProfilerUI::~ProfilerUI() { 156 ProfilerUI::~ProfilerUI() {
156 } 157 }
157 158
158 void ProfilerUI::GetData() { 159 void ProfilerUI::GetData() {
159 TrackingSynchronizer::FetchProfilerDataAsynchronously(ui_weak_ptr_); 160 TrackingSynchronizer::FetchProfilerDataAsynchronously(ui_weak_ptr_);
160 } 161 }
161 162
162 void ProfilerUI::ReceivedData(base::Value* value) { 163 void ProfilerUI::ReceivedData(base::Value* value) {
163 // Send the data to the renderer. 164 // Send the data to the renderer.
164 scoped_ptr<Value> data_values(value); 165 scoped_ptr<Value> data_values(value);
165 CallJavascriptFunction("g_browserBridge.receivedData", *data_values.get()); 166 CallJavascriptFunction("g_browserBridge.receivedData", *data_values.get());
166 } 167 }
167 168
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/profiler_ui.h ('k') | chrome/browser/ui/webui/quota_internals_ui.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698