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

Side by Side Diff: chrome/browser/system_monitor/removable_storage_notifications.h

Issue 11573048: [Media Galleries] Move RemovableStorageInfo notifications to chrome namespace (part 2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Typedef, init observer Created 7 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_STORAGE_NOTIFICATIONS_H_ 5 #ifndef CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_STORAGE_NOTIFICATIONS_H_
6 #define CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_STORAGE_NOTIFICATIONS_H_ 6 #define CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_STORAGE_NOTIFICATIONS_H_
7 7
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/observer_list_threadsafe.h" 9 #include "base/observer_list_threadsafe.h"
10 #include "base/string16.h" 10 #include "base/string16.h"
11 #include "base/synchronization/lock.h" 11 #include "base/synchronization/lock.h"
12 #include "base/system_monitor/system_monitor.h" 12
13 class MediaGalleriesPrivateApiTest;
13 14
14 namespace chrome { 15 namespace chrome {
15 16
16 class RemovableStorageObserver; 17 class RemovableStorageObserver;
17 18
18 // Base class for platform-specific instances watching for removable storage 19 // Base class for platform-specific instances watching for removable storage
19 // attachments/detachments. 20 // attachments/detachments.
20 class RemovableStorageNotifications { 21 class RemovableStorageNotifications {
21 public: 22 public:
22 struct StorageInfo { 23 struct StorageInfo {
(...skipping 14 matching lines...) Expand all
37 38
38 virtual ~RemovableStorageNotifications(); 39 virtual ~RemovableStorageNotifications();
39 40
40 // Returns a pointer to an object owned by the BrowserMainParts, with lifetime 41 // Returns a pointer to an object owned by the BrowserMainParts, with lifetime
41 // somewhat shorter than a process Singleton. 42 // somewhat shorter than a process Singleton.
42 static RemovableStorageNotifications* GetInstance(); 43 static RemovableStorageNotifications* GetInstance();
43 44
44 // Finds the device that contains |path| and populates |device_info|. 45 // Finds the device that contains |path| and populates |device_info|.
45 // Should be able to handle any path on the local system, not just removable 46 // Should be able to handle any path on the local system, not just removable
46 // storage. Returns false if unable to find the device. 47 // storage. Returns false if unable to find the device.
47 // TODO(gbillock): Change this method signature to use StorageInfo.
48 virtual bool GetDeviceInfoForPath( 48 virtual bool GetDeviceInfoForPath(
49 const FilePath& path, 49 const FilePath& path,
50 base::SystemMonitor::RemovableStorageInfo* device_info) const = 0; 50 StorageInfo* device_info) const = 0;
51 51
52 // Returns the storage size of the device present at |location|. If the 52 // Returns the storage size of the device present at |location|. If the
53 // device information is unavailable, returns zero. 53 // device information is unavailable, returns zero.
54 virtual uint64 GetStorageSize(const std::string& location) const = 0; 54 virtual uint64 GetStorageSize(const std::string& location) const = 0;
55 55
56 #if defined(OS_WIN) 56 #if defined(OS_WIN)
57 // Gets the MTP device storage information specified by |storage_device_id|. 57 // Gets the MTP device storage information specified by |storage_device_id|.
58 // On success, returns true and fills in |device_location| with device 58 // On success, returns true and fills in |device_location| with device
59 // interface details and |storage_object_id| with the string ID that 59 // interface details and |storage_object_id| with the string ID that
60 // uniquely identifies the object on the device. This ID need not be 60 // uniquely identifies the object on the device. This ID need not be
61 // persistent across sessions. 61 // persistent across sessions.
62 virtual bool GetMTPStorageInfoFromDeviceId( 62 virtual bool GetMTPStorageInfoFromDeviceId(
63 const std::string& storage_device_id, 63 const std::string& storage_device_id,
64 string16* device_location, 64 string16* device_location,
65 string16* storage_object_id) const = 0; 65 string16* storage_object_id) const = 0;
66 #endif 66 #endif
67 67
68 // Returns information for attached removable storage. 68 // Returns information for attached removable storage.
69 std::vector<StorageInfo> GetAttachedStorage() const; 69 std::vector<StorageInfo> GetAttachedStorage() const;
70 70
71 void AddObserver(RemovableStorageObserver* obs); 71 void AddObserver(RemovableStorageObserver* obs);
72 void RemoveObserver(RemovableStorageObserver* obs); 72 void RemoveObserver(RemovableStorageObserver* obs);
73 73
74 protected: 74 protected:
75 RemovableStorageNotifications(); 75 RemovableStorageNotifications();
76 76
77 friend class MediaFileSystemRegistryTest;
78 friend class ::MediaGalleriesPrivateApiTest;
79 friend class MediaStorageUtilTest;
80 // TODO(gbillock): remove these friends by making the classes owned by the
81 // platform-specific implementation.
82 friend class MediaTransferProtocolDeviceObserverLinux;
83 friend class PortableDeviceWatcherWin;
84 friend class VolumeMountWatcherWin;
85
77 void ProcessAttach(const std::string& id, 86 void ProcessAttach(const std::string& id,
78 const string16& name, 87 const string16& name,
79 const FilePath::StringType& location); 88 const FilePath::StringType& location);
80 void ProcessDetach(const std::string& id); 89 void ProcessDetach(const std::string& id);
81 90
82 private: 91 private:
83 typedef std::map<std::string, StorageInfo> RemovableStorageMap; 92 typedef std::map<std::string, StorageInfo> RemovableStorageMap;
84 93
85 scoped_refptr<ObserverListThreadSafe<RemovableStorageObserver> > 94 scoped_refptr<ObserverListThreadSafe<RemovableStorageObserver> >
86 observer_list_; 95 observer_list_;
87 96
88 // For manipulating removable_storage_map_ structure. 97 // For manipulating removable_storage_map_ structure.
89 mutable base::Lock storage_lock_; 98 mutable base::Lock storage_lock_;
90 99
91 // Map of all the attached removable storage devices. 100 // Map of all the attached removable storage devices.
92 RemovableStorageMap storage_map_; 101 RemovableStorageMap storage_map_;
93 }; 102 };
94 103
95 } // namespace chrome 104 } // namespace chrome
96 105
97 #endif // CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_STORAGE_NOTIFICATIONS_H_ 106 #endif // CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_STORAGE_NOTIFICATIONS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698