| Index: base/system_monitor/system_monitor.cc
|
| diff --git a/base/system_monitor/system_monitor.cc b/base/system_monitor/system_monitor.cc
|
| index f30c8935c9a999b38382f78e879c9319a4eba13f..0aa823b9433406f86e487b467126a0df3154e9d6 100644
|
| --- a/base/system_monitor/system_monitor.cc
|
| +++ b/base/system_monitor/system_monitor.cc
|
| @@ -103,27 +103,35 @@ void SystemMonitor::ProcessRemovableStorageAttached(
|
| const std::string& id,
|
| const string16& name,
|
| const FilePath::StringType& location) {
|
| - if (ContainsKey(removable_storage_map_, id)) {
|
| - // This can happen if our unique id scheme fails. Ignore the incoming
|
| - // non-unique attachment.
|
| - return;
|
| + {
|
| + base::AutoLock lock(removable_storage_lock_);
|
| + if (ContainsKey(removable_storage_map_, id)) {
|
| + // This can happen if our unique id scheme fails. Ignore the incoming
|
| + // non-unique attachment.
|
| + return;
|
| + }
|
| + RemovableStorageInfo info(id, name, location);
|
| + removable_storage_map_.insert(std::make_pair(id, info));
|
| }
|
| - RemovableStorageInfo info(id, name, location);
|
| - removable_storage_map_.insert(std::make_pair(id, info));
|
| NotifyRemovableStorageAttached(id, name, location);
|
| }
|
|
|
| void SystemMonitor::ProcessRemovableStorageDetached(const std::string& id) {
|
| - RemovableStorageMap::iterator it = removable_storage_map_.find(id);
|
| - if (it == removable_storage_map_.end())
|
| - return;
|
| - removable_storage_map_.erase(it);
|
| + {
|
| + base::AutoLock lock(removable_storage_lock_);
|
| + RemovableStorageMap::iterator it = removable_storage_map_.find(id);
|
| + if (it == removable_storage_map_.end())
|
| + return;
|
| + removable_storage_map_.erase(it);
|
| + }
|
| NotifyRemovableStorageDetached(id);
|
| }
|
|
|
| std::vector<SystemMonitor::RemovableStorageInfo>
|
| -SystemMonitor::GetAttachedRemovableStorage() const {
|
| +SystemMonitor::GetAttachedRemovableStorage() {
|
| std::vector<RemovableStorageInfo> results;
|
| +
|
| + base::AutoLock lock(removable_storage_lock_);
|
| for (RemovableStorageMap::const_iterator it = removable_storage_map_.begin();
|
| it != removable_storage_map_.end();
|
| ++it) {
|
|
|