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

Side by Side Diff: chrome/browser/extensions/api/processes/processes_api.h

Issue 11649053: Banish boilerplate. Profile-keyed API factory for extension API classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 12 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_EXTENSIONS_API_PROCESSES_PROCESSES_API_H__ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_PROCESSES_PROCESSES_API_H__
6 #define CHROME_BROWSER_EXTENSIONS_API_PROCESSES_PROCESSES_API_H__ 6 #define CHROME_BROWSER_EXTENSIONS_API_PROCESSES_PROCESSES_API_H__
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h"
12 #include "chrome/browser/extensions/event_router.h" 13 #include "chrome/browser/extensions/event_router.h"
13 #include "chrome/browser/extensions/extension_function.h" 14 #include "chrome/browser/extensions/extension_function.h"
14 #include "chrome/browser/profiles/profile_keyed_service.h" 15 #include "chrome/browser/profiles/profile_keyed_service.h"
15 #include "chrome/browser/task_manager/task_manager.h" 16 #include "chrome/browser/task_manager/task_manager.h"
16 #include "content/public/browser/notification_registrar.h" 17 #include "content/public/browser/notification_registrar.h"
17 #include "content/public/browser/render_process_host.h" 18 #include "content/public/browser/render_process_host.h"
18 #include "content/public/browser/render_widget_host.h" 19 #include "content/public/browser/render_widget_host.h"
19 20
20 class Profile; 21 class Profile;
21 22
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 virtual void OnListenerAdded(const EventListenerInfo& details) OVERRIDE; 110 virtual void OnListenerAdded(const EventListenerInfo& details) OVERRIDE;
110 virtual void OnListenerRemoved(const EventListenerInfo& details) OVERRIDE; 111 virtual void OnListenerRemoved(const EventListenerInfo& details) OVERRIDE;
111 112
112 private: 113 private:
113 Profile* profile_; 114 Profile* profile_;
114 115
115 // Created lazily on first access. 116 // Created lazily on first access.
116 scoped_ptr<ProcessesEventRouter> processes_event_router_; 117 scoped_ptr<ProcessesEventRouter> processes_event_router_;
117 }; 118 };
118 119
120 template <>
121 struct ProfileKeyedAPIFactoryTraits<ProcessesAPI>
122 : public DefaultProfileKeyedAPIFactoryTraits {
123 static const char* name() {
124 return "ProcessesAPI";
125 }
126
127 static const bool kServiceRedirectedInIncognito = true;
128 static const bool kServiceIsNULLWhileTesting = true;
129 };
130
119 // This extension function returns the Process object for the renderer process 131 // This extension function returns the Process object for the renderer process
120 // currently in use by the specified Tab. 132 // currently in use by the specified Tab.
121 class GetProcessIdForTabFunction : public AsyncExtensionFunction, 133 class GetProcessIdForTabFunction : public AsyncExtensionFunction,
122 public content::NotificationObserver { 134 public content::NotificationObserver {
123 public: 135 public:
124 GetProcessIdForTabFunction(); 136 GetProcessIdForTabFunction();
125 137
126 private: 138 private:
127 virtual ~GetProcessIdForTabFunction() {} 139 virtual ~GetProcessIdForTabFunction() {}
128 virtual bool RunImpl() OVERRIDE; 140 virtual bool RunImpl() OVERRIDE;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 #if defined(ENABLE_TASK_MANAGER) 208 #if defined(ENABLE_TASK_MANAGER)
197 bool memory_; 209 bool memory_;
198 #endif 210 #endif
199 211
200 DECLARE_EXTENSION_FUNCTION_NAME("experimental.processes.getProcessInfo") 212 DECLARE_EXTENSION_FUNCTION_NAME("experimental.processes.getProcessInfo")
201 }; 213 };
202 214
203 } // namespace extensions 215 } // namespace extensions
204 216
205 #endif // CHROME_BROWSER_EXTENSIONS_API_PROCESSES_PROCESSES_API_H__ 217 #endif // CHROME_BROWSER_EXTENSIONS_API_PROCESSES_PROCESSES_API_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698