 Chromium Code Reviews
 Chromium Code Reviews Issue 137383005:
  Devtools: UMA for InspectElement loading time was added  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 137383005:
  Devtools: UMA for InspectElement loading time was added  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| 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/devtools/devtools_window.h" | 5 #include "chrome/browser/devtools/devtools_window.h" | 
| 6 #include <algorithm> | 6 #include <algorithm> | 
| 7 | 7 | 
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" | 
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" | 
| 10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" | 
| 11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" | 
| 12 #include "base/metrics/histogram.h" | |
| 12 #include "base/prefs/scoped_user_pref_update.h" | 13 #include "base/prefs/scoped_user_pref_update.h" | 
| 13 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" | 
| 14 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" | 
| 15 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" | 
| 17 #include "base/time/time.h" | |
| 16 #include "base/values.h" | 18 #include "base/values.h" | 
| 17 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" | 
| 18 #include "chrome/browser/chrome_notification_types.h" | 20 #include "chrome/browser/chrome_notification_types.h" | 
| 19 #include "chrome/browser/extensions/api/debugger/debugger_api.h" | 21 #include "chrome/browser/extensions/api/debugger/debugger_api.h" | 
| 20 #include "chrome/browser/extensions/extension_service.h" | 22 #include "chrome/browser/extensions/extension_service.h" | 
| 21 #include "chrome/browser/extensions/extension_system.h" | 23 #include "chrome/browser/extensions/extension_system.h" | 
| 22 #include "chrome/browser/extensions/extension_web_contents_observer.h" | 24 #include "chrome/browser/extensions/extension_web_contents_observer.h" | 
| 23 #include "chrome/browser/file_select_helper.h" | 25 #include "chrome/browser/file_select_helper.h" | 
| 24 #include "chrome/browser/infobars/confirm_infobar_delegate.h" | 26 #include "chrome/browser/infobars/confirm_infobar_delegate.h" | 
| 25 #include "chrome/browser/infobars/infobar.h" | 27 #include "chrome/browser/infobars/infobar.h" | 
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 460 return window; | 462 return window; | 
| 461 } | 463 } | 
| 462 | 464 | 
| 463 // static | 465 // static | 
| 464 void DevToolsWindow::InspectElement(content::RenderViewHost* inspected_rvh, | 466 void DevToolsWindow::InspectElement(content::RenderViewHost* inspected_rvh, | 
| 465 int x, | 467 int x, | 
| 466 int y) { | 468 int y) { | 
| 467 scoped_refptr<DevToolsAgentHost> agent( | 469 scoped_refptr<DevToolsAgentHost> agent( | 
| 468 DevToolsAgentHost::GetOrCreateFor(inspected_rvh)); | 470 DevToolsAgentHost::GetOrCreateFor(inspected_rvh)); | 
| 469 agent->InspectElement(x, y); | 471 agent->InspectElement(x, y); | 
| 472 bool should_measure_time = FindDevToolsWindow(agent.get()) == NULL; | |
| 473 base::TimeTicks start_time = base::TimeTicks::Now(); | |
| 470 // TODO(loislo): we should initiate DevTools window opening from within | 474 // TODO(loislo): we should initiate DevTools window opening from within | 
| 471 // renderer. Otherwise, we still can hit a race condition here. | 475 // renderer. Otherwise, we still can hit a race condition here. | 
| 472 OpenDevToolsWindow(inspected_rvh); | 476 DevToolsWindow* window = OpenDevToolsWindow(inspected_rvh); | 
| 477 if (should_measure_time) { | |
| 
pfeldman
2014/01/29 13:51:35
drop {}
 
sergeyv
2014/01/29 14:12:38
Done.
 | |
| 478 window->inspect_element_start_time_ = start_time; | |
| 479 } | |
| 473 } | 480 } | 
| 474 | 481 | 
| 475 // static | 482 // static | 
| 476 int DevToolsWindow::GetMinimizedHeight() { | 483 int DevToolsWindow::GetMinimizedHeight() { | 
| 477 const int kMinimizedDevToolsHeight = 24; | 484 const int kMinimizedDevToolsHeight = 24; | 
| 478 return kMinimizedDevToolsHeight; | 485 return kMinimizedDevToolsHeight; | 
| 479 } | 486 } | 
| 480 | 487 | 
| 481 void DevToolsWindow::InspectedContentsClosing() { | 488 void DevToolsWindow::InspectedContentsClosing() { | 
| 482 intercepted_page_beforeunload_ = false; | 489 intercepted_page_beforeunload_ = false; | 
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 992 | 999 | 
| 993 contents_insets_ = gfx::Insets(top, left, bottom, right); | 1000 contents_insets_ = gfx::Insets(top, left, bottom, right); | 
| 994 if (is_docked_) { | 1001 if (is_docked_) { | 
| 995 // Update inspected window. | 1002 // Update inspected window. | 
| 996 BrowserWindow* inspected_window = GetInspectedBrowserWindow(); | 1003 BrowserWindow* inspected_window = GetInspectedBrowserWindow(); | 
| 997 if (inspected_window) | 1004 if (inspected_window) | 
| 998 inspected_window->UpdateDevTools(); | 1005 inspected_window->UpdateDevTools(); | 
| 999 } | 1006 } | 
| 1000 } | 1007 } | 
| 1001 | 1008 | 
| 1009 void DevToolsWindow::InspectElementLoadingCompleted() { | |
| 1010 if (!inspect_element_start_time_.is_null()) { | |
| 1011 UMA_HISTOGRAM_TIMES("DevTools.InspectElement", | |
| 1012 base::TimeTicks::Now() - inspect_element_start_time_); | |
| 1013 inspect_element_start_time_ = base::TimeTicks(); | |
| 1014 } | |
| 1015 } | |
| 1016 | |
| 1002 void DevToolsWindow::MoveWindow(int x, int y) { | 1017 void DevToolsWindow::MoveWindow(int x, int y) { | 
| 1003 if (!is_docked_) { | 1018 if (!is_docked_) { | 
| 1004 gfx::Rect bounds = browser_->window()->GetBounds(); | 1019 gfx::Rect bounds = browser_->window()->GetBounds(); | 
| 1005 bounds.Offset(x, y); | 1020 bounds.Offset(x, y); | 
| 1006 browser_->window()->SetBounds(bounds); | 1021 browser_->window()->SetBounds(bounds); | 
| 1007 } | 1022 } | 
| 1008 } | 1023 } | 
| 1009 | 1024 | 
| 1010 void DevToolsWindow::SetIsDockedAndShowImmediatelyForTest(bool is_docked) { | 1025 void DevToolsWindow::SetIsDockedAndShowImmediatelyForTest(bool is_docked) { | 
| 1011 DCHECK(!is_docked || can_dock_); | 1026 DCHECK(!is_docked || can_dock_); | 
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1473 if (load_state_ == kLoadCompleted) | 1488 if (load_state_ == kLoadCompleted) | 
| 1474 LoadCompleted(); | 1489 LoadCompleted(); | 
| 1475 } | 1490 } | 
| 1476 | 1491 | 
| 1477 void DevToolsWindow::LoadCompleted() { | 1492 void DevToolsWindow::LoadCompleted() { | 
| 1478 Show(action_on_load_); | 1493 Show(action_on_load_); | 
| 1479 action_on_load_ = DevToolsToggleAction::NoOp(); | 1494 action_on_load_ = DevToolsToggleAction::NoOp(); | 
| 1480 UpdateTheme(); | 1495 UpdateTheme(); | 
| 1481 AddDevToolsExtensionsToClient(); | 1496 AddDevToolsExtensionsToClient(); | 
| 1482 } | 1497 } | 
| OLD | NEW |