diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-21 01:52:26 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-21 01:52:26 +0000 |
commit | 614a5ff88562dfa394cab497ddc9ca5e1af25ad7 (patch) | |
tree | 4b1084d0843274e100e080fbfe20df83df5d6ba4 /base/system_monitor/system_monitor.h | |
parent | 341370e404477a709a59673728c8666796597dff (diff) | |
download | chromium_src-614a5ff88562dfa394cab497ddc9ca5e1af25ad7.zip chromium_src-614a5ff88562dfa394cab497ddc9ca5e1af25ad7.tar.gz chromium_src-614a5ff88562dfa394cab497ddc9ca5e1af25ad7.tar.bz2 |
Change base::SystemMonitor's media device functions to take a type and FilePath::StringType instead of a FilePath.
BUG=none
TEST=none
Review URL: https://chromiumcodereview.appspot.com/10780023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@147758 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/system_monitor/system_monitor.h')
-rw-r--r-- | base/system_monitor/system_monitor.h | 79 |
1 files changed, 54 insertions, 25 deletions
diff --git a/base/system_monitor/system_monitor.h b/base/system_monitor/system_monitor.h index a6065d9..359feb6 100644 --- a/base/system_monitor/system_monitor.h +++ b/base/system_monitor/system_monitor.h @@ -5,12 +5,14 @@ #ifndef BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_ #define BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_ +#include <map> #include <string> #include <vector> #include "base/base_export.h" #include "base/basictypes.h" -#include "base/tuple.h" +#include "base/file_path.h" +#include "base/string16.h" #include "build/build_config.h" // Windows HiRes timers drain the battery faster so we need to know the battery @@ -35,8 +37,6 @@ #include <objc/runtime.h> #endif // OS_IOS -class FilePath; - namespace base { // Class for monitoring various system-related subsystems @@ -51,9 +51,35 @@ class BASE_EXPORT SystemMonitor { RESUME_EVENT // The system is being resumed. }; - typedef unsigned int DeviceIdType; - // (Media device id, Media device name, Media device path) - typedef Tuple3<DeviceIdType, std::string, FilePath> MediaDeviceInfo; + // Type of location data to identify a currently attached media device. + enum MediaDeviceType { + TYPE_PATH, // FilePath::StringType, e.g. a mount point. + TYPE_MTP, // (W)string to locate a MTP device, e.g. its usb bus/port. + }; + + struct MediaDeviceInfo { + MediaDeviceInfo(const std::string& id, + const string16& device_name, + MediaDeviceType device_type, + const FilePath::StringType& device_location) + : unique_id(id), + name(device_name), + type(device_type), + location(device_location) { + } + + // Unique media device id - persists between device attachments. + std::string unique_id; + + // Human readable media device name. + string16 name; + + // Media device type. + MediaDeviceType type; + + // Current attached media device location. + FilePath::StringType location; + }; // Create SystemMonitor. Only one SystemMonitor instance per application // is allowed. @@ -75,6 +101,9 @@ class BASE_EXPORT SystemMonitor { #endif // OS_IOS #endif // OS_MACOSX + // Returns information for attached media devices. + std::vector<MediaDeviceInfo> GetAttachedMediaDevices() const; + // // Power-related APIs // @@ -115,13 +144,12 @@ class BASE_EXPORT SystemMonitor { // When a media device is attached or detached, one of these two events // is triggered. - // TODO(vandebo) Pass an appropriate device identifier or way to interact - // with the devices instead of FilePath. - virtual void OnMediaDeviceAttached(const DeviceIdType& id, - const std::string& name, - const FilePath& path) {} + virtual void OnMediaDeviceAttached(const std::string& id, + const string16& name, + MediaDeviceType type, + const FilePath::StringType& location) {} - virtual void OnMediaDeviceDetached(const DeviceIdType& id) {} + virtual void OnMediaDeviceDetached(const std::string& id) {} protected: virtual ~DevicesChangedObserver() {} @@ -151,17 +179,16 @@ class BASE_EXPORT SystemMonitor { // Cross-platform handling of a device change event. void ProcessDevicesChanged(); - void ProcessMediaDeviceAttached(const DeviceIdType& id, - const std::string& name, - const FilePath& path); - void ProcessMediaDeviceDetached(const DeviceIdType& id); - - // Returns information for attached media devices. - std::vector<MediaDeviceInfo> GetAttachedMediaDevices() const; + void ProcessMediaDeviceAttached(const std::string& id, + const string16& name, + MediaDeviceType type, + const FilePath::StringType& location); + void ProcessMediaDeviceDetached(const std::string& id); private: - typedef std::map<base::SystemMonitor::DeviceIdType, - MediaDeviceInfo> MediaDeviceMap; + // Mapping of unique device id to device info tuple. + typedef std::map<std::string, MediaDeviceInfo> MediaDeviceMap; + #if defined(OS_MACOSX) void PlatformInit(); void PlatformDestroy(); @@ -178,10 +205,11 @@ class BASE_EXPORT SystemMonitor { // Functions to trigger notifications. void NotifyDevicesChanged(); - void NotifyMediaDeviceAttached(const DeviceIdType& id, - const std::string& name, - const FilePath& path); - void NotifyMediaDeviceDetached(const DeviceIdType& id); + void NotifyMediaDeviceAttached(const std::string& id, + const string16& name, + MediaDeviceType type, + const FilePath::StringType& data); + void NotifyMediaDeviceDetached(const std::string& id); void NotifyPowerStateChange(); void NotifySuspend(); void NotifyResume(); @@ -201,6 +229,7 @@ class BASE_EXPORT SystemMonitor { std::vector<id> notification_observers_; #endif + // Map of all the attached media devices. MediaDeviceMap media_device_map_; DISALLOW_COPY_AND_ASSIGN(SystemMonitor); |