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

Side by Side Diff: components/storage_monitor/storage_monitor.cc

Issue 120303003: [StorageMonitor] Move gallery name generation to StorageInfo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix unittest build error on mac/linux/chromeos 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/storage_monitor/storage_monitor.h" 5 #include "components/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 "components/storage_monitor/removable_storage_observer.h" 9 #include "components/storage_monitor/removable_storage_observer.h"
10 #include "components/storage_monitor/transient_device_ids.h" 10 #include "components/storage_monitor/transient_device_ids.h"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 { 162 {
163 base::AutoLock lock(storage_lock_); 163 base::AutoLock lock(storage_lock_);
164 if (ContainsKey(storage_map_, info.device_id())) { 164 if (ContainsKey(storage_map_, info.device_id())) {
165 // This can happen if our unique id scheme fails. Ignore the incoming 165 // This can happen if our unique id scheme fails. Ignore the incoming
166 // non-unique attachment. 166 // non-unique attachment.
167 return; 167 return;
168 } 168 }
169 storage_map_.insert(std::make_pair(info.device_id(), info)); 169 storage_map_.insert(std::make_pair(info.device_id(), info));
170 } 170 }
171 171
172 DVLOG(1) << "StorageAttached with name " << base::UTF16ToUTF8(info.name()) 172 DVLOG(1) << "StorageAttached id " << info.device_id();
173 << " and id " << info.device_id();
174 if (StorageInfo::IsRemovableDevice(info.device_id())) { 173 if (StorageInfo::IsRemovableDevice(info.device_id())) {
175 observer_list_->Notify( 174 observer_list_->Notify(
176 &RemovableStorageObserver::OnRemovableStorageAttached, info); 175 &RemovableStorageObserver::OnRemovableStorageAttached, info);
177 } 176 }
178 } 177 }
179 178
180 void StorageMonitor::ProcessDetach(const std::string& id) { 179 void StorageMonitor::ProcessDetach(const std::string& id) {
181 StorageInfo info; 180 StorageInfo info;
182 { 181 {
183 base::AutoLock lock(storage_lock_); 182 base::AutoLock lock(storage_lock_);
184 StorageMap::iterator it = storage_map_.find(id); 183 StorageMap::iterator it = storage_map_.find(id);
185 if (it == storage_map_.end()) 184 if (it == storage_map_.end())
186 return; 185 return;
187 info = it->second; 186 info = it->second;
188 storage_map_.erase(it); 187 storage_map_.erase(it);
189 } 188 }
190 189
191 DVLOG(1) << "StorageDetached for id " << id; 190 DVLOG(1) << "StorageDetached for id " << id;
192 if (StorageInfo::IsRemovableDevice(info.device_id())) { 191 if (StorageInfo::IsRemovableDevice(info.device_id())) {
193 observer_list_->Notify( 192 observer_list_->Notify(
194 &RemovableStorageObserver::OnRemovableStorageDetached, info); 193 &RemovableStorageObserver::OnRemovableStorageDetached, info);
195 } 194 }
196 } 195 }
197 196
198 } // namespace storage_monitor 197 } // namespace storage_monitor
OLDNEW
« no previous file with comments | « components/storage_monitor/storage_info.cc ('k') | components/storage_monitor/storage_monitor_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698