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

Side by Side Diff: chrome/browser/devtools/devtools_window.cc

Issue 106223002: chrome power profiler chrome side changes (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 6 years, 11 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
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/devtools/devtools_window.h" 5 #include "chrome/browser/devtools/devtools_window.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 #include "content/public/browser/browser_thread.h" 48 #include "content/public/browser/browser_thread.h"
49 #include "content/public/browser/child_process_security_policy.h" 49 #include "content/public/browser/child_process_security_policy.h"
50 #include "content/public/browser/devtools_agent_host.h" 50 #include "content/public/browser/devtools_agent_host.h"
51 #include "content/public/browser/devtools_client_host.h" 51 #include "content/public/browser/devtools_client_host.h"
52 #include "content/public/browser/devtools_manager.h" 52 #include "content/public/browser/devtools_manager.h"
53 #include "content/public/browser/favicon_status.h" 53 #include "content/public/browser/favicon_status.h"
54 #include "content/public/browser/load_notification_details.h" 54 #include "content/public/browser/load_notification_details.h"
55 #include "content/public/browser/navigation_controller.h" 55 #include "content/public/browser/navigation_controller.h"
56 #include "content/public/browser/navigation_entry.h" 56 #include "content/public/browser/navigation_entry.h"
57 #include "content/public/browser/notification_source.h" 57 #include "content/public/browser/notification_source.h"
58 #include "content/public/browser/power_profiler_service.h"
58 #include "content/public/browser/render_process_host.h" 59 #include "content/public/browser/render_process_host.h"
59 #include "content/public/browser/render_view_host.h" 60 #include "content/public/browser/render_view_host.h"
60 #include "content/public/browser/user_metrics.h" 61 #include "content/public/browser/user_metrics.h"
61 #include "content/public/browser/web_contents.h" 62 #include "content/public/browser/web_contents.h"
62 #include "content/public/browser/web_contents_observer.h" 63 #include "content/public/browser/web_contents_observer.h"
63 #include "content/public/browser/web_contents_view.h" 64 #include "content/public/browser/web_contents_view.h"
64 #include "content/public/common/bindings_policy.h" 65 #include "content/public/common/bindings_policy.h"
65 #include "content/public/common/content_client.h" 66 #include "content/public/common/content_client.h"
66 #include "content/public/common/page_transition_types.h" 67 #include "content/public/common/page_transition_types.h"
67 #include "content/public/common/url_constants.h" 68 #include "content/public/common/url_constants.h"
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 frontend_contents_observer_.reset(new FrontendWebContentsObserver(this)); 678 frontend_contents_observer_.reset(new FrontendWebContentsObserver(this));
678 679
679 web_contents_->GetController().LoadURL(url, content::Referrer(), 680 web_contents_->GetController().LoadURL(url, content::Referrer(),
680 content::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string()); 681 content::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string());
681 682
682 frontend_host_.reset(content::DevToolsClientHost::CreateDevToolsFrontendHost( 683 frontend_host_.reset(content::DevToolsClientHost::CreateDevToolsFrontendHost(
683 web_contents_, this)); 684 web_contents_, this));
684 file_helper_.reset(new DevToolsFileHelper(web_contents_, profile)); 685 file_helper_.reset(new DevToolsFileHelper(web_contents_, profile));
685 file_system_indexer_ = new DevToolsFileSystemIndexer(); 686 file_system_indexer_ = new DevToolsFileSystemIndexer();
686 extensions::ExtensionWebContentsObserver::CreateForWebContents(web_contents_); 687 extensions::ExtensionWebContentsObserver::CreateForWebContents(web_contents_);
687 688 power_profiler_host_ = new DevToolsPowerProfilerHost(
689 weak_factory_.GetWeakPtr());
688 g_instances.Get().push_back(this); 690 g_instances.Get().push_back(this);
689 691
690 // Wipe out page icon so that the default application icon is used. 692 // Wipe out page icon so that the default application icon is used.
691 content::NavigationEntry* entry = 693 content::NavigationEntry* entry =
692 web_contents_->GetController().GetActiveEntry(); 694 web_contents_->GetController().GetActiveEntry();
693 entry->GetFavicon().image = gfx::Image(); 695 entry->GetFavicon().image = gfx::Image();
694 entry->GetFavicon().valid = true; 696 entry->GetFavicon().valid = true;
695 697
696 // Register on-load actions. 698 // Register on-load actions.
697 registrar_.Add( 699 registrar_.Add(
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
1227 return; 1229 return;
1228 } 1230 }
1229 file_system_indexer_->SearchInPath(file_system_path, 1231 file_system_indexer_->SearchInPath(file_system_path,
1230 query, 1232 query,
1231 Bind(&DevToolsWindow::SearchCompleted, 1233 Bind(&DevToolsWindow::SearchCompleted,
1232 weak_factory_.GetWeakPtr(), 1234 weak_factory_.GetWeakPtr(),
1233 request_id, 1235 request_id,
1234 file_system_path)); 1236 file_system_path));
1235 } 1237 }
1236 1238
1239 void DevToolsWindow::QueryPowerProfilerServiceStatus() {
1240 bool is_supported = true;
1241 if (!content::PowerProfilerService::GetInstance()->IsAvailable())
1242 is_supported = false;
1243 // To tell front-end, not implemented yet
1244 }
1245
1246 void DevToolsWindow::StartPowerProfiling() {
1247 power_profiler_host_->Register();
1248 }
1249
1250 void DevToolsWindow::StopPowerProfiling() {
1251 power_profiler_host_->Unregister();
1252 }
1253
1254 void DevToolsWindow::SetPowerProfilingResolution(unsigned resolution) {
1255 DCHECK(resolution >= 0 &&
1256 resolution < static_cast<unsigned>(
1257 content::PowerProfilerObserver::TYPE_COUNT));
1258 power_profiler_host_->SetResolution(
1259 static_cast<content::PowerProfilerObserver::Resolution>(resolution));
1260 }
1261
1237 void DevToolsWindow::FileSavedAs(const std::string& url) { 1262 void DevToolsWindow::FileSavedAs(const std::string& url) {
1238 StringValue url_value(url); 1263 StringValue url_value(url);
1239 CallClientFunction("InspectorFrontendAPI.savedURL", &url_value, NULL, NULL); 1264 CallClientFunction("InspectorFrontendAPI.savedURL", &url_value, NULL, NULL);
1240 } 1265 }
1241 1266
1242 void DevToolsWindow::CanceledFileSaveAs(const std::string& url) { 1267 void DevToolsWindow::CanceledFileSaveAs(const std::string& url) {
1243 StringValue url_value(url); 1268 StringValue url_value(url);
1244 CallClientFunction("InspectorFrontendAPI.canceledSaveURL", 1269 CallClientFunction("InspectorFrontendAPI.canceledSaveURL",
1245 &url_value, NULL, NULL); 1270 &url_value, NULL, NULL);
1246 } 1271 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1324 void DevToolsWindow::ShowDevToolsConfirmInfoBar( 1349 void DevToolsWindow::ShowDevToolsConfirmInfoBar(
1325 const base::string16& message, 1350 const base::string16& message,
1326 const InfoBarCallback& callback) { 1351 const InfoBarCallback& callback) {
1327 DevToolsConfirmInfoBarDelegate::Create( 1352 DevToolsConfirmInfoBarDelegate::Create(
1328 IsDocked() ? 1353 IsDocked() ?
1329 InfoBarService::FromWebContents(GetInspectedWebContents()) : 1354 InfoBarService::FromWebContents(GetInspectedWebContents()) :
1330 InfoBarService::FromWebContents(web_contents_), 1355 InfoBarService::FromWebContents(web_contents_),
1331 callback, message); 1356 callback, message);
1332 } 1357 }
1333 1358
1359 void DevToolsWindow::SendPowerEvent(const std::string& message) {
1360 // To tell front-end, not implemented yet
1361 }
1362
1334 void DevToolsWindow::CreateDevToolsBrowser() { 1363 void DevToolsWindow::CreateDevToolsBrowser() {
1335 std::string wp_key = GetDevToolsWindowPlacementPrefKey(); 1364 std::string wp_key = GetDevToolsWindowPlacementPrefKey();
1336 PrefService* prefs = profile_->GetPrefs(); 1365 PrefService* prefs = profile_->GetPrefs();
1337 const DictionaryValue* wp_pref = prefs->GetDictionary(wp_key.c_str()); 1366 const DictionaryValue* wp_pref = prefs->GetDictionary(wp_key.c_str());
1338 if (!wp_pref || wp_pref->empty()) { 1367 if (!wp_pref || wp_pref->empty()) {
1339 DictionaryPrefUpdate update(prefs, wp_key.c_str()); 1368 DictionaryPrefUpdate update(prefs, wp_key.c_str());
1340 DictionaryValue* defaults = update.Get(); 1369 DictionaryValue* defaults = update.Get();
1341 defaults->SetInteger("left", 100); 1370 defaults->SetInteger("left", 100);
1342 defaults->SetInteger("top", 100); 1371 defaults->SetInteger("top", 100);
1343 defaults->SetInteger("right", 740); 1372 defaults->SetInteger("right", 740);
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1537 return inspected_contents_observer_ ? 1566 return inspected_contents_observer_ ?
1538 inspected_contents_observer_->web_contents() : NULL; 1567 inspected_contents_observer_->web_contents() : NULL;
1539 } 1568 }
1540 1569
1541 void DevToolsWindow::DocumentOnLoadCompletedInMainFrame() { 1570 void DevToolsWindow::DocumentOnLoadCompletedInMainFrame() {
1542 is_loaded_ = true; 1571 is_loaded_ = true;
1543 UpdateTheme(); 1572 UpdateTheme();
1544 DoAction(); 1573 DoAction();
1545 AddDevToolsExtensionsToClient(); 1574 AddDevToolsExtensionsToClient();
1546 } 1575 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698