| OLD | NEW |
| 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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 id " << info.device_id(); | 172 DVLOG(1) << "StorageAttached id " << info.device_id(); |
| 173 if (StorageInfo::IsRemovableDevice(info.device_id())) { | 173 if (StorageInfo::IsRemovableDevice(info.device_id())) { |
| 174 observer_list_->Notify( | 174 observer_list_->Notify( |
| 175 &RemovableStorageObserver::OnRemovableStorageAttached, info); | 175 FROM_HERE, &RemovableStorageObserver::OnRemovableStorageAttached, info); |
| 176 } | 176 } |
| 177 } | 177 } |
| 178 | 178 |
| 179 void StorageMonitor::ProcessDetach(const std::string& id) { | 179 void StorageMonitor::ProcessDetach(const std::string& id) { |
| 180 StorageInfo info; | 180 StorageInfo info; |
| 181 { | 181 { |
| 182 base::AutoLock lock(storage_lock_); | 182 base::AutoLock lock(storage_lock_); |
| 183 StorageMap::iterator it = storage_map_.find(id); | 183 StorageMap::iterator it = storage_map_.find(id); |
| 184 if (it == storage_map_.end()) | 184 if (it == storage_map_.end()) |
| 185 return; | 185 return; |
| 186 info = it->second; | 186 info = it->second; |
| 187 storage_map_.erase(it); | 187 storage_map_.erase(it); |
| 188 } | 188 } |
| 189 | 189 |
| 190 DVLOG(1) << "StorageDetached for id " << id; | 190 DVLOG(1) << "StorageDetached for id " << id; |
| 191 if (StorageInfo::IsRemovableDevice(info.device_id())) { | 191 if (StorageInfo::IsRemovableDevice(info.device_id())) { |
| 192 observer_list_->Notify( | 192 observer_list_->Notify( |
| 193 &RemovableStorageObserver::OnRemovableStorageDetached, info); | 193 FROM_HERE, &RemovableStorageObserver::OnRemovableStorageDetached, info); |
| 194 } | 194 } |
| 195 } | 195 } |
| 196 | 196 |
| 197 } // namespace storage_monitor | 197 } // namespace storage_monitor |
| OLD | NEW |