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

Side by Side Diff: chrome/browser/extensions/api/system_storage/storage_info_provider.cc

Issue 120303003: [StorageMonitor] Move gallery name generation to StorageInfo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address vandebo's comments Created 6 years, 9 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_storage/storage_info_provider.h" 5 #include "chrome/browser/extensions/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 10 matching lines...) Expand all
21 using api::system_storage::StorageUnitInfo; 21 using api::system_storage::StorageUnitInfo;
22 using api::system_storage::STORAGE_UNIT_TYPE_FIXED; 22 using api::system_storage::STORAGE_UNIT_TYPE_FIXED;
23 using api::system_storage::STORAGE_UNIT_TYPE_REMOVABLE; 23 using api::system_storage::STORAGE_UNIT_TYPE_REMOVABLE;
24 24
25 namespace systeminfo { 25 namespace systeminfo {
26 26
27 void BuildStorageUnitInfo(const StorageInfo& info, 27 void BuildStorageUnitInfo(const StorageInfo& info,
28 StorageUnitInfo* unit) { 28 StorageUnitInfo* unit) {
29 unit->id = StorageMonitor::GetInstance()->GetTransientIdForDeviceId( 29 unit->id = StorageMonitor::GetInstance()->GetTransientIdForDeviceId(
30 info.device_id()); 30 info.device_id());
31 unit->name = base::UTF16ToUTF8(info.name()); 31 if (StorageInfo::IsRemovableDevice(info.device_id())) {
32 // TODO(hmin): Might need to take MTP device into consideration. 32 // TODO(hmin): Might need to take MTP device into consideration.
33 unit->type = StorageInfo::IsRemovableDevice(info.device_id()) ? 33 unit->name = base::UTF16ToUTF8(info.GetDisplayName(false));
34 STORAGE_UNIT_TYPE_REMOVABLE : STORAGE_UNIT_TYPE_FIXED; 34 unit->type = STORAGE_UNIT_TYPE_REMOVABLE;
35 } else {
36 unit->name = base::UTF16ToUTF8(info.storage_label());
37 unit->type = STORAGE_UNIT_TYPE_FIXED;
38 }
35 unit->capacity = static_cast<double>(info.total_size_in_bytes()); 39 unit->capacity = static_cast<double>(info.total_size_in_bytes());
36 } 40 }
37 41
38 } // namespace systeminfo 42 } // namespace systeminfo
39 43
40 // Static member intialization. 44 // Static member intialization.
41 base::LazyInstance<scoped_refptr<StorageInfoProvider> > 45 base::LazyInstance<scoped_refptr<StorageInfoProvider> >
42 StorageInfoProvider::provider_ = LAZY_INSTANCE_INITIALIZER; 46 StorageInfoProvider::provider_ = LAZY_INSTANCE_INITIALIZER;
43 47
44 StorageInfoProvider::StorageInfoProvider() { 48 StorageInfoProvider::StorageInfoProvider() {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 } 118 }
115 119
116 // static 120 // static
117 StorageInfoProvider* StorageInfoProvider::Get() { 121 StorageInfoProvider* StorageInfoProvider::Get() {
118 if (provider_.Get().get() == NULL) 122 if (provider_.Get().get() == NULL)
119 provider_.Get() = new StorageInfoProvider(); 123 provider_.Get() = new StorageInfoProvider();
120 return provider_.Get(); 124 return provider_.Get();
121 } 125 }
122 126
123 } // namespace extensions 127 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698