OLD | NEW |
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 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 ProfilerUI* profiler_ui = reinterpret_cast<ProfilerUI*>(web_ui()); | 137 ProfilerUI* profiler_ui = reinterpret_cast<ProfilerUI*>(web_ui()); |
138 profiler_ui->GetData(); | 138 profiler_ui->GetData(); |
139 } | 139 } |
140 | 140 |
141 void ProfilerMessageHandler::OnResetData(const ListValue* list) { | 141 void ProfilerMessageHandler::OnResetData(const ListValue* list) { |
142 tracked_objects::ThreadData::ResetAllThreadData(); | 142 tracked_objects::ThreadData::ResetAllThreadData(); |
143 } | 143 } |
144 | 144 |
145 } // namespace | 145 } // namespace |
146 | 146 |
147 ProfilerUI::ProfilerUI(WebContents* contents) : WebUI(contents) { | 147 ProfilerUI::ProfilerUI(WebContents* contents) : WebUI(contents, this) { |
148 ui_weak_ptr_factory_.reset(new base::WeakPtrFactory<ProfilerUI>(this)); | 148 ui_weak_ptr_factory_.reset(new base::WeakPtrFactory<ProfilerUI>(this)); |
149 ui_weak_ptr_ = ui_weak_ptr_factory_->GetWeakPtr(); | 149 ui_weak_ptr_ = ui_weak_ptr_factory_->GetWeakPtr(); |
150 | 150 |
151 AddMessageHandler(new ProfilerMessageHandler()); | 151 AddMessageHandler(new ProfilerMessageHandler()); |
152 | 152 |
153 // Set up the chrome://profiler/ source. | 153 // Set up the chrome://profiler/ source. |
154 Profile::FromBrowserContext(contents->GetBrowserContext())-> | 154 Profile::FromBrowserContext(contents->GetBrowserContext())-> |
155 GetChromeURLDataManager()->AddDataSource(CreateProfilerHTMLSource()); | 155 GetChromeURLDataManager()->AddDataSource(CreateProfilerHTMLSource()); |
156 } | 156 } |
157 | 157 |
158 ProfilerUI::~ProfilerUI() { | 158 ProfilerUI::~ProfilerUI() { |
159 } | 159 } |
160 | 160 |
161 void ProfilerUI::GetData() { | 161 void ProfilerUI::GetData() { |
162 TrackingSynchronizer::FetchProfilerDataAsynchronously(ui_weak_ptr_); | 162 TrackingSynchronizer::FetchProfilerDataAsynchronously(ui_weak_ptr_); |
163 } | 163 } |
164 | 164 |
165 void ProfilerUI::ReceivedData(base::Value* value) { | 165 void ProfilerUI::ReceivedData(base::Value* value) { |
166 // Send the data to the renderer. | 166 // Send the data to the renderer. |
167 scoped_ptr<Value> data_values(value); | 167 scoped_ptr<Value> data_values(value); |
168 CallJavascriptFunction("g_browserBridge.receivedData", *data_values.get()); | 168 CallJavascriptFunction("g_browserBridge.receivedData", *data_values.get()); |
169 } | 169 } |
170 | 170 |
OLD | NEW |