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

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

Issue 2097753002: Make memory pressure notifier configurable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment Created 4 years, 5 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 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"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 104
105 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 105 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
106 FROM_HERE, base::Bind(&CastMemoryPressureMonitor::PollPressureLevel, 106 FROM_HERE, base::Bind(&CastMemoryPressureMonitor::PollPressureLevel,
107 weak_ptr_factory_.GetWeakPtr()), 107 weak_ptr_factory_.GetWeakPtr()),
108 base::TimeDelta::FromMilliseconds(kPollingIntervalMS)); 108 base::TimeDelta::FromMilliseconds(kPollingIntervalMS));
109 } 109 }
110 110
111 void CastMemoryPressureMonitor::UpdateMemoryPressureLevel( 111 void CastMemoryPressureMonitor::UpdateMemoryPressureLevel(
112 MemoryPressureLevel new_level) { 112 MemoryPressureLevel new_level) {
113 if (new_level != base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE) 113 if (new_level != base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE)
114 base::MemoryPressureListener::NotifyMemoryPressure(new_level); 114 dispatch_callback_(new_level);
115 115
116 if (new_level == current_level_) 116 if (new_level == current_level_)
117 return; 117 return;
118 118
119 current_level_ = new_level; 119 current_level_ = new_level;
120 metrics::CastMetricsHelper::GetInstance()->RecordApplicationEventWithValue( 120 metrics::CastMetricsHelper::GetInstance()->RecordApplicationEventWithValue(
121 "Memory.Pressure.LevelChange", new_level); 121 "Memory.Pressure.LevelChange", new_level);
122 } 122 }
123 123
124 void MemoryPressureMonitor::SetDispatchCallback(DispatchCallback callback) {
125 dispatch_callback_ = callback;
126 }
127
124 } // namespace chromecast 128 } // namespace chromecast
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698