| 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, are done lazily at first use through the async |
| 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 // A post-initialization |GetAttachedStorage()| call coupled with a |
| 47 // registered listener will receive a complete set, albeit potentially with |
| 48 // duplicates. This is because there's no tracking between when listeners were |
| 49 // registered and the state of initialization, and the fact that platforms |
| 50 // behave differently in how these notifications are provided. |
| 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_; |
| 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 |