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

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: Rebase to head 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/system_monitor/system_monitor.h" 9 #include "base/observer_list_threadsafe.h"
10 #include "base/string16.h"
11 #include "base/synchronization/lock.h"
10 12
11 namespace chrome { 13 namespace chrome {
12 14
13 // Base class for platform-specific instances watching for removable storage 15 // Base class for platform-specific instances watching for removable storage
14 // attachments/detachments. 16 // attachments/detachments.
15 class RemovableStorageNotifications { 17 class RemovableStorageNotifications {
16 public: 18 public:
19 RemovableStorageNotifications();
17 virtual ~RemovableStorageNotifications() {} 20 virtual ~RemovableStorageNotifications() {}
18 21
19 // Returns a pointer to an object owned by the BrowserMainParts, with lifetime 22 // Returns a pointer to an object owned by the BrowserMainParts, with lifetime
20 // somewhat shorter than a process Singleton. 23 // somewhat shorter than a process Singleton.
21 static RemovableStorageNotifications* GetInstance(); 24 static RemovableStorageNotifications* GetInstance();
22 25
26 struct BASE_EXPORT RemovableStorageInfo {
27 RemovableStorageInfo();
28 RemovableStorageInfo(const std::string& id,
29 const string16& device_name,
30 const FilePath::StringType& device_location);
31
32 // Unique device id - persists between device attachments.
33 std::string device_id;
34
35 // Human readable removable storage device name.
36 string16 name;
37
38 // Current attached removable storage device location.
39 FilePath::StringType location;
40 };
41
23 // Finds the device that contains |path| and populates |device_info|. 42 // Finds the device that contains |path| and populates |device_info|.
24 // Should be able to handle any path on the local system, not just removable 43 // Should be able to handle any path on the local system, not just removable
25 // storage. Returns false if unable to find the device. 44 // storage. Returns false if unable to find the device.
26 virtual bool GetDeviceInfoForPath( 45 virtual bool GetDeviceInfoForPath(
27 const FilePath& path, 46 const FilePath& path,
28 base::SystemMonitor::RemovableStorageInfo* device_info) const = 0; 47 RemovableStorageInfo* device_info) const = 0;
29 48
30 // Returns the storage size of the device present at |location|. If the 49 // Returns the storage size of the device present at |location|. If the
31 // device information is unavailable, returns zero. 50 // device information is unavailable, returns zero.
32 virtual uint64 GetStorageSize(const std::string& location) const = 0; 51 virtual uint64 GetStorageSize(const std::string& location) const = 0;
52
53 // Returns information for attached removable storage.
54 std::vector<RemovableStorageInfo> GetAttachedRemovableStorage() const;
55
56 class BASE_EXPORT RemovableStorageObserver {
vandebo (ex-Chrome) 2013/01/04 19:58:38 The Observer should not be an inner class and shou
Greg Billock 2013/01/07 21:55:18 Sounds good. I was mimicking the existing layout p
57 public:
58 // When a removable storage device is attached or detached, one of these
59 // two events is triggered.
60 virtual void OnRemovableStorageAttached(
61 const std::string& id,
62 const string16& name,
63 const FilePath::StringType& location) {}
64 virtual void OnRemovableStorageDetached(const std::string& id) {}
65
66 protected:
67 virtual ~RemovableStorageObserver() {}
68 };
69
70 void AddRemovableStorageObserver(RemovableStorageObserver* obs);
vandebo (ex-Chrome) 2013/01/04 19:58:38 Since there's only one observer in this class, the
Greg Billock 2013/01/07 21:55:18 Done. This was a mouthful! On 2013/01/04 19:58:38
71 void RemoveRemovableStorageObserver(RemovableStorageObserver* obs);
72
73 void ProcessRemovableStorageAttached(const std::string& id,
vandebo (ex-Chrome) 2013/01/04 19:58:38 The process methods should not be public. I was p
Greg Billock 2013/01/07 21:55:18 Done.
74 const string16& name,
75 const FilePath::StringType& location);
76 void ProcessRemovableStorageDetached(const std::string& id);
77
78 private:
79 typedef std::map<std::string, RemovableStorageInfo> RemovableStorageMap;
80
81 void NotifyRemovableStorageAttached(const std::string& id,
82 const string16& name,
83 const FilePath::StringType& location);
84 void NotifyRemovableStorageDetached(const std::string& id);
85
86 scoped_refptr<ObserverListThreadSafe<RemovableStorageObserver> >
87 observer_list_;
88
89 // For manipulating removable_storage_map_ structure.
90 mutable base::Lock removable_storage_lock_;
91 // Map of all the attached removable storage devices.
92 RemovableStorageMap removable_storage_map_;
33 }; 93 };
34 94
35 } // namespace chrome 95 } // namespace chrome
36 96
37 #endif // CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_STORAGE_NOTIFICATIONS_H_ 97 #endif // CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_STORAGE_NOTIFICATIONS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698