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

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

Issue 1366643002: Extract guts of ChromeStabilityMetricsProvider into helper class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More build fixes 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/oom_priority_manager.h" 5 #include "chrome/browser/memory/oom_priority_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/oom_priority_manager_delegate_chromeos.h" 45 #include "chrome/browser/memory/oom_priority_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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 int interval_ms = static_cast<int>(interval.InMilliseconds()); 288 int interval_ms = static_cast<int>(interval.InMilliseconds());
289 // Record time in milliseconds over an interval of approximately 1 day. 289 // Record time in milliseconds over an interval of approximately 1 day.
290 // Start at 100 ms to get extra resolution in the target 750 ms range. 290 // Start at 100 ms to get extra resolution in the target 750 ms range.
291 UMA_HISTOGRAM_CUSTOM_COUNTS("Tabs.Discard.IntervalTime2", interval_ms, 100, 291 UMA_HISTOGRAM_CUSTOM_COUNTS("Tabs.Discard.IntervalTime2", interval_ms, 100,
292 100000 * 1000, 50); 292 100000 * 1000, 50);
293 } 293 }
294 // TODO(georgesak): Remove this #if when RecordMemoryStats is implemented for 294 // TODO(georgesak): Remove this #if when RecordMemoryStats is implemented for
295 // all platforms. 295 // all platforms.
296 #if defined(OS_WIN) || defined(OS_CHROMEOS) 296 #if defined(OS_WIN) || defined(OS_CHROMEOS)
297 // Record system memory usage at the time of the discard. 297 // Record system memory usage at the time of the discard.
298 RecordMemoryStats(RECORD_MEMORY_STATS_TAB_DISCARDED); 298 metrics::RecordMemoryStats(metrics::RECORD_MEMORY_STATS_TAB_DISCARDED);
299 #endif 299 #endif
300 // Set up to record the next interval. 300 // Set up to record the next interval.
301 last_discard_time_ = TimeTicks::Now(); 301 last_discard_time_ = TimeTicks::Now();
302 } 302 }
303 303
304 void OomPriorityManager::RecordRecentTabDiscard() { 304 void OomPriorityManager::RecordRecentTabDiscard() {
305 // If we are shutting down, do not do anything. 305 // If we are shutting down, do not do anything.
306 if (g_browser_process->IsShuttingDown()) 306 if (g_browser_process->IsShuttingDown())
307 return; 307 return;
308 308
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 // sudden_termination_allowed false, and that covers too many common pages 475 // sudden_termination_allowed false, and that covers too many common pages
476 // with ad networks and statistics scripts. Ideally we would like to check 476 // with ad networks and statistics scripts. Ideally we would like to check
477 // for beforeUnload handlers, which are likely to present a dialog asking 477 // for beforeUnload handlers, which are likely to present a dialog asking
478 // if the user wants to discard state. crbug.com/123049 478 // if the user wants to discard state. crbug.com/123049
479 479
480 // Being more recently active is more important. 480 // Being more recently active is more important.
481 return first.last_active > second.last_active; 481 return first.last_active > second.last_active;
482 } 482 }
483 483
484 } // namespace memory 484 } // namespace memory
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698