OLD | NEW |
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/debug/debugging_flags.h" |
17 #include "base/macros.h" | 18 #include "base/macros.h" |
18 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
19 #include "base/tracked_objects.h" | 20 #include "base/tracked_objects.h" |
20 #include "base/values.h" | 21 #include "base/values.h" |
21 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
22 #include "chrome/browser/task_profiler/task_profiler_data_serializer.h" | 23 #include "chrome/browser/task_profiler/task_profiler_data_serializer.h" |
23 #include "chrome/common/url_constants.h" | 24 #include "chrome/common/url_constants.h" |
24 #include "chrome/grit/browser_resources.h" | 25 #include "chrome/grit/browser_resources.h" |
25 #include "components/metrics/profiler/tracking_synchronizer.h" | 26 #include "components/metrics/profiler/tracking_synchronizer.h" |
26 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 #else // USE_SOURCE_FILES_DIRECTLY | 99 #else // USE_SOURCE_FILES_DIRECTLY |
99 | 100 |
100 content::WebUIDataSource* CreateProfilerHTMLSource() { | 101 content::WebUIDataSource* CreateProfilerHTMLSource() { |
101 content::WebUIDataSource* source = | 102 content::WebUIDataSource* source = |
102 content::WebUIDataSource::Create(chrome::kChromeUIProfilerHost); | 103 content::WebUIDataSource::Create(chrome::kChromeUIProfilerHost); |
103 | 104 |
104 source->SetJsonPath("strings.js"); | 105 source->SetJsonPath("strings.js"); |
105 source->AddResourcePath("profiler.js", IDR_PROFILER_JS); | 106 source->AddResourcePath("profiler.js", IDR_PROFILER_JS); |
106 source->SetDefaultResource(IDR_PROFILER_HTML); | 107 source->SetDefaultResource(IDR_PROFILER_HTML); |
107 source->DisableI18nAndUseGzipForAllPaths(); | 108 source->DisableI18nAndUseGzipForAllPaths(); |
| 109 source->AddBoolean("enableMemoryTaskProfiler", |
| 110 BUILDFLAG(ENABLE_MEMORY_TASK_PROFILER)); |
| 111 |
108 return source; | 112 return source; |
109 } | 113 } |
110 | 114 |
111 #endif | 115 #endif |
112 | 116 |
113 // This class receives javascript messages from the renderer. | 117 // This class receives javascript messages from the renderer. |
114 // Note that the WebUI infrastructure runs on the UI thread, therefore all of | 118 // Note that the WebUI infrastructure runs on the UI thread, therefore all of |
115 // this class's methods are expected to run on the UI thread. | 119 // this class's methods are expected to run on the UI thread. |
116 class ProfilerMessageHandler : public WebUIMessageHandler { | 120 class ProfilerMessageHandler : public WebUIMessageHandler { |
117 public: | 121 public: |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 // Serialize the data to JSON. | 174 // Serialize the data to JSON. |
171 base::DictionaryValue json_data; | 175 base::DictionaryValue json_data; |
172 task_profiler::TaskProfilerDataSerializer::ToValue( | 176 task_profiler::TaskProfilerDataSerializer::ToValue( |
173 process_data_phase, attributes.process_id, attributes.process_type, | 177 process_data_phase, attributes.process_id, attributes.process_type, |
174 &json_data); | 178 &json_data); |
175 | 179 |
176 // Send the data to the renderer. | 180 // Send the data to the renderer. |
177 web_ui()->CallJavascriptFunctionUnsafe("g_browserBridge.receivedData", | 181 web_ui()->CallJavascriptFunctionUnsafe("g_browserBridge.receivedData", |
178 json_data); | 182 json_data); |
179 } | 183 } |
OLD | NEW |