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

Side by Side Diff: chrome/browser/storage_monitor/storage_monitor.cc

Issue 15896007: [SystemInfo API] Rewrite storage info provider using storage monitor impl (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fix comments from thestig Created 7 years, 6 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/storage_monitor/storage_monitor.h" 5 #include "chrome/browser/storage_monitor/storage_monitor.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/storage_monitor/removable_storage_observer.h" 9 #include "chrome/browser/storage_monitor/removable_storage_observer.h"
10 #include "chrome/browser/storage_monitor/transient_device_ids.h" 10 #include "chrome/browser/storage_monitor/transient_device_ids.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 54
55 base::AutoLock lock(storage_lock_); 55 base::AutoLock lock(storage_lock_);
56 for (RemovableStorageMap::const_iterator it = storage_map_.begin(); 56 for (RemovableStorageMap::const_iterator it = storage_map_.begin();
57 it != storage_map_.end(); 57 it != storage_map_.end();
58 ++it) { 58 ++it) {
59 results.push_back(it->second); 59 results.push_back(it->second);
60 } 60 }
61 return results; 61 return results;
62 } 62 }
63 63
64 std::vector<StorageInfo> StorageMonitor::GetAllAvailableStorages() const {
65 // Returns empty vector as default implemenation.
66 return std::vector<StorageInfo>();
67 }
68
64 void StorageMonitor::Initialize(base::Closure callback) { 69 void StorageMonitor::Initialize(base::Closure callback) {
70 RegisterInitCompletedCallback(callback);
71 Init();
72 }
73
74 void StorageMonitor::RegisterInitCompletedCallback(
75 base::Closure callback) {
65 if (initialized_) { 76 if (initialized_) {
66 if (!callback.is_null()) 77 if (!callback.is_null())
67 callback.Run(); 78 callback.Run();
68 return; 79 return;
69 } 80 }
70 81
71 if (!callback.is_null()) { 82 if (!callback.is_null()) {
72 on_initialize_callbacks_.push_back(callback); 83 on_initialize_callbacks_.push_back(callback);
73 } 84 }
74
75 Init();
76 } 85 }
77 86
78 bool StorageMonitor::IsInitialized() { 87 bool StorageMonitor::IsInitialized() {
79 return initialized_; 88 return initialized_;
80 } 89 }
81 90
82 void StorageMonitor::AddObserver(RemovableStorageObserver* obs) { 91 void StorageMonitor::AddObserver(RemovableStorageObserver* obs) {
83 observer_list_->AddObserver(obs); 92 observer_list_->AddObserver(obs);
84 } 93 }
85 94
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 info = it->second; 175 info = it->second;
167 storage_map_.erase(it); 176 storage_map_.erase(it);
168 } 177 }
169 178
170 DVLOG(1) << "RemovableStorageDetached for id " << id; 179 DVLOG(1) << "RemovableStorageDetached for id " << id;
171 observer_list_->Notify( 180 observer_list_->Notify(
172 &RemovableStorageObserver::OnRemovableStorageDetached, info); 181 &RemovableStorageObserver::OnRemovableStorageDetached, info);
173 } 182 }
174 183
175 } // namespace chrome 184 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698