Commit b9a1cd10 authored by vandebo@chromium.org's avatar vandebo@chromium.org

Move TransientDeviceId from MediFileSystemRegistry to RemovableStorageNotifications.

BUG=NONE


Review URL: https://chromiumcodereview.appspot.com/12208079

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@182086 0039d316-1c4b-4281-b951-d872f2087c98
parent 945cdc83
...@@ -11,11 +11,9 @@ ...@@ -11,11 +11,9 @@
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/utf_string_conversions.h" #include "base/utf_string_conversions.h"
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/event_names.h" #include "chrome/browser/extensions/event_names.h"
#include "chrome/browser/extensions/event_router.h" #include "chrome/browser/extensions/event_router.h"
#include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/media_gallery/media_file_system_registry.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/system_monitor/removable_storage_notifications.h" #include "chrome/browser/system_monitor/removable_storage_notifications.h"
#include "chrome/common/extensions/api/media_galleries_private.h" #include "chrome/common/extensions/api/media_galleries_private.h"
...@@ -26,9 +24,10 @@ namespace extensions { ...@@ -26,9 +24,10 @@ namespace extensions {
namespace { namespace {
std::string GetTransientIdForDeviceId(const std::string& device_id) { std::string GetTransientIdForDeviceId(const std::string& device_id) {
chrome::MediaFileSystemRegistry* registry = chrome::RemovableStorageNotifications* storage_notifications =
g_browser_process->media_file_system_registry(); chrome::RemovableStorageNotifications::GetInstance();
return base::Uint64ToString(registry->GetTransientIdForDeviceId(device_id)); return base::Uint64ToString(
storage_notifications->GetTransientIdForDeviceId(device_id));
} }
} // namespace } // namespace
......
...@@ -402,9 +402,9 @@ class ExtensionGalleriesHost ...@@ -402,9 +402,9 @@ class ExtensionGalleriesHost
uint64 GetTransientIdForRemovableDeviceId(const std::string& device_id) { uint64 GetTransientIdForRemovableDeviceId(const std::string& device_id) {
if (!MediaStorageUtil::IsRemovableDevice(device_id)) if (!MediaStorageUtil::IsRemovableDevice(device_id))
return 0; return 0;
MediaFileSystemRegistry* registry = RemovableStorageNotifications* storage_notifications =
file_system_context_->GetMediaFileSystemRegistry(); RemovableStorageNotifications::GetInstance();
return registry->GetTransientIdForDeviceId(device_id); return storage_notifications->GetTransientIdForDeviceId(device_id);
} }
// This code is deprecated and should be removed. See http://crbug.com/170138 // This code is deprecated and should be removed. See http://crbug.com/170138
...@@ -629,11 +629,6 @@ size_t MediaFileSystemRegistry::GetExtensionHostCountForTests() const { ...@@ -629,11 +629,6 @@ size_t MediaFileSystemRegistry::GetExtensionHostCountForTests() const {
return extension_hosts_map_.size(); return extension_hosts_map_.size();
} }
uint64 MediaFileSystemRegistry::GetTransientIdForDeviceId(
const std::string& device_id) {
return transient_device_ids_.GetTransientIdForDeviceId(device_id);
}
/****************** /******************
* Private methods * Private methods
******************/ ******************/
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/prefs/public/pref_change_registrar.h" #include "base/prefs/public/pref_change_registrar.h"
#include "chrome/browser/media_gallery/media_galleries_preferences.h" #include "chrome/browser/media_gallery/media_galleries_preferences.h"
#include "chrome/browser/media_gallery/transient_device_ids.h"
#include "chrome/browser/system_monitor/removable_storage_observer.h" #include "chrome/browser/system_monitor/removable_storage_observer.h"
#include "webkit/fileapi/media/mtp_device_file_system_config.h" #include "webkit/fileapi/media/mtp_device_file_system_config.h"
...@@ -153,8 +152,6 @@ class MediaFileSystemRegistry : public RemovableStorageObserver { ...@@ -153,8 +152,6 @@ class MediaFileSystemRegistry : public RemovableStorageObserver {
scoped_ptr<MediaFileSystemContext> file_system_context_; scoped_ptr<MediaFileSystemContext> file_system_context_;
TransientDeviceIds transient_device_ids_;
DISALLOW_COPY_AND_ASSIGN(MediaFileSystemRegistry); DISALLOW_COPY_AND_ASSIGN(MediaFileSystemRegistry);
}; };
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/stl_util.h" #include "base/stl_util.h"
#include "base/utf_string_conversions.h" #include "base/utf_string_conversions.h"
#include "chrome/browser/system_monitor/removable_storage_observer.h" #include "chrome/browser/system_monitor/removable_storage_observer.h"
#include "chrome/browser/system_monitor/transient_device_ids.h"
namespace chrome { namespace chrome {
...@@ -59,9 +60,40 @@ void RemovableStorageNotifications::ReceiverImpl::ProcessDetach( ...@@ -59,9 +60,40 @@ void RemovableStorageNotifications::ReceiverImpl::ProcessDetach(
notifications_->ProcessDetach(id); notifications_->ProcessDetach(id);
} }
RemovableStorageNotifications* RemovableStorageNotifications::GetInstance() {
return g_removable_storage_notifications;
}
std::vector<RemovableStorageNotifications::StorageInfo>
RemovableStorageNotifications::GetAttachedStorage() const {
std::vector<StorageInfo> results;
base::AutoLock lock(storage_lock_);
for (RemovableStorageMap::const_iterator it = storage_map_.begin();
it != storage_map_.end();
++it) {
results.push_back(it->second);
}
return results;
}
void RemovableStorageNotifications::AddObserver(RemovableStorageObserver* obs) {
observer_list_->AddObserver(obs);
}
void RemovableStorageNotifications::RemoveObserver(
RemovableStorageObserver* obs) {
observer_list_->RemoveObserver(obs);
}
uint64 RemovableStorageNotifications::GetTransientIdForDeviceId(
const std::string& device_id) {
return transient_device_ids_->GetTransientIdForDeviceId(device_id);
}
RemovableStorageNotifications::RemovableStorageNotifications() RemovableStorageNotifications::RemovableStorageNotifications()
: observer_list_( : observer_list_(new ObserverListThreadSafe<RemovableStorageObserver>()),
new ObserverListThreadSafe<RemovableStorageObserver>()) { transient_device_ids_(new TransientDeviceIds) {
receiver_.reset(new ReceiverImpl(this)); receiver_.reset(new ReceiverImpl(this));
DCHECK(!g_removable_storage_notifications); DCHECK(!g_removable_storage_notifications);
...@@ -112,30 +144,4 @@ void RemovableStorageNotifications::ProcessDetach(const std::string& id) { ...@@ -112,30 +144,4 @@ void RemovableStorageNotifications::ProcessDetach(const std::string& id) {
&RemovableStorageObserver::OnRemovableStorageDetached, info); &RemovableStorageObserver::OnRemovableStorageDetached, info);
} }
std::vector<RemovableStorageNotifications::StorageInfo>
RemovableStorageNotifications::GetAttachedStorage() const {
std::vector<StorageInfo> results;
base::AutoLock lock(storage_lock_);
for (RemovableStorageMap::const_iterator it = storage_map_.begin();
it != storage_map_.end();
++it) {
results.push_back(it->second);
}
return results;
}
void RemovableStorageNotifications::AddObserver(RemovableStorageObserver* obs) {
observer_list_->AddObserver(obs);
}
void RemovableStorageNotifications::RemoveObserver(
RemovableStorageObserver* obs) {
observer_list_->RemoveObserver(obs);
}
RemovableStorageNotifications* RemovableStorageNotifications::GetInstance() {
return g_removable_storage_notifications;
}
} // namespace chrome } // namespace chrome
...@@ -18,6 +18,7 @@ namespace chrome { ...@@ -18,6 +18,7 @@ namespace chrome {
class MediaFileSystemRegistryTest; class MediaFileSystemRegistryTest;
class RemovableStorageObserver; class RemovableStorageObserver;
class TransientDeviceIds;
// Base class for platform-specific instances watching for removable storage // Base class for platform-specific instances watching for removable storage
// attachments/detachments. // attachments/detachments.
...@@ -83,6 +84,8 @@ class RemovableStorageNotifications { ...@@ -83,6 +84,8 @@ class RemovableStorageNotifications {
void AddObserver(RemovableStorageObserver* obs); void AddObserver(RemovableStorageObserver* obs);
void RemoveObserver(RemovableStorageObserver* obs); void RemoveObserver(RemovableStorageObserver* obs);
uint64 GetTransientIdForDeviceId(const std::string& device_id);
protected: protected:
RemovableStorageNotifications(); RemovableStorageNotifications();
virtual ~RemovableStorageNotifications(); virtual ~RemovableStorageNotifications();
...@@ -114,6 +117,8 @@ class RemovableStorageNotifications { ...@@ -114,6 +117,8 @@ class RemovableStorageNotifications {
// Map of all the attached removable storage devices. // Map of all the attached removable storage devices.
RemovableStorageMap storage_map_; RemovableStorageMap storage_map_;
scoped_ptr<TransientDeviceIds> transient_device_ids_;
}; };
} // namespace chrome } // namespace chrome
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// TransientDeviceIds implementation. // TransientDeviceIds implementation.
#include "chrome/browser/media_gallery/transient_device_ids.h" #include "chrome/browser/system_monitor/transient_device_ids.h"
#include "base/logging.h" #include "base/logging.h"
#include "chrome/browser/system_monitor/media_storage_util.h" #include "chrome/browser/system_monitor/media_storage_util.h"
......
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
// gets mapped to a transient ID, the mapping remains valid for the duration of // gets mapped to a transient ID, the mapping remains valid for the duration of
// TransientDeviceIds' lifetime. // TransientDeviceIds' lifetime.
#ifndef CHROME_BROWSER_MEDIA_GALLERY_TRANSIENT_DEVICE_IDS_H_ #ifndef CHROME_BROWSER_SYSTEM_MONITOR_TRANSIENT_DEVICE_IDS_H_
#define CHROME_BROWSER_MEDIA_GALLERY_TRANSIENT_DEVICE_IDS_H_ #define CHROME_BROWSER_SYSTEM_MONITOR_TRANSIENT_DEVICE_IDS_H_
#include <map> #include <map>
#include <string> #include <string>
...@@ -42,4 +42,4 @@ class TransientDeviceIds { ...@@ -42,4 +42,4 @@ class TransientDeviceIds {
} // namespace chrome } // namespace chrome
#endif // CHROME_BROWSER_MEDIA_GALLERY_TRANSIENT_DEVICE_IDS_H_ #endif // CHROME_BROWSER_SYSTEM_MONITOR_TRANSIENT_DEVICE_IDS_H_
...@@ -1052,8 +1052,6 @@ ...@@ -1052,8 +1052,6 @@
'browser/media_gallery/mtp_device_delegate_impl.h', 'browser/media_gallery/mtp_device_delegate_impl.h',
'browser/media_gallery/scoped_mtp_device_map_entry.cc', 'browser/media_gallery/scoped_mtp_device_map_entry.cc',
'browser/media_gallery/scoped_mtp_device_map_entry.h', 'browser/media_gallery/scoped_mtp_device_map_entry.h',
'browser/media_gallery/transient_device_ids.cc',
'browser/media_gallery/transient_device_ids.h',
'browser/media_gallery/win/mtp_device_delegate_impl_win.cc', 'browser/media_gallery/win/mtp_device_delegate_impl_win.cc',
'browser/media_gallery/win/mtp_device_delegate_impl_win.h', 'browser/media_gallery/win/mtp_device_delegate_impl_win.h',
'browser/media_gallery/win/mtp_device_object_entry.cc', 'browser/media_gallery/win/mtp_device_object_entry.cc',
...@@ -2077,6 +2075,8 @@ ...@@ -2077,6 +2075,8 @@
'browser/system_monitor/removable_storage_notifications.cc', 'browser/system_monitor/removable_storage_notifications.cc',
'browser/system_monitor/removable_storage_notifications.h', 'browser/system_monitor/removable_storage_notifications.h',
'browser/system_monitor/removable_storage_observer.h', 'browser/system_monitor/removable_storage_observer.h',
'browser/system_monitor/transient_device_ids.cc',
'browser/system_monitor/transient_device_ids.h',
'browser/system_monitor/udev_util_linux.cc', 'browser/system_monitor/udev_util_linux.cc',
'browser/system_monitor/udev_util_linux.h', 'browser/system_monitor/udev_util_linux.h',
'browser/system_monitor/volume_mount_watcher_win.cc', 'browser/system_monitor/volume_mount_watcher_win.cc',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment