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

Unified Diff: chrome/browser/extensions/api/media_galleries_private/media_galleries_private_api.h

Issue 14556015: [Media Galleries] Lazily initialize the storage monitor. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix merge Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/media_galleries_private/media_galleries_private_api.h
diff --git a/chrome/browser/extensions/api/media_galleries_private/media_galleries_private_api.h b/chrome/browser/extensions/api/media_galleries_private/media_galleries_private_api.h
index c3b7815d2f563b7abe2eca6b79cb317696c16754..1c3e5710244d0c21865b7a500edbec7c197faa8d 100644
--- a/chrome/browser/extensions/api/media_galleries_private/media_galleries_private_api.h
+++ b/chrome/browser/extensions/api/media_galleries_private/media_galleries_private_api.h
@@ -9,6 +9,7 @@
#include <vector>
#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
#include "chrome/browser/extensions/api/media_galleries_private/gallery_watch_state_tracker.h"
#include "chrome/browser/extensions/api/profile_keyed_api_factory.h"
#include "chrome/browser/extensions/event_router.h"
@@ -24,7 +25,7 @@ namespace extensions {
class MediaGalleriesPrivateEventRouter;
// The profile-keyed service that manages the media galleries private extension
-// API.
+// API. Created at the same time as the Profile.
class MediaGalleriesPrivateAPI : public ProfileKeyedAPI,
public EventRouter::Observer {
public:
@@ -85,12 +86,15 @@ class MediaGalleriesPrivateAPI : public ProfileKeyedAPI,
// Current profile.
Profile* profile_;
+ // Created lazily on first access.
scoped_ptr<GalleryWatchStateTracker> tracker_;
// Created lazily on first access.
scoped_ptr<MediaGalleriesPrivateEventRouter>
media_galleries_private_event_router_;
+ base::WeakPtrFactory<MediaGalleriesPrivateAPI> weak_ptr_factory_;
+
DISALLOW_COPY_AND_ASSIGN(MediaGalleriesPrivateAPI);
};
@@ -108,6 +112,8 @@ class MediaGalleriesPrivateAddGalleryWatchFunction
virtual bool RunImpl() OVERRIDE;
private:
+ void OnStorageMonitorInit(const std::string& pref_id);
+
// Gallery watch request handler.
void HandleResponse(chrome::MediaGalleryPrefId gallery_id,
bool success);
@@ -115,7 +121,7 @@ class MediaGalleriesPrivateAddGalleryWatchFunction
// Implements the chrome.mediaGalleriesPrivate.removeGalleryWatch method.
class MediaGalleriesPrivateRemoveGalleryWatchFunction
- : public SyncExtensionFunction {
+ : public AsyncExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("mediaGalleriesPrivate.removeGalleryWatch",
MEDIAGALLERIESPRIVATE_REMOVEGALLERYWATCH);
@@ -125,11 +131,14 @@ class MediaGalleriesPrivateRemoveGalleryWatchFunction
// SyncExtensionFunction overrides.
virtual bool RunImpl() OVERRIDE;
+
+ private:
+ void OnStorageMonitorInit(const std::string& pref_id);
};
// Implements the chrome.mediaGalleriesPrivate.getAllGalleryWatch method.
class MediaGalleriesPrivateGetAllGalleryWatchFunction
- : public SyncExtensionFunction {
+ : public AsyncExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("mediaGalleriesPrivate.getAllGalleryWatch",
MEDIAGALLERIESPRIVATE_GETALLGALLERYWATCH);
@@ -138,11 +147,14 @@ class MediaGalleriesPrivateGetAllGalleryWatchFunction
// SyncExtensionFunction overrides.
virtual bool RunImpl() OVERRIDE;
+
+ private:
+ void OnStorageMonitorInit();
};
// Implements the chrome.mediaGalleriesPrivate.removeAllGalleryWatch method.
class MediaGalleriesPrivateRemoveAllGalleryWatchFunction
- : public SyncExtensionFunction {
+ : public AsyncExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("mediaGalleriesPrivate.removeAllGalleryWatch",
MEDIAGALLERIESPRIVATE_REMOVEALLGALLERYWATCH);
@@ -151,6 +163,9 @@ class MediaGalleriesPrivateRemoveAllGalleryWatchFunction
// SyncExtensionFunction overrides.
virtual bool RunImpl() OVERRIDE;
+
+ private:
+ void OnStorageMonitorInit();
};
// Implements the chrome.mediaGalleriesPrivate.ejectDevice method.
@@ -167,6 +182,8 @@ class MediaGalleriesPrivateEjectDeviceFunction
virtual bool RunImpl() OVERRIDE;
private:
+ void OnStorageMonitorInit(const std::string& transient_device_id);
+
// Eject device request handler.
void HandleResponse(chrome::StorageMonitor::EjectStatus status);
};

Powered by Google App Engine
This is Rietveld 408576698