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/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/storage_monitor/removable_storage_observer.h" | 9 #include "chrome/browser/storage_monitor/removable_storage_observer.h" |
10 #include "chrome/browser/storage_monitor/transient_device_ids.h" | 10 #include "chrome/browser/storage_monitor/transient_device_ids.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 on_initialize_callbacks_.begin(); | 135 on_initialize_callbacks_.begin(); |
136 iter != on_initialize_callbacks_.end(); ++iter) { | 136 iter != on_initialize_callbacks_.end(); ++iter) { |
137 iter->Run(); | 137 iter->Run(); |
138 } | 138 } |
139 on_initialize_callbacks_.clear(); | 139 on_initialize_callbacks_.clear(); |
140 } | 140 } |
141 | 141 |
142 void StorageMonitor::ProcessAttach(const StorageInfo& info) { | 142 void StorageMonitor::ProcessAttach(const StorageInfo& info) { |
143 { | 143 { |
144 base::AutoLock lock(storage_lock_); | 144 base::AutoLock lock(storage_lock_); |
145 if (ContainsKey(storage_map_, info.device_id)) { | 145 if (ContainsKey(storage_map_, info.device_id())) { |
146 // This can happen if our unique id scheme fails. Ignore the incoming | 146 // This can happen if our unique id scheme fails. Ignore the incoming |
147 // non-unique attachment. | 147 // non-unique attachment. |
148 return; | 148 return; |
149 } | 149 } |
150 storage_map_.insert(std::make_pair(info.device_id, info)); | 150 storage_map_.insert(std::make_pair(info.device_id(), info)); |
151 } | 151 } |
152 | 152 |
153 DVLOG(1) << "RemovableStorageAttached with name " << UTF16ToUTF8(info.name) | 153 DVLOG(1) << "RemovableStorageAttached with name " << UTF16ToUTF8(info.name()) |
154 << " and id " << info.device_id; | 154 << " and id " << info.device_id(); |
155 observer_list_->Notify( | 155 observer_list_->Notify( |
156 &RemovableStorageObserver::OnRemovableStorageAttached, info); | 156 &RemovableStorageObserver::OnRemovableStorageAttached, info); |
157 } | 157 } |
158 | 158 |
159 void StorageMonitor::ProcessDetach(const std::string& id) { | 159 void StorageMonitor::ProcessDetach(const std::string& id) { |
160 StorageInfo info; | 160 StorageInfo info; |
161 { | 161 { |
162 base::AutoLock lock(storage_lock_); | 162 base::AutoLock lock(storage_lock_); |
163 RemovableStorageMap::iterator it = storage_map_.find(id); | 163 RemovableStorageMap::iterator it = storage_map_.find(id); |
164 if (it == storage_map_.end()) | 164 if (it == storage_map_.end()) |
165 return; | 165 return; |
166 info = it->second; | 166 info = it->second; |
167 storage_map_.erase(it); | 167 storage_map_.erase(it); |
168 } | 168 } |
169 | 169 |
170 DVLOG(1) << "RemovableStorageDetached for id " << id; | 170 DVLOG(1) << "RemovableStorageDetached for id " << id; |
171 observer_list_->Notify( | 171 observer_list_->Notify( |
172 &RemovableStorageObserver::OnRemovableStorageDetached, info); | 172 &RemovableStorageObserver::OnRemovableStorageDetached, info); |
173 } | 173 } |
174 | 174 |
175 } // namespace chrome | 175 } // namespace chrome |
OLD | NEW |