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

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

Issue 16703025: [StorageMonitor] Move StorageMonitor ownership to BrowserProcessImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Catch up to SystemInfoStorage eject test Created 7 years, 5 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 18 matching lines...) Expand all
29 } 29 }
30 30
31 namespace chrome { 31 namespace chrome {
32 32
33 class MediaFileSystemRegistryTest; 33 class MediaFileSystemRegistryTest;
34 class RemovableStorageObserver; 34 class RemovableStorageObserver;
35 class TransientDeviceIds; 35 class TransientDeviceIds;
36 36
37 // Base class for platform-specific instances watching for removable storage 37 // Base class for platform-specific instances watching for removable storage
38 // attachments/detachments. 38 // attachments/detachments.
39 // Lifecycle contracts: This class is created by ChromeBrowserMain 39 // Lifecycle contracts: This class is created in the browser process
40 // implementations before the profile is initialized, so listeners can be 40 // before the profile is initialized, so listeners can be
41 // created during profile construction. The platform-specific initialization, 41 // created during profile construction. The platform-specific initialization,
42 // which can lead to calling registered listeners with notifications of 42 // which can lead to calling registered listeners with notifications of
43 // attached volumes, are done lazily at first use through the async 43 // attached volumes, are done lazily at first use through the async
44 // |Initialize()| method. That must be done before any of the registered 44 // |Initialize()| method. That must be done before any of the registered
45 // listeners will receive updates or calls to other API methods return 45 // listeners will receive updates or calls to other API methods return
46 // meaningful results. 46 // meaningful results.
47 // A post-initialization |GetAttachedStorage()| call coupled with a 47 // A post-initialization |GetAttachedStorage()| call coupled with a
48 // registered listener will receive a complete set, albeit potentially with 48 // registered listener will receive a complete set, albeit potentially with
49 // duplicates. This is because there's no tracking between when listeners were 49 // duplicates. This is because there's no tracking between when listeners were
50 // registered and the state of initialization, and the fact that platforms 50 // registered and the state of initialization, and the fact that platforms
(...skipping 11 matching lines...) Expand all
62 }; 62 };
63 63
64 // Status codes for the result of an EjectDevice() call. 64 // Status codes for the result of an EjectDevice() call.
65 enum EjectStatus { 65 enum EjectStatus {
66 EJECT_OK, 66 EJECT_OK,
67 EJECT_IN_USE, 67 EJECT_IN_USE,
68 EJECT_NO_SUCH_DEVICE, 68 EJECT_NO_SUCH_DEVICE,
69 EJECT_FAILURE 69 EJECT_FAILURE
70 }; 70 };
71 71
72 // Returns a pointer to an object owned by the BrowserMainParts, with lifetime 72 // Returns a pointer to a newly created per-platform object with the
73 // somewhat shorter than a process Singleton. 73 // StorageMonitor interface.
74 static StorageMonitor* Create();
75
76 // Returns a pointer to an object owned by BrowserProcess, with lifetime
77 // starting before main message loop start, and ending after main message loop
78 // shutdown. Called outside it's lifetime (or with no browser process),
79 // returns NULL.
74 static StorageMonitor* GetInstance(); 80 static StorageMonitor* GetInstance();
75 81
82 virtual ~StorageMonitor();
83
76 // Ensures that the storage monitor is initialized. The provided callback, If 84 // Ensures that the storage monitor is initialized. The provided callback, If
77 // non-null, will be called when initialization is complete. If initialization 85 // non-null, will be called when initialization is complete. If initialization
78 // has already completed, this callback will be invoked within the calling 86 // has already completed, this callback will be invoked within the calling
79 // stack. Before the callback is run, calls to |GetAllAvailableStorages| and 87 // stack. Before the callback is run, calls to |GetAllAvailableStorages| and
80 // |GetStorageInfoForPath| may not return the correct results. In addition, 88 // |GetStorageInfoForPath| may not return the correct results. In addition,
81 // registered observers will not be notified on device attachment/detachment. 89 // registered observers will not be notified on device attachment/detachment.
82 // Should be invoked on the UI thread; callbacks will be run on the UI thread. 90 // Should be invoked on the UI thread; callbacks will be run on the UI thread.
83 void EnsureInitialized(base::Closure callback); 91 void EnsureInitialized(base::Closure callback);
84 92
85 // Return true if the storage monitor has already been initialized. 93 // Return true if the storage monitor has already been initialized.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 135
128 protected: 136 protected:
129 friend class ::MediaGalleriesPlatformAppBrowserTest; 137 friend class ::MediaGalleriesPlatformAppBrowserTest;
130 friend class ::MediaGalleriesPrivateApiTest; 138 friend class ::MediaGalleriesPrivateApiTest;
131 friend class ::MediaGalleriesPrivateEjectApiTest; 139 friend class ::MediaGalleriesPrivateEjectApiTest;
132 friend class MediaFileSystemRegistryTest; 140 friend class MediaFileSystemRegistryTest;
133 friend class ::SystemInfoStorageApiTest; 141 friend class ::SystemInfoStorageApiTest;
134 friend class ::SystemInfoStorageEjectApiTest; 142 friend class ::SystemInfoStorageEjectApiTest;
135 143
136 StorageMonitor(); 144 StorageMonitor();
137 virtual ~StorageMonitor();
138
139 // Removes the existing singleton for testing.
140 // (So that a new one can be created.)
141 static void RemoveSingletonForTesting();
142 145
143 virtual Receiver* receiver() const; 146 virtual Receiver* receiver() const;
144 147
145 // Called to initialize the storage monitor. 148 // Called to initialize the storage monitor.
146 virtual void Init() = 0; 149 virtual void Init() = 0;
147 150
148 // Called by subclasses to mark the storage monitor as 151 // Called by subclasses to mark the storage monitor as
149 // fully initialized. Must be called on the UI thread. 152 // fully initialized. Must be called on the UI thread.
150 void MarkInitialized(); 153 void MarkInitialized();
151 154
(...skipping 24 matching lines...) Expand all
176 179
177 // Map of all known storage devices,including fixed and removable storages. 180 // Map of all known storage devices,including fixed and removable storages.
178 StorageMap storage_map_; 181 StorageMap storage_map_;
179 182
180 scoped_ptr<TransientDeviceIds> transient_device_ids_; 183 scoped_ptr<TransientDeviceIds> transient_device_ids_;
181 }; 184 };
182 185
183 } // namespace chrome 186 } // namespace chrome
184 187
185 #endif // CHROME_BROWSER_STORAGE_MONITOR_STORAGE_MONITOR_H_ 188 #endif // CHROME_BROWSER_STORAGE_MONITOR_STORAGE_MONITOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698