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

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: Rebase 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 }; 61 };
62 62
63 // Status codes for the result of an EjectDevice() call. 63 // Status codes for the result of an EjectDevice() call.
64 enum EjectStatus { 64 enum EjectStatus {
65 EJECT_OK, 65 EJECT_OK,
66 EJECT_IN_USE, 66 EJECT_IN_USE,
67 EJECT_NO_SUCH_DEVICE, 67 EJECT_NO_SUCH_DEVICE,
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 a created per-platform object with the StorageMonitor
72 // somewhat shorter than a process Singleton. 72 // interface.
vandebo (ex-Chrome) 2013/07/10 16:57:45 Should this only be called by BrowserProcess (espe
Greg Billock 2013/07/10 21:57:17 Hmmm. Could do.
73 static StorageMonitor* Create();
74
75 // Returns a pointer to an object owned by BrowserProcess, with lifetime
76 // starting before main message loop start, and ending after main message loop
77 // shutdown.
vandebo (ex-Chrome) 2013/07/10 16:57:45 Outside that lifetime this returns Null?
Greg Billock 2013/07/10 21:11:16 Added comment
73 static StorageMonitor* GetInstance(); 78 static StorageMonitor* GetInstance();
74 79
80 virtual ~StorageMonitor();
81
75 // Ensures that the storage monitor is initialized. The provided callback, If 82 // Ensures that the storage monitor is initialized. The provided callback, If
76 // non-null, will be called when initialization is complete. If initialization 83 // non-null, will be called when initialization is complete. If initialization
77 // has already completed, this callback will be invoked within the calling 84 // has already completed, this callback will be invoked within the calling
78 // stack. Before the callback is run, calls to |GetAllAvailableStorages| and 85 // stack. Before the callback is run, calls to |GetAllAvailableStorages| and
79 // |GetStorageInfoForPath| may not return the correct results. In addition, 86 // |GetStorageInfoForPath| may not return the correct results. In addition,
80 // registered observers will not be notified on device attachment/detachment. 87 // 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. 88 // Should be invoked on the UI thread; callbacks will be run on the UI thread.
82 void EnsureInitialized(base::Closure callback); 89 void EnsureInitialized(base::Closure callback);
83 90
84 // Return true if the storage monitor has already been initialized. 91 // Return true if the storage monitor has already been initialized.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 base::Callback<void(EjectStatus)> callback); 132 base::Callback<void(EjectStatus)> callback);
126 133
127 protected: 134 protected:
128 friend class ::MediaGalleriesPlatformAppBrowserTest; 135 friend class ::MediaGalleriesPlatformAppBrowserTest;
129 friend class ::MediaGalleriesPrivateApiTest; 136 friend class ::MediaGalleriesPrivateApiTest;
130 friend class ::MediaGalleriesPrivateEjectApiTest; 137 friend class ::MediaGalleriesPrivateEjectApiTest;
131 friend class MediaFileSystemRegistryTest; 138 friend class MediaFileSystemRegistryTest;
132 friend class ::SystemInfoStorageApiTest; 139 friend class ::SystemInfoStorageApiTest;
133 140
134 StorageMonitor(); 141 StorageMonitor();
135 virtual ~StorageMonitor();
136
137 // Removes the existing singleton for testing.
138 // (So that a new one can be created.)
139 static void RemoveSingletonForTesting();
140 142
141 virtual Receiver* receiver() const; 143 virtual Receiver* receiver() const;
vandebo (ex-Chrome) 2013/07/10 16:57:45 aside: weren't we going to get rid of this method
Greg Billock 2013/07/10 21:11:16 I think so. There are still various tests that use
142 144
143 // Called to initialize the storage monitor. 145 // Called to initialize the storage monitor.
144 virtual void Init() = 0; 146 virtual void Init() = 0;
145 147
146 // Called by subclasses to mark the storage monitor as 148 // Called by subclasses to mark the storage monitor as
147 // fully initialized. Must be called on the UI thread. 149 // fully initialized. Must be called on the UI thread.
148 void MarkInitialized(); 150 void MarkInitialized();
149 151
150 private: 152 private:
151 class ReceiverImpl; 153 class ReceiverImpl;
(...skipping 22 matching lines...) Expand all
174 176
175 // Map of all known storage devices,including fixed and removable storages. 177 // Map of all known storage devices,including fixed and removable storages.
176 StorageMap storage_map_; 178 StorageMap storage_map_;
177 179
178 scoped_ptr<TransientDeviceIds> transient_device_ids_; 180 scoped_ptr<TransientDeviceIds> transient_device_ids_;
179 }; 181 };
180 182
181 } // namespace chrome 183 } // namespace chrome
182 184
183 #endif // CHROME_BROWSER_STORAGE_MONITOR_STORAGE_MONITOR_H_ 185 #endif // CHROME_BROWSER_STORAGE_MONITOR_STORAGE_MONITOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698