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

Side by Side Diff: chromecast/browser/cast_memory_pressure_monitor.cc

Issue 2028233002: [Chromecast] Add free memory UMA histograms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "chromecast/browser/cast_memory_pressure_monitor.h" 5 #include "chromecast/browser/cast_memory_pressure_monitor.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/metrics/histogram_macros.h"
12 #include "base/process/process_metrics.h" 13 #include "base/process/process_metrics.h"
13 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
14 #include "base/threading/thread_task_runner_handle.h" 15 #include "base/threading/thread_task_runner_handle.h"
15 #include "chromecast/base/chromecast_switches.h" 16 #include "chromecast/base/chromecast_switches.h"
16 #include "chromecast/base/metrics/cast_metrics_helper.h" 17 #include "chromecast/base/metrics/cast_metrics_helper.h"
17 18
18 namespace chromecast { 19 namespace chromecast {
19 namespace { 20 namespace {
20 21
21 // Memory thresholds (as fraction of total memory) for memory pressure levels. 22 // Memory thresholds (as fraction of total memory) for memory pressure levels.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 DCHECK(total > 0); 82 DCHECK(total > 0);
82 83
83 if ((max_free / total) < kCriticalMemoryFraction) 84 if ((max_free / total) < kCriticalMemoryFraction)
84 level = base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL; 85 level = base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL;
85 else if ((max_free / total) < kModerateMemoryFraction) 86 else if ((max_free / total) < kModerateMemoryFraction)
86 level = base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE; 87 level = base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE;
87 } 88 }
88 } 89 }
89 90
90 UpdateMemoryPressureLevel(level); 91 UpdateMemoryPressureLevel(level);
92
93 UMA_HISTOGRAM_PERCENTAGE("Platform.MeminfoMemFree",
94 (info.free * 100.0) / info.total);
95 UMA_HISTOGRAM_CUSTOM_COUNTS("Platform.MeminfoMemFreeDerived",
96 info.free + info.buffers + info.cached, 1,
97 info.total, 100);
wzhong 2016/06/01 20:24:25 The info.total varies by platform though, for exam
98
91 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 99 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
92 FROM_HERE, base::Bind(&CastMemoryPressureMonitor::PollPressureLevel, 100 FROM_HERE, base::Bind(&CastMemoryPressureMonitor::PollPressureLevel,
93 weak_ptr_factory_.GetWeakPtr()), 101 weak_ptr_factory_.GetWeakPtr()),
94 base::TimeDelta::FromMilliseconds(kPollingIntervalMS)); 102 base::TimeDelta::FromMilliseconds(kPollingIntervalMS));
95 } 103 }
96 104
97 void CastMemoryPressureMonitor::UpdateMemoryPressureLevel( 105 void CastMemoryPressureMonitor::UpdateMemoryPressureLevel(
98 MemoryPressureLevel new_level) { 106 MemoryPressureLevel new_level) {
99 if (new_level != base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE) 107 if (new_level != base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE)
100 base::MemoryPressureListener::NotifyMemoryPressure(new_level); 108 base::MemoryPressureListener::NotifyMemoryPressure(new_level);
101 109
102 if (new_level == current_level_) 110 if (new_level == current_level_)
103 return; 111 return;
104 112
105 current_level_ = new_level; 113 current_level_ = new_level;
106 metrics::CastMetricsHelper::GetInstance()->RecordApplicationEventWithValue( 114 metrics::CastMetricsHelper::GetInstance()->RecordApplicationEventWithValue(
107 "Memory.Pressure.LevelChange", new_level); 115 "Memory.Pressure.LevelChange", new_level);
108 } 116 }
109 117
110 } // namespace chromecast 118 } // namespace chromecast
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