OLD | NEW |
---|---|
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 21 matching lines...) Expand all Loading... | |
32 class MediaFileSystemRegistryTest; | 32 class MediaFileSystemRegistryTest; |
33 class RemovableStorageObserver; | 33 class RemovableStorageObserver; |
34 class TransientDeviceIds; | 34 class TransientDeviceIds; |
35 | 35 |
36 // Base class for platform-specific instances watching for removable storage | 36 // Base class for platform-specific instances watching for removable storage |
37 // attachments/detachments. | 37 // attachments/detachments. |
38 // Lifecycle contracts: This class is created by ChromeBrowserMain | 38 // Lifecycle contracts: This class is created by ChromeBrowserMain |
39 // implementations before the profile is initialized, so listeners can be | 39 // implementations before the profile is initialized, so listeners can be |
40 // created during profile construction. The platform-specific initialization, | 40 // created during profile construction. The platform-specific initialization, |
41 // which can lead to calling registered listeners with notifications of | 41 // which can lead to calling registered listeners with notifications of |
42 // attached volumes, will happen after profile construction. | 42 // attached volumes, can be done lazily at first use through the async |
vandebo (ex-Chrome)
2013/05/31 18:05:03
nit: can be done => are done
| |
43 // |Initialize()| method. That must be done before any of the registered | |
44 // listeners will receive updates or calls to other API methods return | |
45 // meaningful results. | |
46 // For platform implementations, the intention is that notifications be sent | |
vandebo (ex-Chrome)
2013/05/31 18:05:03
This implies that we try to suppress duplicates, b
Greg Billock
2013/06/01 01:48:46
OK, this was a bit premature, as we haven't done t
| |
47 // on storages attached/detached after initialization is complete. However, | |
48 // not all platforms can guarantee this process is race-free, so clients | |
49 // should not depend on notifications and an initial |GetAttachedStorage()| | |
50 // call having no duplicates. | |
43 class StorageMonitor { | 51 class StorageMonitor { |
44 public: | 52 public: |
45 // This interface is provided to generators of storage notifications. | 53 // This interface is provided to generators of storage notifications. |
46 class Receiver { | 54 class Receiver { |
47 public: | 55 public: |
48 virtual ~Receiver(); | 56 virtual ~Receiver(); |
49 | 57 |
50 virtual void ProcessAttach(const StorageInfo& info) = 0; | 58 virtual void ProcessAttach(const StorageInfo& info) = 0; |
51 virtual void ProcessDetach(const std::string& id) = 0; | 59 virtual void ProcessDetach(const std::string& id) = 0; |
52 virtual void MarkInitialized() = 0; | 60 virtual void MarkInitialized() = 0; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
146 typedef std::map<std::string, StorageInfo> RemovableStorageMap; | 154 typedef std::map<std::string, StorageInfo> RemovableStorageMap; |
147 | 155 |
148 void ProcessAttach(const StorageInfo& storage); | 156 void ProcessAttach(const StorageInfo& storage); |
149 void ProcessDetach(const std::string& id); | 157 void ProcessDetach(const std::string& id); |
150 | 158 |
151 scoped_ptr<Receiver> receiver_; | 159 scoped_ptr<Receiver> receiver_; |
152 | 160 |
153 scoped_refptr<ObserverListThreadSafe<RemovableStorageObserver> > | 161 scoped_refptr<ObserverListThreadSafe<RemovableStorageObserver> > |
154 observer_list_; | 162 observer_list_; |
155 | 163 |
164 bool initializing_; | |
vandebo (ex-Chrome)
2013/05/31 18:05:03
nit: instead of two bools, an enum might be better
Greg Billock
2013/06/01 01:48:46
I think two bools are easier to understand -- one
vandebo (ex-Chrome)
2013/06/01 15:47:24
Together they specify the state of the object. If
Greg Billock
2013/06/03 15:30:57
True, but still I think this is more clear.
| |
156 bool initialized_; | 165 bool initialized_; |
157 std::vector<base::Closure> on_initialize_callbacks_; | 166 std::vector<base::Closure> on_initialize_callbacks_; |
158 | 167 |
159 // For manipulating removable_storage_map_ structure. | 168 // For manipulating removable_storage_map_ structure. |
160 mutable base::Lock storage_lock_; | 169 mutable base::Lock storage_lock_; |
161 | 170 |
162 // Map of all the attached removable storage devices. | 171 // Map of all the attached removable storage devices. |
163 RemovableStorageMap storage_map_; | 172 RemovableStorageMap storage_map_; |
164 | 173 |
165 scoped_ptr<TransientDeviceIds> transient_device_ids_; | 174 scoped_ptr<TransientDeviceIds> transient_device_ids_; |
166 }; | 175 }; |
167 | 176 |
168 } // namespace chrome | 177 } // namespace chrome |
169 | 178 |
170 #endif // CHROME_BROWSER_STORAGE_MONITOR_STORAGE_MONITOR_H_ | 179 #endif // CHROME_BROWSER_STORAGE_MONITOR_STORAGE_MONITOR_H_ |
OLD | NEW |