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/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
19 #include "base/tracked_objects.h" | 19 #include "base/tracked_objects.h" |
20 #include "base/values.h" | 20 #include "base/values.h" |
21 #include "chrome/browser/metrics/tracking_synchronizer.h" | |
22 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
23 #include "chrome/browser/task_profiler/task_profiler_data_serializer.h" | 22 #include "chrome/browser/task_profiler/task_profiler_data_serializer.h" |
24 #include "chrome/common/url_constants.h" | 23 #include "chrome/common/url_constants.h" |
| 24 #include "components/metrics/profiler/tracking_synchronizer.h" |
25 #include "content/public/browser/browser_thread.h" | 25 #include "content/public/browser/browser_thread.h" |
26 #include "content/public/browser/url_data_source.h" | 26 #include "content/public/browser/url_data_source.h" |
27 #include "content/public/browser/web_contents.h" | 27 #include "content/public/browser/web_contents.h" |
28 #include "content/public/browser/web_ui.h" | 28 #include "content/public/browser/web_ui.h" |
29 #include "content/public/browser/web_ui_data_source.h" | 29 #include "content/public/browser/web_ui_data_source.h" |
30 #include "content/public/browser/web_ui_message_handler.h" | 30 #include "content/public/browser/web_ui_message_handler.h" |
31 #include "grit/browser_resources.h" | 31 #include "grit/browser_resources.h" |
32 | 32 |
33 #ifdef USE_SOURCE_FILES_DIRECTLY | 33 #ifdef USE_SOURCE_FILES_DIRECTLY |
34 #include "base/base_paths.h" | 34 #include "base/base_paths.h" |
35 #include "base/files/file_util.h" | 35 #include "base/files/file_util.h" |
36 #include "base/memory/ref_counted_memory.h" | 36 #include "base/memory/ref_counted_memory.h" |
37 #include "base/path_service.h" | 37 #include "base/path_service.h" |
38 #endif // USE_SOURCE_FILES_DIRECTLY | 38 #endif // USE_SOURCE_FILES_DIRECTLY |
39 | 39 |
40 using chrome_browser_metrics::TrackingSynchronizer; | |
41 using content::BrowserThread; | 40 using content::BrowserThread; |
42 using content::WebContents; | 41 using content::WebContents; |
43 using content::WebUIMessageHandler; | 42 using content::WebUIMessageHandler; |
| 43 using metrics::TrackingSynchronizer; |
44 | 44 |
45 namespace { | 45 namespace { |
46 | 46 |
47 #ifdef USE_SOURCE_FILES_DIRECTLY | 47 #ifdef USE_SOURCE_FILES_DIRECTLY |
48 | 48 |
49 class ProfilerWebUIDataSource : public content::URLDataSource { | 49 class ProfilerWebUIDataSource : public content::URLDataSource { |
50 public: | 50 public: |
51 ProfilerWebUIDataSource() { | 51 ProfilerWebUIDataSource() { |
52 } | 52 } |
53 | 53 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 int process_type) { | 175 int process_type) { |
176 // Serialize the data to JSON. | 176 // Serialize the data to JSON. |
177 base::DictionaryValue json_data; | 177 base::DictionaryValue json_data; |
178 task_profiler::TaskProfilerDataSerializer::ToValue(profiler_data, | 178 task_profiler::TaskProfilerDataSerializer::ToValue(profiler_data, |
179 process_type, | 179 process_type, |
180 &json_data); | 180 &json_data); |
181 | 181 |
182 // Send the data to the renderer. | 182 // Send the data to the renderer. |
183 web_ui()->CallJavascriptFunction("g_browserBridge.receivedData", json_data); | 183 web_ui()->CallJavascriptFunction("g_browserBridge.receivedData", json_data); |
184 } | 184 } |
OLD | NEW |