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

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

Issue 14016002: Storage Monitor: Make StorageMonitorLinux own the MediaTransferProtocolManager. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix browser_tests Created 7 years, 8 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/storage_monitor/media_transfer_protocol_device_observer_linux.cc
===================================================================
--- chrome/browser/storage_monitor/media_transfer_protocol_device_observer_linux.cc (revision 194743)
+++ chrome/browser/storage_monitor/media_transfer_protocol_device_observer_linux.cc (working copy)
@@ -24,6 +24,13 @@
// Device root path constant.
const char kRootPath[] = "/";
+device::MediaTransferProtocolManager* GetMediaTransferProtocolManager() {
+ StorageMonitor* monitor = StorageMonitor::GetInstance();
+ if (!monitor)
+ return NULL;
+ return monitor->media_transfer_protocol_manager();
+}
+
// Constructs and returns the location of the device using the |storage_name|.
std::string GetDeviceLocationFromStorageName(const std::string& storage_name) {
// Construct a dummy device path using the storage name. This is only used
@@ -101,10 +108,8 @@
string16* label,
std::string* location) {
DCHECK(!storage_name.empty());
- device::MediaTransferProtocolManager* mtp_manager =
- device::MediaTransferProtocolManager::GetInstance();
const MtpStorageInfo* storage_info =
- mtp_manager->GetStorageInfo(storage_name);
+ GetMediaTransferProtocolManager()->GetStorageInfo(storage_name);
if (!storage_info)
return;
@@ -128,10 +133,7 @@
DCHECK(!g_mtp_device_observer);
g_mtp_device_observer = this;
- device::MediaTransferProtocolManager* mtp_manager =
- device::MediaTransferProtocolManager::GetInstance();
- DCHECK(mtp_manager);
- mtp_manager->AddObserver(this);
+ GetMediaTransferProtocolManager()->AddObserver(this);
EnumerateStorages();
}
@@ -152,7 +154,7 @@
g_mtp_device_observer = NULL;
device::MediaTransferProtocolManager* mtp_manager =
- device::MediaTransferProtocolManager::GetInstance();
+ GetMediaTransferProtocolManager();
if (mtp_manager)
mtp_manager->RemoveObserver(this);
}
@@ -219,9 +221,7 @@
void MediaTransferProtocolDeviceObserverLinux::EnumerateStorages() {
typedef std::vector<std::string> StorageList;
- device::MediaTransferProtocolManager* mtp_manager =
- device::MediaTransferProtocolManager::GetInstance();
- StorageList storages = mtp_manager->GetStorages();
+ StorageList storages = GetMediaTransferProtocolManager()->GetStorages();
for (StorageList::const_iterator storage_iter = storages.begin();
storage_iter != storages.end(); ++storage_iter) {
StorageChanged(true, *storage_iter);
« no previous file with comments | « chrome/browser/media_galleries/linux/mtp_read_file_worker.cc ('k') | chrome/browser/storage_monitor/storage_monitor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698