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

Side by Side Diff: chrome/browser/extensions/api/media_galleries_private/media_galleries_private_api.h

Issue 11820041: Remove profile-keyed factory boilerplates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 7 years, 11 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_EXTENSIONS_API_MEDIA_GALLERIES_PRIVATE_MEDIA_GALLERIES_PR IVATE_API_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_PRIVATE_MEDIA_GALLERIES_PR IVATE_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_PRIVATE_MEDIA_GALLERIES_PR IVATE_API_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_PRIVATE_MEDIA_GALLERIES_PR IVATE_API_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h"
11 #include "chrome/browser/extensions/event_router.h" 12 #include "chrome/browser/extensions/event_router.h"
12 #include "chrome/browser/extensions/extension_function.h" 13 #include "chrome/browser/extensions/extension_function.h"
13 #include "chrome/browser/media_gallery/media_galleries_preferences.h" 14 #include "chrome/browser/media_gallery/media_galleries_preferences.h"
14 #include "chrome/browser/profiles/profile_keyed_service.h"
15 15
16 class FilePath; 16 class FilePath;
17 class Profile; 17 class Profile;
18 18
19 namespace extensions { 19 namespace extensions {
20 20
21 class MediaGalleryExtensionNotificationObserver; 21 class MediaGalleryExtensionNotificationObserver;
22 class MediaGalleriesPrivateEventRouter; 22 class MediaGalleriesPrivateEventRouter;
23 23
24 // The profile-keyed service that manages the media galleries private extension 24 // The profile-keyed service that manages the media galleries private extension
25 // API. 25 // API.
26 class MediaGalleriesPrivateAPI : public ProfileKeyedService, 26 class MediaGalleriesPrivateAPI : public ProfileKeyedAPI,
27 public EventRouter::Observer { 27 public EventRouter::Observer {
28 public: 28 public:
29 explicit MediaGalleriesPrivateAPI(Profile* profile); 29 explicit MediaGalleriesPrivateAPI(Profile* profile);
30 virtual ~MediaGalleriesPrivateAPI(); 30 virtual ~MediaGalleriesPrivateAPI();
31 31
32 // ProfileKeyedService implementation. 32 // ProfileKeyedService implementation.
33 virtual void Shutdown() OVERRIDE; 33 virtual void Shutdown() OVERRIDE;
34 34
35 // ProfileKeyedAPI implementation.
36 static ProfileKeyedAPIFactory<MediaGalleriesPrivateAPI>* GetFactoryInstance();
37
38 // Convenience method to get the MediaGalleriesPrivateAPI for a profile.
39 static MediaGalleriesPrivateAPI* Get(Profile* profile);
40
35 // EventRouter::Observer implementation. 41 // EventRouter::Observer implementation.
36 virtual void OnListenerAdded(const EventListenerInfo& details) OVERRIDE; 42 virtual void OnListenerAdded(const EventListenerInfo& details) OVERRIDE;
37 43
38 MediaGalleriesPrivateEventRouter* GetEventRouter(); 44 MediaGalleriesPrivateEventRouter* GetEventRouter();
39 45
40 private: 46 private:
47 friend class ProfileKeyedAPIFactory<MediaGalleriesPrivateAPI>;
48
41 void MaybeInitializeEventRouter(); 49 void MaybeInitializeEventRouter();
42 50
51 // ProfileKeyedAPI implementation.
52 static const char* service_name() {
53 return "MediaGalleriesPrivateAPI";
54 }
55 static const bool kServiceIsNULLWhileTesting = true;
56
43 // Current profile. 57 // Current profile.
44 Profile* profile_; 58 Profile* profile_;
45 59
46 scoped_ptr<MediaGalleryExtensionNotificationObserver> 60 scoped_ptr<MediaGalleryExtensionNotificationObserver>
47 extension_notification_observer_; 61 extension_notification_observer_;
48 62
49 // Created lazily on first access. 63 // Created lazily on first access.
50 scoped_ptr<MediaGalleriesPrivateEventRouter> 64 scoped_ptr<MediaGalleriesPrivateEventRouter>
51 media_galleries_private_event_router_; 65 media_galleries_private_event_router_;
52 66
(...skipping 27 matching lines...) Expand all
80 protected: 94 protected:
81 virtual ~MediaGalleriesPrivateRemoveGalleryWatchFunction(); 95 virtual ~MediaGalleriesPrivateRemoveGalleryWatchFunction();
82 96
83 // SyncExtensionFunction overrides. 97 // SyncExtensionFunction overrides.
84 virtual bool RunImpl() OVERRIDE; 98 virtual bool RunImpl() OVERRIDE;
85 }; 99 };
86 100
87 } // namespace extensions 101 } // namespace extensions
88 102
89 #endif // CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_PRIVATE_MEDIA_GALLERIES _PRIVATE_API_H_ 103 #endif // CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_PRIVATE_MEDIA_GALLERIES _PRIVATE_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698