| 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 |
| 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/trace_controller.h" | 22 #include "content/browser/trace_controller.h" |
| 23 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
| 24 #include "content/public/browser/web_contents.h" | 24 #include "content/public/browser/web_contents.h" |
| 25 #include "content/public/browser/web_ui_message_handler.h" |
| 25 #include "grit/browser_resources.h" | 26 #include "grit/browser_resources.h" |
| 26 #include "grit/generated_resources.h" | 27 #include "grit/generated_resources.h" |
| 27 | 28 |
| 28 #ifdef USE_SOURCE_FILES_DIRECTLY | 29 #ifdef USE_SOURCE_FILES_DIRECTLY |
| 29 #include "base/base_paths.h" | 30 #include "base/base_paths.h" |
| 30 #include "base/file_util.h" | 31 #include "base/file_util.h" |
| 31 #include "base/memory/ref_counted_memory.h" | 32 #include "base/memory/ref_counted_memory.h" |
| 32 #include "base/path_service.h" | 33 #include "base/path_service.h" |
| 33 #endif // USE_SOURCE_FILES_DIRECTLY | 34 #endif // USE_SOURCE_FILES_DIRECTLY |
| 34 | 35 |
| 35 using chrome_browser_metrics::TrackingSynchronizer; | 36 using chrome_browser_metrics::TrackingSynchronizer; |
| 36 using content::BrowserThread; | 37 using content::BrowserThread; |
| 37 using content::WebContents; | 38 using content::WebContents; |
| 39 using content::WebUIMessageHandler; |
| 38 | 40 |
| 39 namespace { | 41 namespace { |
| 40 | 42 |
| 41 #ifdef USE_SOURCE_FILES_DIRECTLY | 43 #ifdef USE_SOURCE_FILES_DIRECTLY |
| 42 | 44 |
| 43 class ProfilerWebUIDataSource : public ChromeURLDataManager::DataSource { | 45 class ProfilerWebUIDataSource : public ChromeURLDataManager::DataSource { |
| 44 public: | 46 public: |
| 45 ProfilerWebUIDataSource() | 47 ProfilerWebUIDataSource() |
| 46 : DataSource(chrome::kChromeUIProfilerHost, MessageLoop::current()) { | 48 : DataSource(chrome::kChromeUIProfilerHost, MessageLoop::current()) { |
| 47 } | 49 } |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 void ProfilerUI::GetData() { | 161 void ProfilerUI::GetData() { |
| 160 TrackingSynchronizer::FetchProfilerDataAsynchronously(ui_weak_ptr_); | 162 TrackingSynchronizer::FetchProfilerDataAsynchronously(ui_weak_ptr_); |
| 161 } | 163 } |
| 162 | 164 |
| 163 void ProfilerUI::ReceivedData(base::Value* value) { | 165 void ProfilerUI::ReceivedData(base::Value* value) { |
| 164 // Send the data to the renderer. | 166 // Send the data to the renderer. |
| 165 scoped_ptr<Value> data_values(value); | 167 scoped_ptr<Value> data_values(value); |
| 166 CallJavascriptFunction("g_browserBridge.receivedData", *data_values.get()); | 168 CallJavascriptFunction("g_browserBridge.receivedData", *data_values.get()); |
| 167 } | 169 } |
| 168 | 170 |
| OLD | NEW |