| OLD | NEW |
| 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 { | 140 { |
| 141 base::AutoLock lock(storage_lock_); | 141 base::AutoLock lock(storage_lock_); |
| 142 if (ContainsKey(storage_map_, info.device_id())) { | 142 if (ContainsKey(storage_map_, info.device_id())) { |
| 143 // This can happen if our unique id scheme fails. Ignore the incoming | 143 // This can happen if our unique id scheme fails. Ignore the incoming |
| 144 // non-unique attachment. | 144 // non-unique attachment. |
| 145 return; | 145 return; |
| 146 } | 146 } |
| 147 storage_map_.insert(std::make_pair(info.device_id(), info)); | 147 storage_map_.insert(std::make_pair(info.device_id(), info)); |
| 148 } | 148 } |
| 149 | 149 |
| 150 DVLOG(1) << "StorageAttached with name " << UTF16ToUTF8(info.name()) | 150 DVLOG(1) << "StorageAttached with name " << base::UTF16ToUTF8(info.name()) |
| 151 << " and id " << info.device_id(); | 151 << " and id " << info.device_id(); |
| 152 if (StorageInfo::IsRemovableDevice(info.device_id())) { | 152 if (StorageInfo::IsRemovableDevice(info.device_id())) { |
| 153 observer_list_->Notify( | 153 observer_list_->Notify( |
| 154 &RemovableStorageObserver::OnRemovableStorageAttached, info); | 154 &RemovableStorageObserver::OnRemovableStorageAttached, info); |
| 155 } | 155 } |
| 156 } | 156 } |
| 157 | 157 |
| 158 void StorageMonitor::ProcessDetach(const std::string& id) { | 158 void StorageMonitor::ProcessDetach(const std::string& id) { |
| 159 StorageInfo info; | 159 StorageInfo info; |
| 160 { | 160 { |
| 161 base::AutoLock lock(storage_lock_); | 161 base::AutoLock lock(storage_lock_); |
| 162 StorageMap::iterator it = storage_map_.find(id); | 162 StorageMap::iterator it = storage_map_.find(id); |
| 163 if (it == storage_map_.end()) | 163 if (it == storage_map_.end()) |
| 164 return; | 164 return; |
| 165 info = it->second; | 165 info = it->second; |
| 166 storage_map_.erase(it); | 166 storage_map_.erase(it); |
| 167 } | 167 } |
| 168 | 168 |
| 169 DVLOG(1) << "StorageDetached for id " << id; | 169 DVLOG(1) << "StorageDetached for id " << id; |
| 170 if (StorageInfo::IsRemovableDevice(info.device_id())) { | 170 if (StorageInfo::IsRemovableDevice(info.device_id())) { |
| 171 observer_list_->Notify( | 171 observer_list_->Notify( |
| 172 &RemovableStorageObserver::OnRemovableStorageDetached, info); | 172 &RemovableStorageObserver::OnRemovableStorageDetached, info); |
| 173 } | 173 } |
| 174 } | 174 } |
| OLD | NEW |