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

Side by Side Diff: chrome/browser/storage_monitor/storage_monitor.h

Issue 15988011: Refine StorageMonitor storage device getter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix SystemInfoStorageApiTest failures in browser_tests Created 7 years, 6 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
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_STORAGE_MONITOR_STORAGE_MONITOR_H_ 5 #ifndef CHROME_BROWSER_STORAGE_MONITOR_STORAGE_MONITOR_H_
6 #define CHROME_BROWSER_STORAGE_MONITOR_STORAGE_MONITOR_H_ 6 #define CHROME_BROWSER_STORAGE_MONITOR_STORAGE_MONITOR_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 EJECT_FAILURE 68 EJECT_FAILURE
69 }; 69 };
70 70
71 // Returns a pointer to an object owned by the BrowserMainParts, with lifetime 71 // Returns a pointer to an object owned by the BrowserMainParts, with lifetime
72 // somewhat shorter than a process Singleton. 72 // somewhat shorter than a process Singleton.
73 static StorageMonitor* GetInstance(); 73 static StorageMonitor* GetInstance();
74 74
75 // Initialize the storage monitor. The provided callback, if non-null, 75 // Initialize the storage monitor. The provided callback, if non-null,
76 // will be called when initialization is complete. If initialization has 76 // will be called when initialization is complete. If initialization has
77 // already completed, this callback will be invoked within the calling stack. 77 // already completed, this callback will be invoked within the calling stack.
78 // Before the callback is run, calls to |GetAttachedStorage| and 78 // Before the callback is run, calls to |GetAllAvailableStorages| and
79 // |GetStorageInfoForPath| may not return the correct results. In addition, 79 // |GetStorageInfoForPath| may not return the correct results. In addition,
80 // registered observers will not be notified on device attachment/detachment. 80 // registered observers will not be notified on device attachment/detachment.
81 // Should be invoked on the UI thread; callbacks will be run on the UI thread. 81 // Should be invoked on the UI thread; callbacks will be run on the UI thread.
82 void Initialize(base::Closure callback); 82 void Initialize(base::Closure callback);
83 83
84 // Return true if the storage monitor has already been initialized. 84 // Return true if the storage monitor has already been initialized.
85 bool IsInitialized(); 85 bool IsInitialized();
86 86
87 // Finds the device that contains |path| and populates |device_info|. 87 // Finds the device that contains |path| and populates |device_info|.
88 // Should be able to handle any path on the local system, not just removable 88 // Should be able to handle any path on the local system, not just removable
(...skipping 14 matching lines...) Expand all
103 const std::string& storage_device_id, 103 const std::string& storage_device_id,
104 string16* device_location, 104 string16* device_location,
105 string16* storage_object_id) const = 0; 105 string16* storage_object_id) const = 0;
106 #endif 106 #endif
107 107
108 #if defined(OS_LINUX) 108 #if defined(OS_LINUX)
109 virtual device::MediaTransferProtocolManager* 109 virtual device::MediaTransferProtocolManager*
110 media_transfer_protocol_manager() = 0; 110 media_transfer_protocol_manager() = 0;
111 #endif 111 #endif
112 112
113 // Returns information for attached removable storage. 113 // Returns information for all known storages on the system,
114 std::vector<StorageInfo> GetAttachedStorage() const; 114 // including fixed and removable storages.
115 std::vector<StorageInfo> GetAllAvailableStorages() const;
115 116
116 void AddObserver(RemovableStorageObserver* obs); 117 void AddObserver(RemovableStorageObserver* obs);
117 void RemoveObserver(RemovableStorageObserver* obs); 118 void RemoveObserver(RemovableStorageObserver* obs);
118 119
119 std::string GetTransientIdForDeviceId(const std::string& device_id); 120 std::string GetTransientIdForDeviceId(const std::string& device_id);
120 std::string GetDeviceIdForTransientId(const std::string& transient_id) const; 121 std::string GetDeviceIdForTransientId(const std::string& transient_id) const;
121 122
122 virtual void EjectDevice( 123 virtual void EjectDevice(
123 const std::string& device_id, 124 const std::string& device_id,
124 base::Callback<void(EjectStatus)> callback); 125 base::Callback<void(EjectStatus)> callback);
(...skipping 19 matching lines...) Expand all
144 145
145 // Called by subclasses to mark the storage monitor as 146 // Called by subclasses to mark the storage monitor as
146 // fully initialized. Must be called on the UI thread. 147 // fully initialized. Must be called on the UI thread.
147 void MarkInitialized(); 148 void MarkInitialized();
148 149
149 private: 150 private:
150 class ReceiverImpl; 151 class ReceiverImpl;
151 friend class ReceiverImpl; 152 friend class ReceiverImpl;
152 153
153 // Key: device id. 154 // Key: device id.
154 typedef std::map<std::string, StorageInfo> RemovableStorageMap; 155 typedef std::map<std::string, StorageInfo> StorageMap;
155 156
156 void ProcessAttach(const StorageInfo& storage); 157 void ProcessAttach(const StorageInfo& storage);
157 void ProcessDetach(const std::string& id); 158 void ProcessDetach(const std::string& id);
158 159
159 scoped_ptr<Receiver> receiver_; 160 scoped_ptr<Receiver> receiver_;
160 161
161 scoped_refptr<ObserverListThreadSafe<RemovableStorageObserver> > 162 scoped_refptr<ObserverListThreadSafe<RemovableStorageObserver> >
162 observer_list_; 163 observer_list_;
163 164
164 // Used to make sure we call initialize from the same thread as creation. 165 // Used to make sure we call initialize from the same thread as creation.
165 base::ThreadChecker thread_checker_; 166 base::ThreadChecker thread_checker_;
166 167
167 bool initializing_; 168 bool initializing_;
168 bool initialized_; 169 bool initialized_;
169 std::vector<base::Closure> on_initialize_callbacks_; 170 std::vector<base::Closure> on_initialize_callbacks_;
170 171
171 // For manipulating removable_storage_map_ structure. 172 // For manipulating storage_map_ structure.
172 mutable base::Lock storage_lock_; 173 mutable base::Lock storage_lock_;
173 174
174 // Map of all the attached removable storage devices. 175 // Map of all known storage devices,including fixed and removable storages.
175 RemovableStorageMap storage_map_; 176 StorageMap storage_map_;
176 177
177 scoped_ptr<TransientDeviceIds> transient_device_ids_; 178 scoped_ptr<TransientDeviceIds> transient_device_ids_;
178 }; 179 };
179 180
180 } // namespace chrome 181 } // namespace chrome
181 182
182 #endif // CHROME_BROWSER_STORAGE_MONITOR_STORAGE_MONITOR_H_ 183 #endif // CHROME_BROWSER_STORAGE_MONITOR_STORAGE_MONITOR_H_
OLDNEW
« no previous file with comments | « chrome/browser/storage_monitor/media_storage_util.cc ('k') | chrome/browser/storage_monitor/storage_monitor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698