Chromium Code Reviews| Index: chrome/browser/system_monitor/media_transfer_protocol_device_observer_linux.cc |
| diff --git a/chrome/browser/system_monitor/media_transfer_protocol_device_observer_linux.cc b/chrome/browser/system_monitor/media_transfer_protocol_device_observer_linux.cc |
| index 8b34e3908f1d634f52e712c558a2d0d57edeaa4b..3e7f062907ef9beb13fcda0e21af4a0e59d172ea 100644 |
| --- a/chrome/browser/system_monitor/media_transfer_protocol_device_observer_linux.cc |
| +++ b/chrome/browser/system_monitor/media_transfer_protocol_device_observer_linux.cc |
| @@ -185,16 +185,17 @@ bool MediaTransferProtocolDeviceObserverLinux::GetStorageInfoForPath( |
| return true; |
| } |
| +void MediaTransferProtocolDeviceObserverLinux::SetNotifications( |
| + RemovableStorageNotifications::Receiver* notifications) { |
| + notifications_ = notifications; |
| +} |
| + |
| // device::MediaTransferProtocolManager::Observer override. |
| void MediaTransferProtocolDeviceObserverLinux::StorageChanged( |
| bool is_attached, |
| const std::string& storage_name) { |
| DCHECK(!storage_name.empty()); |
| - RemovableStorageNotifications* notifications = |
| - RemovableStorageNotifications::GetInstance(); |
| - DCHECK(notifications); |
| - |
| // New storage is attached. |
| if (is_attached) { |
| std::string device_id; |
| @@ -213,14 +214,16 @@ void MediaTransferProtocolDeviceObserverLinux::StorageChanged( |
| RemovableStorageNotifications::StorageInfo storage_info( |
| device_id, device_name, location); |
| storage_map_[location] = storage_info; |
| - notifications->ProcessAttach(device_id, device_name, location); |
| + if (notifications_) |
|
vandebo (ex-Chrome)
2013/01/31 23:51:29
Why the condition? Should always be true, right?
Greg Billock
2013/02/01 18:28:42
Yes. This is defensive and mostly done for uniform
vandebo (ex-Chrome)
2013/02/01 18:59:55
If everything works without it, then lets go that
Greg Billock
2013/02/01 23:05:42
Done.
|
| + notifications_->ProcessAttach(storage_info); |
| } else { |
| // Existing storage is detached. |
| StorageLocationToInfoMap::iterator it = |
| storage_map_.find(GetDeviceLocationFromStorageName(storage_name)); |
| if (it == storage_map_.end()) |
| return; |
| - notifications->ProcessDetach(it->second.device_id); |
| + if (notifications_) |
| + notifications_->ProcessDetach(it->second.device_id); |
| storage_map_.erase(it); |
| } |
| } |