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

Side by Side Diff: chrome/browser/media_galleries/media_galleries_preferences.h

Issue 24298002: Media Galleries API: Use Scheduler in MediaGalleriesPreferences initialization. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
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_MEDIA_GALLERIES_MEDIA_GALLERIES_PREFERENCES_H_ 5 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_GALLERIES_PREFERENCES_H_
6 #define CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_GALLERIES_PREFERENCES_H_ 6 #define CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_GALLERIES_PREFERENCES_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 static bool APIHasBeenUsed(Profile* profile); 226 static bool APIHasBeenUsed(Profile* profile);
227 227
228 private: 228 private:
229 friend class MediaGalleriesPreferencesTest; 229 friend class MediaGalleriesPreferencesTest;
230 friend class MediaGalleriesPermissionsTest; 230 friend class MediaGalleriesPermissionsTest;
231 231
232 typedef std::map<std::string /*device id*/, MediaGalleryPrefIdSet> 232 typedef std::map<std::string /*device id*/, MediaGalleryPrefIdSet>
233 DeviceIdPrefIdsMap; 233 DeviceIdPrefIdsMap;
234 234
235 // These must be called on the UI thread. 235 // These must be called on the UI thread.
236 void OnInitializationCallbackReturned();
237 void FinishInitialization(); 236 void FinishInitialization();
238 237
239 // Populates the default galleries if this is a fresh profile. 238 // Populates the default galleries if this is a fresh profile.
240 void AddDefaultGalleriesIfFreshProfile(); 239 void AddDefaultGalleriesIfFreshProfile();
241 240
242 // This is a hack - Some devices (iTunes, Picasa) are singletons in that only 241 // This is a hack - Some devices (iTunes, Picasa) are singletons in that only
243 // one instance of that type is supported at a time. As such, the device id 242 // one instance of that type is supported at a time. As such, the device id
244 // should just be "itunes:" or "picasa:" but that would mean finding the 243 // should just be "itunes:" or "picasa:" but that would mean finding the
245 // location of the database file multiple times, which may be an async 244 // location of the database file multiple times, which may be an async
246 // operation. Storing the location of the backing database in the device 245 // operation. Storing the location of the backing database in the device
247 // id allows that look up to be avoided. However, the cost is that if the 246 // id allows that look up to be avoided. However, the cost is that if the
248 // database moves, the device id in preferences has to be updated. This 247 // database moves, the device id in preferences has to be updated. This
249 // method searches for a gallery of the type passed in and updates its 248 // method searches for a gallery of the type passed in and updates its
250 // device id. It returns true if the device id is up to date. 249 // device id. It returns true if the device id is up to date.
251 bool UpdateDeviceIDForSingletonType(const std::string& device_id); 250 bool UpdateDeviceIDForSingletonType(const std::string& device_id);
252 251
253 // Handle an iTunes or Picasa finder returning a device ID to us. 252 // Handle an iTunes or Picasa finder returning a device ID to us.
254 void OnFinderDeviceID(const std::string& device_id); 253 // |callback| is called once it's done, if it's non-null.
254 void OnFinderDeviceID(base::Closure callback, const std::string& device_id);
255 255
256 // Builds |known_galleries_| from the persistent store. 256 // Builds |known_galleries_| from the persistent store.
257 void InitFromPrefs(); 257 void InitFromPrefs();
258 258
259 MediaGalleryPrefId AddGalleryInternal(const std::string& device_id, 259 MediaGalleryPrefId AddGalleryInternal(const std::string& device_id,
260 const string16& display_name, 260 const string16& display_name,
261 const base::FilePath& relative_path, 261 const base::FilePath& relative_path,
262 bool user_added, 262 bool user_added,
263 const string16& volume_label, 263 const string16& volume_label,
264 const string16& vendor_name, 264 const string16& vendor_name,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 void SetExtensionPrefsForTesting(extensions::ExtensionPrefs* extension_prefs); 298 void SetExtensionPrefsForTesting(extensions::ExtensionPrefs* extension_prefs);
299 299
300 base::WeakPtrFactory<MediaGalleriesPreferences> weak_factory_; 300 base::WeakPtrFactory<MediaGalleriesPreferences> weak_factory_;
301 301
302 // Used to make sure we call initialize from the same thread as creation. 302 // Used to make sure we call initialize from the same thread as creation.
303 base::ThreadChecker thread_checker_; 303 base::ThreadChecker thread_checker_;
304 304
305 bool initializing_; 305 bool initializing_;
306 bool initialized_; 306 bool initialized_;
307 std::vector<base::Closure> on_initialize_callbacks_; 307 std::vector<base::Closure> on_initialize_callbacks_;
308 int pre_initialization_callbacks_waiting_;
309 308
310 // The profile that owns |this|. 309 // The profile that owns |this|.
311 Profile* profile_; 310 Profile* profile_;
312 311
313 // The ExtensionPrefs used in a testing environment, where 312 // The ExtensionPrefs used in a testing environment, where
314 // BrowserContextKeyedServices aren't used. This will be NULL unless it is 313 // BrowserContextKeyedServices aren't used. This will be NULL unless it is
315 // set with SetExtensionPrefsForTesting(). 314 // set with SetExtensionPrefsForTesting().
316 extensions::ExtensionPrefs* extension_prefs_for_testing_; 315 extensions::ExtensionPrefs* extension_prefs_for_testing_;
317 316
318 // An in-memory cache of known galleries. 317 // An in-memory cache of known galleries.
319 MediaGalleriesPrefInfoMap known_galleries_; 318 MediaGalleriesPrefInfoMap known_galleries_;
320 319
321 // A mapping from device id to the set of gallery pref ids on that device. 320 // A mapping from device id to the set of gallery pref ids on that device.
322 // All pref ids in |device_map_| are also in |known_galleries_|. 321 // All pref ids in |device_map_| are also in |known_galleries_|.
323 DeviceIdPrefIdsMap device_map_; 322 DeviceIdPrefIdsMap device_map_;
324 323
325 ObserverList<GalleryChangeObserver> gallery_change_observers_; 324 ObserverList<GalleryChangeObserver> gallery_change_observers_;
326 325
327 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesPreferences); 326 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesPreferences);
328 }; 327 };
329 328
330 #endif // CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_GALLERIES_PREFERENCES_H_ 329 #endif // CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_GALLERIES_PREFERENCES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698