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

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

Issue 19489006: Media Galleries: Move gallery name generation back to StorageMonitor. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: rebase Created 7 years, 4 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 | Annotate | Revision Log
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/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/storage_monitor/removable_storage_observer.h" 10 #include "chrome/browser/storage_monitor/removable_storage_observer.h"
(...skipping 27 matching lines...) Expand all
38 38
39 void StorageMonitor::ReceiverImpl::ProcessDetach(const std::string& id) { 39 void StorageMonitor::ReceiverImpl::ProcessDetach(const std::string& id) {
40 notifications_->ProcessDetach(id); 40 notifications_->ProcessDetach(id);
41 } 41 }
42 42
43 void StorageMonitor::ReceiverImpl::MarkInitialized() { 43 void StorageMonitor::ReceiverImpl::MarkInitialized() {
44 notifications_->MarkInitialized(); 44 notifications_->MarkInitialized();
45 } 45 }
46 46
47 StorageMonitor* StorageMonitor::GetInstance() { 47 StorageMonitor* StorageMonitor::GetInstance() {
48 if (g_browser_process) 48 return g_browser_process ? g_browser_process->storage_monitor() : NULL;
49 return g_browser_process->storage_monitor();
50
51 return NULL;
52 } 49 }
53 50
54 std::vector<StorageInfo> StorageMonitor::GetAllAvailableStorages() const { 51 std::vector<StorageInfo> StorageMonitor::GetAllAvailableStorages() const {
55 std::vector<StorageInfo> results; 52 std::vector<StorageInfo> results;
56 53
57 base::AutoLock lock(storage_lock_); 54 base::AutoLock lock(storage_lock_);
58 for (StorageMap::const_iterator it = storage_map_.begin(); 55 for (StorageMap::const_iterator it = storage_map_.begin();
59 it != storage_map_.end(); 56 it != storage_map_.end();
60 ++it) { 57 ++it) {
61 results.push_back(it->second); 58 results.push_back(it->second);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 { 139 {
143 base::AutoLock lock(storage_lock_); 140 base::AutoLock lock(storage_lock_);
144 if (ContainsKey(storage_map_, info.device_id())) { 141 if (ContainsKey(storage_map_, info.device_id())) {
145 // This can happen if our unique id scheme fails. Ignore the incoming 142 // This can happen if our unique id scheme fails. Ignore the incoming
146 // non-unique attachment. 143 // non-unique attachment.
147 return; 144 return;
148 } 145 }
149 storage_map_.insert(std::make_pair(info.device_id(), info)); 146 storage_map_.insert(std::make_pair(info.device_id(), info));
150 } 147 }
151 148
152 DVLOG(1) << "StorageAttached with name " << UTF16ToUTF8(info.name()) 149 DVLOG(1) << "StorageAttached with id " << info.device_id();
153 << " and id " << info.device_id();
154 if (StorageInfo::IsRemovableDevice(info.device_id())) { 150 if (StorageInfo::IsRemovableDevice(info.device_id())) {
155 observer_list_->Notify( 151 observer_list_->Notify(
156 &RemovableStorageObserver::OnRemovableStorageAttached, info); 152 &RemovableStorageObserver::OnRemovableStorageAttached, info);
157 } 153 }
158 } 154 }
159 155
160 void StorageMonitor::ProcessDetach(const std::string& id) { 156 void StorageMonitor::ProcessDetach(const std::string& id) {
161 StorageInfo info; 157 StorageInfo info;
162 { 158 {
163 base::AutoLock lock(storage_lock_); 159 base::AutoLock lock(storage_lock_);
164 StorageMap::iterator it = storage_map_.find(id); 160 StorageMap::iterator it = storage_map_.find(id);
165 if (it == storage_map_.end()) 161 if (it == storage_map_.end())
166 return; 162 return;
167 info = it->second; 163 info = it->second;
168 storage_map_.erase(it); 164 storage_map_.erase(it);
169 } 165 }
170 166
171 DVLOG(1) << "StorageDetached for id " << id; 167 DVLOG(1) << "StorageDetached for id " << id;
172 if (StorageInfo::IsRemovableDevice(info.device_id())) { 168 if (StorageInfo::IsRemovableDevice(info.device_id())) {
173 observer_list_->Notify( 169 observer_list_->Notify(
174 &RemovableStorageObserver::OnRemovableStorageDetached, info); 170 &RemovableStorageObserver::OnRemovableStorageDetached, info);
175 } 171 }
176 } 172 }
177 173
178 } // namespace chrome 174 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/storage_monitor/storage_info.cc ('k') | chrome/browser/storage_monitor/storage_monitor_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698