Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Side by Side Diff: chrome/browser/ui/webui/profiler_ui.cc

Issue 2705243002: chrome://profiler: Only show memory metrics in when heap tracking is enabled. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/debug/debugging_flags.h"
18 #include "base/debug/thread_heap_usage_tracker.h"
18 #include "base/macros.h" 19 #include "base/macros.h"
19 #include "base/memory/ptr_util.h" 20 #include "base/memory/ptr_util.h"
20 #include "base/strings/string_util.h" 21 #include "base/strings/string_util.h"
21 #include "base/tracked_objects.h" 22 #include "base/tracked_objects.h"
22 #include "base/values.h" 23 #include "base/values.h"
23 #include "chrome/browser/profiles/profile.h" 24 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/browser/task_profiler/task_profiler_data_serializer.h" 25 #include "chrome/browser/task_profiler/task_profiler_data_serializer.h"
25 #include "chrome/common/url_constants.h" 26 #include "chrome/common/url_constants.h"
26 #include "chrome/grit/browser_resources.h" 27 #include "chrome/grit/browser_resources.h"
27 #include "components/metrics/profiler/tracking_synchronizer.h" 28 #include "components/metrics/profiler/tracking_synchronizer.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 #else // USE_SOURCE_FILES_DIRECTLY 101 #else // USE_SOURCE_FILES_DIRECTLY
101 102
102 content::WebUIDataSource* CreateProfilerHTMLSource() { 103 content::WebUIDataSource* CreateProfilerHTMLSource() {
103 content::WebUIDataSource* source = 104 content::WebUIDataSource* source =
104 content::WebUIDataSource::Create(chrome::kChromeUIProfilerHost); 105 content::WebUIDataSource::Create(chrome::kChromeUIProfilerHost);
105 106
106 source->SetJsonPath("strings.js"); 107 source->SetJsonPath("strings.js");
107 source->AddResourcePath("profiler.js", IDR_PROFILER_JS); 108 source->AddResourcePath("profiler.js", IDR_PROFILER_JS);
108 source->SetDefaultResource(IDR_PROFILER_HTML); 109 source->SetDefaultResource(IDR_PROFILER_HTML);
109 source->UseGzip(std::unordered_set<std::string>()); 110 source->UseGzip(std::unordered_set<std::string>());
110 source->AddBoolean("enableMemoryTaskProfiler", 111 source->AddBoolean(
111 BUILDFLAG(ENABLE_MEMORY_TASK_PROFILER)); 112 "enableMemoryTaskProfiler",
113 base::debug::ThreadHeapUsageTracker::IsHeapTrackingEnabled());
112 114
113 return source; 115 return source;
114 } 116 }
115 117
116 #endif 118 #endif
117 119
118 // This class receives javascript messages from the renderer. 120 // This class receives javascript messages from the renderer.
119 // Note that the WebUI infrastructure runs on the UI thread, therefore all of 121 // Note that the WebUI infrastructure runs on the UI thread, therefore all of
120 // this class's methods are expected to run on the UI thread. 122 // this class's methods are expected to run on the UI thread.
121 class ProfilerMessageHandler : public WebUIMessageHandler { 123 class ProfilerMessageHandler : public WebUIMessageHandler {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 // Serialize the data to JSON. 177 // Serialize the data to JSON.
176 base::DictionaryValue json_data; 178 base::DictionaryValue json_data;
177 task_profiler::TaskProfilerDataSerializer::ToValue( 179 task_profiler::TaskProfilerDataSerializer::ToValue(
178 process_data_phase, attributes.process_id, attributes.process_type, 180 process_data_phase, attributes.process_id, attributes.process_type,
179 &json_data); 181 &json_data);
180 182
181 // Send the data to the renderer. 183 // Send the data to the renderer.
182 web_ui()->CallJavascriptFunctionUnsafe("g_browserBridge.receivedData", 184 web_ui()->CallJavascriptFunctionUnsafe("g_browserBridge.receivedData",
183 json_data); 185 json_data);
184 } 186 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698