diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-18 20:36:40 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-18 20:36:40 +0000 |
commit | bd9cc50d9f76a210c1dcff873af9b61fcc60c884 (patch) | |
tree | e9ec024f0560413a349338647ba0fc1d0702dc8c /device | |
parent | cb22f2e43373d00d40754d5a67bf2620abb8ff4c (diff) | |
download | chromium_src-bd9cc50d9f76a210c1dcff873af9b61fcc60c884.zip chromium_src-bd9cc50d9f76a210c1dcff873af9b61fcc60c884.tar.gz chromium_src-bd9cc50d9f76a210c1dcff873af9b61fcc60c884.tar.bz2 |
Storage Monitor: Make StorageMonitorLinux own the MediaTransferProtocolManager.
Review URL: https://chromiumcodereview.appspot.com/14016002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@194994 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'device')
-rw-r--r-- | device/media_transfer_protocol/media_transfer_protocol_manager.cc | 28 | ||||
-rw-r--r-- | device/media_transfer_protocol/media_transfer_protocol_manager.h | 12 |
2 files changed, 10 insertions, 30 deletions
diff --git a/device/media_transfer_protocol/media_transfer_protocol_manager.cc b/device/media_transfer_protocol/media_transfer_protocol_manager.cc index d3fce03..37cc5ed 100644 --- a/device/media_transfer_protocol/media_transfer_protocol_manager.cc +++ b/device/media_transfer_protocol/media_transfer_protocol_manager.cc @@ -35,7 +35,7 @@ MediaTransferProtocolManager* g_media_transfer_protocol_manager = NULL; // The MediaTransferProtocolManager implementation. class MediaTransferProtocolManagerImpl : public MediaTransferProtocolManager { public: - MediaTransferProtocolManagerImpl( + explicit MediaTransferProtocolManagerImpl( scoped_refptr<base::MessageLoopProxy> loop_proxy) : weak_ptr_factory_(this) { dbus::Bus* bus = NULL; @@ -71,6 +71,9 @@ class MediaTransferProtocolManagerImpl : public MediaTransferProtocolManager { } virtual ~MediaTransferProtocolManagerImpl() { + DCHECK(g_media_transfer_protocol_manager); + g_media_transfer_protocol_manager = NULL; + VLOG(1) << "MediaTransferProtocolManager Shutdown completed"; } // MediaTransferProtocolManager override. @@ -434,31 +437,14 @@ class MediaTransferProtocolManagerImpl : public MediaTransferProtocolManager { } // namespace // static -void MediaTransferProtocolManager::Initialize( +MediaTransferProtocolManager* MediaTransferProtocolManager::Initialize( scoped_refptr<base::MessageLoopProxy> loop_proxy) { - if (g_media_transfer_protocol_manager) { - LOG(WARNING) << "MediaTransferProtocolManager was already initialized"; - return; - } + DCHECK(!g_media_transfer_protocol_manager); + g_media_transfer_protocol_manager = new MediaTransferProtocolManagerImpl(loop_proxy); VLOG(1) << "MediaTransferProtocolManager initialized"; -} - -// static -void MediaTransferProtocolManager::Shutdown() { - if (!g_media_transfer_protocol_manager) { - LOG(WARNING) << "MediaTransferProtocolManager::Shutdown() called with " - << "NULL manager"; - return; - } - delete g_media_transfer_protocol_manager; - g_media_transfer_protocol_manager = NULL; - VLOG(1) << "MediaTransferProtocolManager Shutdown completed"; -} -// static -MediaTransferProtocolManager* MediaTransferProtocolManager::GetInstance() { return g_media_transfer_protocol_manager; } diff --git a/device/media_transfer_protocol/media_transfer_protocol_manager.h b/device/media_transfer_protocol/media_transfer_protocol_manager.h index 8751325..4b14e87 100644 --- a/device/media_transfer_protocol/media_transfer_protocol_manager.h +++ b/device/media_transfer_protocol/media_transfer_protocol_manager.h @@ -132,19 +132,13 @@ class MediaTransferProtocolManager { uint32 file_id, const GetFileInfoCallback& callback) = 0; - // Creates the global MediaTransferProtocolManager instance. + // Creates and returns the global MediaTransferProtocolManager instance. // On Linux, |loop_proxy| specifies the message loop proxy to process // asynchronous operations. // On ChromeOS, |loop_proxy| is set to NULL because ChromeOS already has a // dedicated message loop proxy. - static void Initialize(scoped_refptr<base::MessageLoopProxy> loop_proxy); - - // Destroys the global MediaTransferProtocolManager instance if it exists. - static void Shutdown(); - - // Returns a pointer to the global MediaTransferProtocolManager instance. - // Initialize() should already have been called. - static MediaTransferProtocolManager* GetInstance(); + static MediaTransferProtocolManager* Initialize( + scoped_refptr<base::MessageLoopProxy> loop_proxy); }; } // namespace device |