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

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

Issue 10196004: Changed ChromeURLDataManager to a ProfileKeyedService and made a Factory for it. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Made ChromeURLDataManager's destructor virtual Created 8 years, 8 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
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/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/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
18 #include "base/tracked_objects.h" 18 #include "base/tracked_objects.h"
19 #include "base/values.h" 19 #include "base/values.h"
20 #include "chrome/browser/metrics/tracking_synchronizer.h" 20 #include "chrome/browser/metrics/tracking_synchronizer.h"
21 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/task_profiler/task_profiler_data_serializer.h" 22 #include "chrome/browser/task_profiler/task_profiler_data_serializer.h"
23 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
23 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" 24 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
24 #include "chrome/common/url_constants.h" 25 #include "chrome/common/url_constants.h"
25 #include "content/public/browser/browser_thread.h" 26 #include "content/public/browser/browser_thread.h"
26 #include "content/public/browser/web_contents.h" 27 #include "content/public/browser/web_contents.h"
27 #include "content/public/browser/web_ui.h" 28 #include "content/public/browser/web_ui.h"
28 #include "content/public/browser/web_ui_message_handler.h" 29 #include "content/public/browser/web_ui_message_handler.h"
29 #include "grit/browser_resources.h" 30 #include "grit/browser_resources.h"
30 #include "grit/generated_resources.h" 31 #include "grit/generated_resources.h"
31 32
32 #ifdef USE_SOURCE_FILES_DIRECTLY 33 #ifdef USE_SOURCE_FILES_DIRECTLY
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 } 147 }
147 148
148 } // namespace 149 } // namespace
149 150
150 ProfilerUI::ProfilerUI(content::WebUI* web_ui) 151 ProfilerUI::ProfilerUI(content::WebUI* web_ui)
151 : WebUIController(web_ui), 152 : WebUIController(web_ui),
152 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { 153 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
153 web_ui->AddMessageHandler(new ProfilerMessageHandler()); 154 web_ui->AddMessageHandler(new ProfilerMessageHandler());
154 155
155 // Set up the chrome://profiler/ source. 156 // Set up the chrome://profiler/ source.
156 Profile::FromWebUI(web_ui)-> 157 Profile* profile = Profile::FromWebUI(web_ui);
157 GetChromeURLDataManager()->AddDataSource(CreateProfilerHTMLSource()); 158 ChromeURLDataManager::AddDataSource(profile, CreateProfilerHTMLSource());
158 } 159 }
159 160
160 ProfilerUI::~ProfilerUI() { 161 ProfilerUI::~ProfilerUI() {
161 } 162 }
162 163
163 void ProfilerUI::GetData() { 164 void ProfilerUI::GetData() {
164 TrackingSynchronizer::FetchProfilerDataAsynchronously( 165 TrackingSynchronizer::FetchProfilerDataAsynchronously(
165 weak_ptr_factory_.GetWeakPtr()); 166 weak_ptr_factory_.GetWeakPtr());
166 } 167 }
167 168
168 void ProfilerUI::ReceivedProfilerData( 169 void ProfilerUI::ReceivedProfilerData(
169 const tracked_objects::ProcessDataSnapshot& profiler_data, 170 const tracked_objects::ProcessDataSnapshot& profiler_data,
170 content::ProcessType process_type) { 171 content::ProcessType process_type) {
171 // Serialize the data to JSON. 172 // Serialize the data to JSON.
172 DictionaryValue json_data; 173 DictionaryValue json_data;
173 task_profiler::TaskProfilerDataSerializer::ToValue(profiler_data, 174 task_profiler::TaskProfilerDataSerializer::ToValue(profiler_data,
174 process_type, 175 process_type,
175 &json_data); 176 &json_data);
176 177
177 // Send the data to the renderer. 178 // Send the data to the renderer.
178 web_ui()->CallJavascriptFunction("g_browserBridge.receivedData", json_data); 179 web_ui()->CallJavascriptFunction("g_browserBridge.receivedData", json_data);
179 } 180 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/print_preview/print_preview_ui.cc ('k') | chrome/browser/ui/webui/quota_internals_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698