| 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 29 matching lines...) Expand all Loading... |
| 40 // Static member intialization. | 40 // Static member intialization. |
| 41 base::LazyInstance<scoped_refptr<StorageInfoProvider> > | 41 base::LazyInstance<scoped_refptr<StorageInfoProvider> > |
| 42 StorageInfoProvider::provider_ = LAZY_INSTANCE_INITIALIZER; | 42 StorageInfoProvider::provider_ = LAZY_INSTANCE_INITIALIZER; |
| 43 | 43 |
| 44 StorageInfoProvider::StorageInfoProvider() { | 44 StorageInfoProvider::StorageInfoProvider() { |
| 45 } | 45 } |
| 46 | 46 |
| 47 StorageInfoProvider::~StorageInfoProvider() { | 47 StorageInfoProvider::~StorageInfoProvider() { |
| 48 } | 48 } |
| 49 | 49 |
| 50 const StorageUnitInfoList& StorageInfoProvider::storage_unit_info_list() const { | |
| 51 return info_; | |
| 52 } | |
| 53 | |
| 54 void StorageInfoProvider::InitializeForTesting( | 50 void StorageInfoProvider::InitializeForTesting( |
| 55 scoped_refptr<StorageInfoProvider> provider) { | 51 scoped_refptr<StorageInfoProvider> provider) { |
| 56 DCHECK(provider.get() != NULL); | 52 DCHECK(provider.get() != NULL); |
| 57 provider_.Get() = provider; | 53 provider_.Get() = provider; |
| 58 } | 54 } |
| 59 | 55 |
| 60 void StorageInfoProvider::PrepareQueryOnUIThread() { | 56 void StorageInfoProvider::PrepareQueryOnUIThread() { |
| 61 // Get all available storage devices before invoking |QueryInfo()|. | 57 // Get all available storage devices before invoking |QueryInfo()|. |
| 62 GetAllStoragesIntoInfoList(); | 58 GetAllStoragesIntoInfoList(); |
| 63 } | 59 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 79 } | 75 } |
| 80 | 76 |
| 81 void StorageInfoProvider::GetAllStoragesIntoInfoList() { | 77 void StorageInfoProvider::GetAllStoragesIntoInfoList() { |
| 82 info_.clear(); | 78 info_.clear(); |
| 83 std::vector<StorageInfo> storage_list = | 79 std::vector<StorageInfo> storage_list = |
| 84 StorageMonitor::GetInstance()->GetAllAvailableStorages(); | 80 StorageMonitor::GetInstance()->GetAllAvailableStorages(); |
| 85 | 81 |
| 86 for (std::vector<StorageInfo>::const_iterator it = storage_list.begin(); | 82 for (std::vector<StorageInfo>::const_iterator it = storage_list.begin(); |
| 87 it != storage_list.end(); | 83 it != storage_list.end(); |
| 88 ++it) { | 84 ++it) { |
| 89 linked_ptr<StorageUnitInfo> unit(new StorageUnitInfo()); | 85 StorageUnitInfo unit; |
| 90 systeminfo::BuildStorageUnitInfo(*it, unit.get()); | 86 systeminfo::BuildStorageUnitInfo(*it, &unit); |
| 91 info_.push_back(unit); | 87 info_.push_back(std::move(unit)); |
| 92 } | 88 } |
| 93 } | 89 } |
| 94 | 90 |
| 95 double StorageInfoProvider::GetStorageFreeSpaceFromTransientIdOnFileThread( | 91 double StorageInfoProvider::GetStorageFreeSpaceFromTransientIdOnFileThread( |
| 96 const std::string& transient_id) { | 92 const std::string& transient_id) { |
| 97 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 93 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
| 98 std::vector<StorageInfo> storage_list = | 94 std::vector<StorageInfo> storage_list = |
| 99 StorageMonitor::GetInstance()->GetAllAvailableStorages(); | 95 StorageMonitor::GetInstance()->GetAllAvailableStorages(); |
| 100 | 96 |
| 101 std::string device_id = | 97 std::string device_id = |
| (...skipping 12 matching lines...) Expand all Loading... |
| 114 } | 110 } |
| 115 | 111 |
| 116 // static | 112 // static |
| 117 StorageInfoProvider* StorageInfoProvider::Get() { | 113 StorageInfoProvider* StorageInfoProvider::Get() { |
| 118 if (provider_.Get().get() == NULL) | 114 if (provider_.Get().get() == NULL) |
| 119 provider_.Get() = new StorageInfoProvider(); | 115 provider_.Get() = new StorageInfoProvider(); |
| 120 return provider_.Get().get(); | 116 return provider_.Get().get(); |
| 121 } | 117 } |
| 122 | 118 |
| 123 } // namespace extensions | 119 } // namespace extensions |
| OLD | NEW |