| 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 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| 54 protected: | 54 protected: |
| 55 // content::URLDataSource implementation. | 55 // content::URLDataSource implementation. |
| 56 virtual std::string GetSource() OVERRIDE { | 56 virtual std::string GetSource() override { |
| 57 return chrome::kChromeUIProfilerHost; | 57 return chrome::kChromeUIProfilerHost; |
| 58 } | 58 } |
| 59 | 59 |
| 60 virtual std::string GetMimeType(const std::string& path) const OVERRIDE { | 60 virtual std::string GetMimeType(const std::string& path) const override { |
| 61 if (EndsWith(path, ".js", false)) | 61 if (EndsWith(path, ".js", false)) |
| 62 return "application/javascript"; | 62 return "application/javascript"; |
| 63 return "text/html"; | 63 return "text/html"; |
| 64 } | 64 } |
| 65 | 65 |
| 66 virtual void StartDataRequest( | 66 virtual void StartDataRequest( |
| 67 const std::string& path, | 67 const std::string& path, |
| 68 bool is_incognito, | 68 bool is_incognito, |
| 69 const content::URLDataSource::GotDataCallback& callback) OVERRIDE { | 69 const content::URLDataSource::GotDataCallback& callback) override { |
| 70 base::FilePath base_path; | 70 base::FilePath base_path; |
| 71 PathService::Get(base::DIR_SOURCE_ROOT, &base_path); | 71 PathService::Get(base::DIR_SOURCE_ROOT, &base_path); |
| 72 base_path = base_path.AppendASCII("chrome"); | 72 base_path = base_path.AppendASCII("chrome"); |
| 73 base_path = base_path.AppendASCII("browser"); | 73 base_path = base_path.AppendASCII("browser"); |
| 74 base_path = base_path.AppendASCII("resources"); | 74 base_path = base_path.AppendASCII("resources"); |
| 75 base_path = base_path.AppendASCII("profiler"); | 75 base_path = base_path.AppendASCII("profiler"); |
| 76 | 76 |
| 77 // If no resource was specified, default to profiler.html. | 77 // If no resource was specified, default to profiler.html. |
| 78 std::string filename = path.empty() ? "profiler.html" : path; | 78 std::string filename = path.empty() ? "profiler.html" : path; |
| 79 | 79 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 110 #endif | 110 #endif |
| 111 | 111 |
| 112 // This class receives javascript messages from the renderer. | 112 // This class receives javascript messages from the renderer. |
| 113 // Note that the WebUI infrastructure runs on the UI thread, therefore all of | 113 // Note that the WebUI infrastructure runs on the UI thread, therefore all of |
| 114 // this class's methods are expected to run on the UI thread. | 114 // this class's methods are expected to run on the UI thread. |
| 115 class ProfilerMessageHandler : public WebUIMessageHandler { | 115 class ProfilerMessageHandler : public WebUIMessageHandler { |
| 116 public: | 116 public: |
| 117 ProfilerMessageHandler() {} | 117 ProfilerMessageHandler() {} |
| 118 | 118 |
| 119 // WebUIMessageHandler implementation. | 119 // WebUIMessageHandler implementation. |
| 120 virtual void RegisterMessages() OVERRIDE; | 120 virtual void RegisterMessages() override; |
| 121 | 121 |
| 122 // Messages. | 122 // Messages. |
| 123 void OnGetData(const base::ListValue* list); | 123 void OnGetData(const base::ListValue* list); |
| 124 void OnResetData(const base::ListValue* list); | 124 void OnResetData(const base::ListValue* list); |
| 125 | 125 |
| 126 private: | 126 private: |
| 127 DISALLOW_COPY_AND_ASSIGN(ProfilerMessageHandler); | 127 DISALLOW_COPY_AND_ASSIGN(ProfilerMessageHandler); |
| 128 }; | 128 }; |
| 129 | 129 |
| 130 void ProfilerMessageHandler::RegisterMessages() { | 130 void ProfilerMessageHandler::RegisterMessages() { |
| (...skipping 44 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 |