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

Side by Side Diff: chrome/browser/memory/tab_manager.cc

Issue 1366643002: Extract guts of ChromeStabilityMetricsProvider into helper class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 2 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/memory/tab_manager.h" 5 #include "chrome/browser/memory/tab_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
11 #include "ash/multi_profile_uma.h" 11 #include "ash/multi_profile_uma.h"
12 #include "ash/session/session_state_delegate.h" 12 #include "ash/session/session_state_delegate.h"
13 #include "ash/shell.h" 13 #include "ash/shell.h"
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/bind_helpers.h" 15 #include "base/bind_helpers.h"
16 #include "base/command_line.h" 16 #include "base/command_line.h"
17 #include "base/memory/memory_pressure_monitor.h" 17 #include "base/memory/memory_pressure_monitor.h"
18 #include "base/metrics/field_trial.h" 18 #include "base/metrics/field_trial.h"
19 #include "base/metrics/histogram.h" 19 #include "base/metrics/histogram.h"
20 #include "base/process/process.h" 20 #include "base/process/process.h"
21 #include "base/strings/string16.h" 21 #include "base/strings/string16.h"
22 #include "base/strings/string_number_conversions.h" 22 #include "base/strings/string_number_conversions.h"
23 #include "base/strings/string_util.h" 23 #include "base/strings/string_util.h"
24 #include "base/strings/utf_string_conversions.h" 24 #include "base/strings/utf_string_conversions.h"
25 #include "base/threading/thread.h" 25 #include "base/threading/thread.h"
26 #include "build/build_config.h" 26 #include "build/build_config.h"
27 #include "chrome/browser/browser_process.h" 27 #include "chrome/browser/browser_process.h"
28 #include "chrome/browser/memory/oom_memory_details.h" 28 #include "chrome/browser/memory/oom_memory_details.h"
29 #include "chrome/browser/memory/system_memory_stats_recorder.h"
30 #include "chrome/browser/ui/browser.h" 29 #include "chrome/browser/ui/browser.h"
31 #include "chrome/browser/ui/browser_iterator.h" 30 #include "chrome/browser/ui/browser_iterator.h"
32 #include "chrome/browser/ui/browser_list.h" 31 #include "chrome/browser/ui/browser_list.h"
33 #include "chrome/browser/ui/host_desktop.h" 32 #include "chrome/browser/ui/host_desktop.h"
34 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" 33 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h"
35 #include "chrome/browser/ui/tabs/tab_discard_state.h" 34 #include "chrome/browser/ui/tabs/tab_discard_state.h"
36 #include "chrome/browser/ui/tabs/tab_strip_model.h" 35 #include "chrome/browser/ui/tabs/tab_strip_model.h"
37 #include "chrome/browser/ui/tabs/tab_utils.h" 36 #include "chrome/browser/ui/tabs/tab_utils.h"
38 #include "chrome/common/chrome_constants.h" 37 #include "chrome/common/chrome_constants.h"
39 #include "chrome/common/url_constants.h" 38 #include "chrome/common/url_constants.h"
39 #include "components/metrics/system_memory_stats_recorder.h"
40 #include "content/public/browser/browser_thread.h" 40 #include "content/public/browser/browser_thread.h"
41 #include "content/public/browser/render_process_host.h" 41 #include "content/public/browser/render_process_host.h"
42 #include "content/public/browser/web_contents.h" 42 #include "content/public/browser/web_contents.h"
43 43
44 #if defined(OS_CHROMEOS) 44 #if defined(OS_CHROMEOS)
45 #include "chrome/browser/memory/tab_manager_delegate_chromeos.h" 45 #include "chrome/browser/memory/tab_manager_delegate_chromeos.h"
46 #endif 46 #endif
47 47
48 using base::TimeDelta; 48 using base::TimeDelta;
49 using base::TimeTicks; 49 using base::TimeTicks;
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 int interval_ms = static_cast<int>(interval.InMilliseconds()); 286 int interval_ms = static_cast<int>(interval.InMilliseconds());
287 // Record time in milliseconds over an interval of approximately 1 day. 287 // Record time in milliseconds over an interval of approximately 1 day.
288 // Start at 100 ms to get extra resolution in the target 750 ms range. 288 // Start at 100 ms to get extra resolution in the target 750 ms range.
289 UMA_HISTOGRAM_CUSTOM_COUNTS("Tabs.Discard.IntervalTime2", interval_ms, 100, 289 UMA_HISTOGRAM_CUSTOM_COUNTS("Tabs.Discard.IntervalTime2", interval_ms, 100,
290 100000 * 1000, 50); 290 100000 * 1000, 50);
291 } 291 }
292 // TODO(georgesak): Remove this #if when RecordMemoryStats is implemented for 292 // TODO(georgesak): Remove this #if when RecordMemoryStats is implemented for
293 // all platforms. 293 // all platforms.
294 #if defined(OS_WIN) || defined(OS_CHROMEOS) 294 #if defined(OS_WIN) || defined(OS_CHROMEOS)
295 // Record system memory usage at the time of the discard. 295 // Record system memory usage at the time of the discard.
296 RecordMemoryStats(RECORD_MEMORY_STATS_TAB_DISCARDED); 296 metrics::RecordMemoryStats(metrics::RECORD_MEMORY_STATS_TAB_DISCARDED);
297 #endif 297 #endif
298 // Set up to record the next interval. 298 // Set up to record the next interval.
299 last_discard_time_ = TimeTicks::Now(); 299 last_discard_time_ = TimeTicks::Now();
300 } 300 }
301 301
302 void TabManager::RecordRecentTabDiscard() { 302 void TabManager::RecordRecentTabDiscard() {
303 // If we are shutting down, do not do anything. 303 // If we are shutting down, do not do anything.
304 if (g_browser_process->IsShuttingDown()) 304 if (g_browser_process->IsShuttingDown())
305 return; 305 return;
306 306
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 // sudden_termination_allowed false, and that covers too many common pages 473 // sudden_termination_allowed false, and that covers too many common pages
474 // with ad networks and statistics scripts. Ideally we would like to check 474 // with ad networks and statistics scripts. Ideally we would like to check
475 // for beforeUnload handlers, which are likely to present a dialog asking 475 // for beforeUnload handlers, which are likely to present a dialog asking
476 // if the user wants to discard state. crbug.com/123049 476 // if the user wants to discard state. crbug.com/123049
477 477
478 // Being more recently active is more important. 478 // Being more recently active is more important.
479 return first.last_active > second.last_active; 479 return first.last_active > second.last_active;
480 } 480 }
481 481
482 } // namespace memory 482 } // namespace memory
OLDNEW
« no previous file with comments | « chrome/browser/memory/system_memory_stats_recorder_win.cc ('k') | chrome/browser/metrics/chrome_metrics_service_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698