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

Side by Side Diff: third_party/WebKit/Source/platform/MemoryCoordinator.cpp

Issue 2933503002: Add IsCurrentlyLowMemory (Closed)
Patch Set: added comment Created 3 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 | « third_party/WebKit/Source/platform/MemoryCoordinator.h ('k') | 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "platform/MemoryCoordinator.h" 5 #include "platform/MemoryCoordinator.h"
6 6
7 #include "base/sys_info.h" 7 #include "base/sys_info.h"
8 #include "platform/fonts/FontCache.h" 8 #include "platform/fonts/FontCache.h"
9 #include "platform/graphics/ImageDecodingStore.h" 9 #include "platform/graphics/ImageDecodingStore.h"
10 #include "platform/instrumentation/tracing/TraceEvent.h" 10 #include "platform/instrumentation/tracing/TraceEvent.h"
11 #include "platform/wtf/allocator/Partitions.h" 11 #include "platform/wtf/allocator/Partitions.h"
12 12
13 #if OS(ANDROID)
14 #include "base/android/sys_utils.h"
15 #endif
16
13 namespace blink { 17 namespace blink {
14 18
15 // static 19 // static
16 bool MemoryCoordinator::is_low_end_device_ = false; 20 bool MemoryCoordinator::is_low_end_device_ = false;
17 int64_t MemoryCoordinator::physical_memory_mb_ = 0; 21 int64_t MemoryCoordinator::physical_memory_mb_ = 0;
18 22
19 // static 23 // static
20 bool MemoryCoordinator::IsLowEndDevice() { 24 bool MemoryCoordinator::IsLowEndDevice() {
21 return is_low_end_device_; 25 return is_low_end_device_;
22 } 26 }
23 27
24 // static 28 // static
25 int64_t MemoryCoordinator::GetPhysicalMemoryMB() { 29 int64_t MemoryCoordinator::GetPhysicalMemoryMB() {
26 return physical_memory_mb_; 30 return physical_memory_mb_;
27 } 31 }
28 32
29 // static 33 // static
30 void MemoryCoordinator::SetPhysicalMemoryMBForTesting( 34 void MemoryCoordinator::SetPhysicalMemoryMBForTesting(
31 int64_t physical_memory_mb) { 35 int64_t physical_memory_mb) {
32 physical_memory_mb_ = physical_memory_mb; 36 physical_memory_mb_ = physical_memory_mb;
33 } 37 }
34 38
35 // static 39 // static
40 bool MemoryCoordinator::IsCurrentlyLowMemory() {
41 #if OS(ANDROID)
42 return base::android::SysUtils::IsCurrentlyLowMemory();
43 #else
44 return false;
45 #endif
46 }
47
48 // static
36 void MemoryCoordinator::Initialize() { 49 void MemoryCoordinator::Initialize() {
37 is_low_end_device_ = ::base::SysInfo::IsLowEndDevice(); 50 is_low_end_device_ = ::base::SysInfo::IsLowEndDevice();
38 physical_memory_mb_ = ::base::SysInfo::AmountOfPhysicalMemoryMB(); 51 physical_memory_mb_ = ::base::SysInfo::AmountOfPhysicalMemoryMB();
39 } 52 }
40 53
41 // static 54 // static
42 void MemoryCoordinator::SetIsLowEndDeviceForTesting(bool is_low_end_device) { 55 void MemoryCoordinator::SetIsLowEndDeviceForTesting(bool is_low_end_device) {
43 is_low_end_device_ = is_low_end_device; 56 is_low_end_device_ = is_low_end_device;
44 } 57 }
45 58
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 // MemoryCoordinatorClients rather than clearing caches here. 110 // MemoryCoordinatorClients rather than clearing caches here.
98 ImageDecodingStore::Instance().Clear(); 111 ImageDecodingStore::Instance().Clear();
99 FontCache::GetFontCache()->Invalidate(); 112 FontCache::GetFontCache()->Invalidate();
100 } 113 }
101 114
102 DEFINE_TRACE(MemoryCoordinator) { 115 DEFINE_TRACE(MemoryCoordinator) {
103 visitor->Trace(clients_); 116 visitor->Trace(clients_);
104 } 117 }
105 118
106 } // namespace blink 119 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/MemoryCoordinator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698