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

Side by Side Diff: extensions/browser/api/system_memory/memory_info_provider.cc

Issue 389633002: Move system.* family of APIs to extensions/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: No ash/ dependency anymore Created 6 years, 3 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/extensions/api/system_memory/memory_info_provider.h" 5 #include "extensions/browser/api/system_memory/memory_info_provider.h"
6 6
7 #include "base/sys_info.h" 7 #include "base/sys_info.h"
8 8
9 namespace extensions { 9 namespace extensions {
10 10
11 using api::system_memory::MemoryInfo; 11 using core_api::system_memory::MemoryInfo;
12 12
13 // Static member intialization. 13 // Static member intialization.
14 base::LazyInstance<scoped_refptr<MemoryInfoProvider> > 14 base::LazyInstance<scoped_refptr<MemoryInfoProvider> >
15 MemoryInfoProvider::provider_ = LAZY_INSTANCE_INITIALIZER; 15 MemoryInfoProvider::provider_ = LAZY_INSTANCE_INITIALIZER;
16 16
17 MemoryInfoProvider::MemoryInfoProvider() {} 17 MemoryInfoProvider::MemoryInfoProvider() {
18 }
18 19
19 MemoryInfoProvider::~MemoryInfoProvider() {} 20 MemoryInfoProvider::~MemoryInfoProvider() {
21 }
20 22
21 const MemoryInfo& MemoryInfoProvider::memory_info() const { 23 const MemoryInfo& MemoryInfoProvider::memory_info() const {
22 return info_; 24 return info_;
23 } 25 }
24 26
25 void MemoryInfoProvider::InitializeForTesting( 27 void MemoryInfoProvider::InitializeForTesting(
26 scoped_refptr<MemoryInfoProvider> provider) { 28 scoped_refptr<MemoryInfoProvider> provider) {
27 DCHECK(provider.get() != NULL); 29 DCHECK(provider.get() != NULL);
28 provider_.Get() = provider; 30 provider_.Get() = provider;
29 } 31 }
30 32
31 bool MemoryInfoProvider::QueryInfo() { 33 bool MemoryInfoProvider::QueryInfo() {
32 info_.capacity = static_cast<double>(base::SysInfo::AmountOfPhysicalMemory()); 34 info_.capacity = static_cast<double>(base::SysInfo::AmountOfPhysicalMemory());
33 info_.available_capacity = 35 info_.available_capacity =
34 static_cast<double>(base::SysInfo::AmountOfAvailablePhysicalMemory()); 36 static_cast<double>(base::SysInfo::AmountOfAvailablePhysicalMemory());
35 return true; 37 return true;
36 } 38 }
37 39
38 // static 40 // static
39 MemoryInfoProvider* MemoryInfoProvider::Get() { 41 MemoryInfoProvider* MemoryInfoProvider::Get() {
40 if (provider_.Get().get() == NULL) 42 if (provider_.Get().get() == NULL)
41 provider_.Get() = new MemoryInfoProvider(); 43 provider_.Get() = new MemoryInfoProvider();
42 return provider_.Get().get(); 44 return provider_.Get().get();
43 } 45 }
44 46
45 } // namespace extensions 47 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698