OLD | NEW |
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 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 // The profile-keyed service that manages the processes extension API. | 94 // The profile-keyed service that manages the processes extension API. |
95 class ProcessesAPI : public ProfileKeyedAPI, | 95 class ProcessesAPI : public ProfileKeyedAPI, |
96 public EventRouter::Observer { | 96 public EventRouter::Observer { |
97 public: | 97 public: |
98 explicit ProcessesAPI(Profile* profile); | 98 explicit ProcessesAPI(Profile* profile); |
99 virtual ~ProcessesAPI(); | 99 virtual ~ProcessesAPI(); |
100 | 100 |
101 // ProfileKeyedService implementation. | 101 // ProfileKeyedService implementation. |
102 virtual void Shutdown() OVERRIDE; | 102 virtual void Shutdown() OVERRIDE; |
103 | 103 |
| 104 // ProfileKeyedAPI implementation. |
| 105 static ProfileKeyedAPIFactory<ProcessesAPI>* GetFactoryInstance(); |
| 106 |
104 // Convenience method to get the ProcessesAPI for a profile. | 107 // Convenience method to get the ProcessesAPI for a profile. |
105 static ProcessesAPI* Get(Profile* profile); | 108 static ProcessesAPI* Get(Profile* profile); |
106 | 109 |
107 ProcessesEventRouter* processes_event_router(); | 110 ProcessesEventRouter* processes_event_router(); |
108 | 111 |
109 // EventRouter::Observer implementation. | 112 // EventRouter::Observer implementation. |
110 virtual void OnListenerAdded(const EventListenerInfo& details) OVERRIDE; | 113 virtual void OnListenerAdded(const EventListenerInfo& details) OVERRIDE; |
111 virtual void OnListenerRemoved(const EventListenerInfo& details) OVERRIDE; | 114 virtual void OnListenerRemoved(const EventListenerInfo& details) OVERRIDE; |
112 | 115 |
113 private: | 116 private: |
114 friend class ProfileKeyedAPIFactory<ProcessesAPI>; | 117 friend class ProfileKeyedAPIFactory<ProcessesAPI>; |
115 | 118 |
116 Profile* profile_; | 119 Profile* profile_; |
117 | 120 |
118 // ProfileKeyedAPI implementation. | 121 // ProfileKeyedAPI implementation. |
119 static const char* service_name() { | 122 static const char* service_name() { |
120 return "ProcessesAPI"; | 123 return "ProcessesAPI"; |
121 } | 124 } |
122 static const bool kServiceRedirectedInIncognito = true; | 125 static const bool kServiceRedirectedInIncognito = true; |
123 static const bool kServiceIsNULLWhileTesting = true; | 126 static const bool kServiceIsNULLWhileTesting = true; |
124 | 127 |
125 // Created lazily on first access. | 128 // Created lazily on first access. |
126 scoped_ptr<ProcessesEventRouter> processes_event_router_; | 129 scoped_ptr<ProcessesEventRouter> processes_event_router_; |
127 }; | 130 }; |
128 | 131 |
129 template <> | |
130 ProfileKeyedAPIFactory<ProcessesAPI>* | |
131 ProfileKeyedAPIFactory<ProcessesAPI>::GetInstance(); | |
132 | |
133 // This extension function returns the Process object for the renderer process | 132 // This extension function returns the Process object for the renderer process |
134 // currently in use by the specified Tab. | 133 // currently in use by the specified Tab. |
135 class GetProcessIdForTabFunction : public AsyncExtensionFunction, | 134 class GetProcessIdForTabFunction : public AsyncExtensionFunction, |
136 public content::NotificationObserver { | 135 public content::NotificationObserver { |
137 public: | 136 public: |
138 GetProcessIdForTabFunction(); | 137 GetProcessIdForTabFunction(); |
139 | 138 |
140 private: | 139 private: |
141 virtual ~GetProcessIdForTabFunction() {} | 140 virtual ~GetProcessIdForTabFunction() {} |
142 virtual bool RunImpl() OVERRIDE; | 141 virtual bool RunImpl() OVERRIDE; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 #if defined(ENABLE_TASK_MANAGER) | 209 #if defined(ENABLE_TASK_MANAGER) |
211 bool memory_; | 210 bool memory_; |
212 #endif | 211 #endif |
213 | 212 |
214 DECLARE_EXTENSION_FUNCTION_NAME("experimental.processes.getProcessInfo") | 213 DECLARE_EXTENSION_FUNCTION_NAME("experimental.processes.getProcessInfo") |
215 }; | 214 }; |
216 | 215 |
217 } // namespace extensions | 216 } // namespace extensions |
218 | 217 |
219 #endif // CHROME_BROWSER_EXTENSIONS_API_PROCESSES_PROCESSES_API_H__ | 218 #endif // CHROME_BROWSER_EXTENSIONS_API_PROCESSES_PROCESSES_API_H__ |
OLD | NEW |