Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Unified Diff: chrome/browser/system_monitor/media_transfer_protocol_device_observer_linux.cc

Issue 12147002: Add a receiver interface to RemovableStorageNotifications. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Merging Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 d2d33ef5e81c6a619d0f382dd367c723dc88f651..490d9ed6ead2a4bf5be62dba3568082569795f50 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
@@ -136,7 +136,8 @@ MediaTransferProtocolDeviceObserverLinux()
MediaTransferProtocolDeviceObserverLinux::
MediaTransferProtocolDeviceObserverLinux(
GetStorageInfoFunc get_storage_info_func)
- : get_storage_info_func_(get_storage_info_func) {
+ : get_storage_info_func_(get_storage_info_func),
+ notifications_(NULL) {
// In unit tests, we don't have a media transfer protocol manager.
DCHECK(!device::MediaTransferProtocolManager::GetInstance());
DCHECK(!g_mtp_device_observer);
@@ -185,16 +186,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 +215,14 @@ void MediaTransferProtocolDeviceObserverLinux::StorageChanged(
RemovableStorageNotifications::StorageInfo storage_info(
device_id, device_name, location);
storage_map_[location] = storage_info;
- notifications->ProcessAttach(device_id, device_name, location);
+ notifications_->ProcessAttach(device_id, device_name, location);
} 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);
+ notifications_->ProcessDetach(it->second.device_id);
storage_map_.erase(it);
}
}

Powered by Google App Engine
This is Rietveld 408576698