OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_STORAGE_MONITOR_STORAGE_MONITOR_H_ | 5 #ifndef COMPONENTS_STORAGE_MONITOR_STORAGE_MONITOR_H_ |
6 #define COMPONENTS_STORAGE_MONITOR_STORAGE_MONITOR_H_ | 6 #define COMPONENTS_STORAGE_MONITOR_STORAGE_MONITOR_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
| 9 #include <memory> |
9 #include <string> | 10 #include <string> |
10 #include <vector> | 11 #include <vector> |
11 | 12 |
12 #include "base/callback.h" | 13 #include "base/callback.h" |
13 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
14 #include "base/memory/scoped_ptr.h" | |
15 #include "base/observer_list_threadsafe.h" | 15 #include "base/observer_list_threadsafe.h" |
16 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
17 #include "base/synchronization/lock.h" | 17 #include "base/synchronization/lock.h" |
18 #include "base/threading/thread_checker.h" | 18 #include "base/threading/thread_checker.h" |
19 #include "build/build_config.h" | 19 #include "build/build_config.h" |
20 #include "components/storage_monitor/storage_info.h" | 20 #include "components/storage_monitor/storage_info.h" |
21 | 21 |
22 class MediaFileSystemRegistryTest; | 22 class MediaFileSystemRegistryTest; |
23 class MediaGalleriesPlatformAppBrowserTest; | 23 class MediaGalleriesPlatformAppBrowserTest; |
24 class SystemStorageApiTest; | 24 class SystemStorageApiTest; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 // Destroys the StorageMonitor singleton. | 76 // Destroys the StorageMonitor singleton. |
77 static void Destroy(); | 77 static void Destroy(); |
78 | 78 |
79 // Returns a pointer to an object owned by BrowserProcess, with lifetime | 79 // Returns a pointer to an object owned by BrowserProcess, with lifetime |
80 // starting before main message loop start, and ending after main message loop | 80 // starting before main message loop start, and ending after main message loop |
81 // shutdown. Called outside it's lifetime (or with no browser process), | 81 // shutdown. Called outside it's lifetime (or with no browser process), |
82 // returns NULL. | 82 // returns NULL. |
83 static StorageMonitor* GetInstance(); | 83 static StorageMonitor* GetInstance(); |
84 | 84 |
85 static void SetStorageMonitorForTesting( | 85 static void SetStorageMonitorForTesting( |
86 scoped_ptr<StorageMonitor> storage_monitor); | 86 std::unique_ptr<StorageMonitor> storage_monitor); |
87 | 87 |
88 virtual ~StorageMonitor(); | 88 virtual ~StorageMonitor(); |
89 | 89 |
90 // Ensures that the storage monitor is initialized. The provided callback, if | 90 // Ensures that the storage monitor is initialized. The provided callback, if |
91 // non-null, will be called when initialization is complete. If initialization | 91 // non-null, will be called when initialization is complete. If initialization |
92 // has already completed, this callback will be invoked within the calling | 92 // has already completed, this callback will be invoked within the calling |
93 // stack. Before the callback is run, calls to |GetAllAvailableStorages| and | 93 // stack. Before the callback is run, calls to |GetAllAvailableStorages| and |
94 // |GetStorageInfoForPath| may not return the correct results. In addition, | 94 // |GetStorageInfoForPath| may not return the correct results. In addition, |
95 // registered observers will not be notified on device attachment/detachment. | 95 // registered observers will not be notified on device attachment/detachment. |
96 // Should be invoked on the UI thread; callbacks will be run on the UI thread. | 96 // Should be invoked on the UI thread; callbacks will be run on the UI thread. |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 | 162 |
163 class ReceiverImpl; | 163 class ReceiverImpl; |
164 friend class ReceiverImpl; | 164 friend class ReceiverImpl; |
165 | 165 |
166 // Key: device id. | 166 // Key: device id. |
167 typedef std::map<std::string, StorageInfo> StorageMap; | 167 typedef std::map<std::string, StorageInfo> StorageMap; |
168 | 168 |
169 void ProcessAttach(const StorageInfo& storage); | 169 void ProcessAttach(const StorageInfo& storage); |
170 void ProcessDetach(const std::string& id); | 170 void ProcessDetach(const std::string& id); |
171 | 171 |
172 scoped_ptr<Receiver> receiver_; | 172 std::unique_ptr<Receiver> receiver_; |
173 | 173 |
174 scoped_refptr<base::ObserverListThreadSafe<RemovableStorageObserver>> | 174 scoped_refptr<base::ObserverListThreadSafe<RemovableStorageObserver>> |
175 observer_list_; | 175 observer_list_; |
176 | 176 |
177 // Used to make sure we call initialize from the same thread as creation. | 177 // Used to make sure we call initialize from the same thread as creation. |
178 base::ThreadChecker thread_checker_; | 178 base::ThreadChecker thread_checker_; |
179 | 179 |
180 bool initializing_; | 180 bool initializing_; |
181 bool initialized_; | 181 bool initialized_; |
182 std::vector<base::Closure> on_initialize_callbacks_; | 182 std::vector<base::Closure> on_initialize_callbacks_; |
183 | 183 |
184 // For manipulating storage_map_ structure. | 184 // For manipulating storage_map_ structure. |
185 mutable base::Lock storage_lock_; | 185 mutable base::Lock storage_lock_; |
186 | 186 |
187 // Map of all known storage devices,including fixed and removable storages. | 187 // Map of all known storage devices,including fixed and removable storages. |
188 StorageMap storage_map_; | 188 StorageMap storage_map_; |
189 | 189 |
190 scoped_ptr<TransientDeviceIds> transient_device_ids_; | 190 std::unique_ptr<TransientDeviceIds> transient_device_ids_; |
191 }; | 191 }; |
192 | 192 |
193 } // namespace storage_monitor | 193 } // namespace storage_monitor |
194 | 194 |
195 #endif // COMPONENTS_STORAGE_MONITOR_STORAGE_MONITOR_H_ | 195 #endif // COMPONENTS_STORAGE_MONITOR_STORAGE_MONITOR_H_ |
OLD | NEW |