| OLD | NEW | 
|    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 namespace blink { |   13 namespace blink { | 
|   14  |   14  | 
|   15 // static |   15 // static | 
|   16 bool MemoryCoordinator::is_low_end_device_ = false; |   16 bool MemoryCoordinator::is_low_end_device_ = false; | 
 |   17 int64_t MemoryCoordinator::physical_memory_mb_ = 0; | 
|   17  |   18  | 
|   18 // static |   19 // static | 
|   19 bool MemoryCoordinator::IsLowEndDevice() { |   20 bool MemoryCoordinator::IsLowEndDevice() { | 
|   20   return is_low_end_device_; |   21   return is_low_end_device_; | 
|   21 } |   22 } | 
|   22  |   23  | 
|   23 // static |   24 // static | 
 |   25 int64_t MemoryCoordinator::GetPhysicalMemoryMB() { | 
 |   26   return physical_memory_mb_; | 
 |   27 } | 
 |   28  | 
 |   29 // static | 
 |   30 void MemoryCoordinator::SetPhysicalMemoryMBForTesting( | 
 |   31     int64_t physical_memory_mb) { | 
 |   32   physical_memory_mb_ = physical_memory_mb; | 
 |   33 } | 
 |   34  | 
 |   35 // static | 
|   24 void MemoryCoordinator::Initialize() { |   36 void MemoryCoordinator::Initialize() { | 
|   25   is_low_end_device_ = ::base::SysInfo::IsLowEndDevice(); |   37   is_low_end_device_ = ::base::SysInfo::IsLowEndDevice(); | 
 |   38   physical_memory_mb_ = ::base::SysInfo::AmountOfPhysicalMemoryMB(); | 
|   26 } |   39 } | 
|   27  |   40  | 
|   28 // static |   41 // static | 
|   29 void MemoryCoordinator::SetIsLowEndDeviceForTesting(bool is_low_end_device) { |   42 void MemoryCoordinator::SetIsLowEndDeviceForTesting(bool is_low_end_device) { | 
|   30   is_low_end_device_ = is_low_end_device; |   43   is_low_end_device_ = is_low_end_device; | 
|   31 } |   44 } | 
|   32  |   45  | 
|   33 // static |   46 // static | 
|   34 MemoryCoordinator& MemoryCoordinator::Instance() { |   47 MemoryCoordinator& MemoryCoordinator::Instance() { | 
|   35   DEFINE_STATIC_LOCAL(Persistent<MemoryCoordinator>, external, |   48   DEFINE_STATIC_LOCAL(Persistent<MemoryCoordinator>, external, | 
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   84   // MemoryCoordinatorClients rather than clearing caches here. |   97   // MemoryCoordinatorClients rather than clearing caches here. | 
|   85   ImageDecodingStore::Instance().Clear(); |   98   ImageDecodingStore::Instance().Clear(); | 
|   86   FontCache::GetFontCache()->Invalidate(); |   99   FontCache::GetFontCache()->Invalidate(); | 
|   87 } |  100 } | 
|   88  |  101  | 
|   89 DEFINE_TRACE(MemoryCoordinator) { |  102 DEFINE_TRACE(MemoryCoordinator) { | 
|   90   visitor->Trace(clients_); |  103   visitor->Trace(clients_); | 
|   91 } |  104 } | 
|   92  |  105  | 
|   93 }  // namespace blink |  106 }  // namespace blink | 
| OLD | NEW |