| OLD | NEW |
| 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 "extensions/browser/api/system_storage/storage_info_provider.h" | 5 #include "extensions/browser/api/system_storage/storage_info_provider.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "base/sys_info.h" | 9 #include "base/sys_info.h" |
| 10 #include "base/threading/sequenced_worker_pool.h" | 10 #include "base/threading/sequenced_worker_pool.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 StorageInfoProvider::~StorageInfoProvider() { | 47 StorageInfoProvider::~StorageInfoProvider() { |
| 48 } | 48 } |
| 49 | 49 |
| 50 const StorageUnitInfoList& StorageInfoProvider::storage_unit_info_list() const { | 50 const StorageUnitInfoList& StorageInfoProvider::storage_unit_info_list() const { |
| 51 return info_; | 51 return info_; |
| 52 } | 52 } |
| 53 | 53 |
| 54 void StorageInfoProvider::InitializeForTesting( | 54 void StorageInfoProvider::InitializeForTesting( |
| 55 scoped_refptr<StorageInfoProvider> provider) { | 55 scoped_refptr<StorageInfoProvider> provider) { |
| 56 DCHECK(provider.get() != NULL); | 56 DCHECK(provider.get() != nullptr); |
| 57 provider_.Get() = provider; | 57 provider_.Get() = provider; |
| 58 } | 58 } |
| 59 | 59 |
| 60 void StorageInfoProvider::PrepareQueryOnUIThread() { | 60 void StorageInfoProvider::PrepareQueryOnUIThread() { |
| 61 // Get all available storage devices before invoking |QueryInfo()|. | 61 // Get all available storage devices before invoking |QueryInfo()|. |
| 62 GetAllStoragesIntoInfoList(); | 62 GetAllStoragesIntoInfoList(); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void StorageInfoProvider::InitializeProvider( | 65 void StorageInfoProvider::InitializeProvider( |
| 66 const base::Closure& do_query_info_callback) { | 66 const base::Closure& do_query_info_callback) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 if (device_id == it->device_id()) | 108 if (device_id == it->device_id()) |
| 109 return static_cast<double>( | 109 return static_cast<double>( |
| 110 base::SysInfo::AmountOfFreeDiskSpace(base::FilePath(it->location()))); | 110 base::SysInfo::AmountOfFreeDiskSpace(base::FilePath(it->location()))); |
| 111 } | 111 } |
| 112 | 112 |
| 113 return -1; | 113 return -1; |
| 114 } | 114 } |
| 115 | 115 |
| 116 // static | 116 // static |
| 117 StorageInfoProvider* StorageInfoProvider::Get() { | 117 StorageInfoProvider* StorageInfoProvider::Get() { |
| 118 if (provider_.Get().get() == NULL) | 118 if (provider_.Get().get() == nullptr) |
| 119 provider_.Get() = new StorageInfoProvider(); | 119 provider_.Get() = new StorageInfoProvider(); |
| 120 return provider_.Get().get(); | 120 return provider_.Get().get(); |
| 121 } | 121 } |
| 122 | 122 |
| 123 } // namespace extensions | 123 } // namespace extensions |
| OLD | NEW |