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

Side by Side Diff: chrome/browser/extensions/api/history/history_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_HISTORY_HISTORY_API_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_HISTORY_HISTORY_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_HISTORY_HISTORY_API_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_HISTORY_HISTORY_API_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/memory/linked_ptr.h" 12 #include "base/memory/linked_ptr.h"
13 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h"
13 #include "chrome/browser/extensions/event_router.h" 14 #include "chrome/browser/extensions/event_router.h"
14 #include "chrome/browser/extensions/extension_function.h" 15 #include "chrome/browser/extensions/extension_function.h"
15 #include "chrome/browser/history/history.h" 16 #include "chrome/browser/history/history.h"
16 #include "chrome/browser/history/history_notifications.h" 17 #include "chrome/browser/history/history_notifications.h"
17 #include "chrome/browser/profiles/profile_keyed_service.h"
18 #include "chrome/common/cancelable_task_tracker.h" 18 #include "chrome/common/cancelable_task_tracker.h"
19 #include "chrome/common/extensions/api/history.h" 19 #include "chrome/common/extensions/api/history.h"
20 #include "content/public/browser/notification_registrar.h" 20 #include "content/public/browser/notification_registrar.h"
21 21
22 namespace base { 22 namespace base {
23 class ListValue; 23 class ListValue;
24 } 24 }
25 25
26 namespace extensions { 26 namespace extensions {
27 27
(...skipping 19 matching lines...) Expand all
47 void DispatchEvent(Profile* profile, 47 void DispatchEvent(Profile* profile,
48 const char* event_name, 48 const char* event_name,
49 scoped_ptr<base::ListValue> event_args); 49 scoped_ptr<base::ListValue> event_args);
50 50
51 // Used for tracking registrations to history service notifications. 51 // Used for tracking registrations to history service notifications.
52 content::NotificationRegistrar registrar_; 52 content::NotificationRegistrar registrar_;
53 53
54 DISALLOW_COPY_AND_ASSIGN(HistoryEventRouter); 54 DISALLOW_COPY_AND_ASSIGN(HistoryEventRouter);
55 }; 55 };
56 56
57 class HistoryAPI : public ProfileKeyedService, 57 class HistoryAPI : public ProfileKeyedAPI,
58 public EventRouter::Observer { 58 public EventRouter::Observer {
59 public: 59 public:
60 explicit HistoryAPI(Profile* profile); 60 explicit HistoryAPI(Profile* profile);
61 virtual ~HistoryAPI(); 61 virtual ~HistoryAPI();
62 62
63 // ProfileKeyedService implementation. 63 // ProfileKeyedService implementation.
64 virtual void Shutdown() OVERRIDE; 64 virtual void Shutdown() OVERRIDE;
65 65
66 // ProfileKeyedAPI implementation.
67 static ProfileKeyedAPIFactory<HistoryAPI>* GetFactoryInstance();
68
66 // EventRouter::Observer implementation. 69 // EventRouter::Observer implementation.
67 virtual void OnListenerAdded(const EventListenerInfo& details) OVERRIDE; 70 virtual void OnListenerAdded(const EventListenerInfo& details) OVERRIDE;
68 71
69 private: 72 private:
73 friend class ProfileKeyedAPIFactory<HistoryAPI>;
74
70 Profile* profile_; 75 Profile* profile_;
71 76
77 // ProfileKeyedAPI implementation.
78 static const char* service_name() {
79 return "HistoryAPI";
80 }
81 static const bool kServiceIsNULLWhileTesting = true;
82
72 // Created lazily upon OnListenerAdded. 83 // Created lazily upon OnListenerAdded.
73 scoped_ptr<HistoryEventRouter> history_event_router_; 84 scoped_ptr<HistoryEventRouter> history_event_router_;
74 }; 85 };
75 86
76 // Base class for history function APIs. 87 // Base class for history function APIs.
77 class HistoryFunction : public AsyncExtensionFunction { 88 class HistoryFunction : public AsyncExtensionFunction {
78 protected: 89 protected:
79 virtual ~HistoryFunction() {} 90 virtual ~HistoryFunction() {}
80 virtual void Run() OVERRIDE; 91 virtual void Run() OVERRIDE;
81 92
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 // HistoryFunctionWithCallback: 217 // HistoryFunctionWithCallback:
207 virtual bool RunAsyncImpl() OVERRIDE; 218 virtual bool RunAsyncImpl() OVERRIDE;
208 219
209 // Callback for the history service to acknowledge deletion. 220 // Callback for the history service to acknowledge deletion.
210 void DeleteComplete(); 221 void DeleteComplete();
211 }; 222 };
212 223
213 } // namespace extensions 224 } // namespace extensions
214 225
215 #endif // CHROME_BROWSER_EXTENSIONS_API_HISTORY_HISTORY_API_H_ 226 #endif // CHROME_BROWSER_EXTENSIONS_API_HISTORY_HISTORY_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698