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

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

Issue 257333002: Drive extension functions from ExtensionFunction::Run. The (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix comment Created 6 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 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
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 }; 132 };
133 133
134 // This extension function returns the Process object for the renderer process 134 // This extension function returns the Process object for the renderer process
135 // currently in use by the specified Tab. 135 // currently in use by the specified Tab.
136 class GetProcessIdForTabFunction : public ChromeAsyncExtensionFunction { 136 class GetProcessIdForTabFunction : public ChromeAsyncExtensionFunction {
137 public: 137 public:
138 GetProcessIdForTabFunction(); 138 GetProcessIdForTabFunction();
139 139
140 private: 140 private:
141 virtual ~GetProcessIdForTabFunction() {} 141 virtual ~GetProcessIdForTabFunction() {}
142 virtual bool RunImpl() OVERRIDE; 142 virtual bool RunAsync() OVERRIDE;
143 143
144 void GetProcessIdForTab(); 144 void GetProcessIdForTab();
145 145
146 // Storage for the tab ID parameter. 146 // Storage for the tab ID parameter.
147 int tab_id_; 147 int tab_id_;
148 148
149 DECLARE_EXTENSION_FUNCTION("processes.getProcessIdForTab", 149 DECLARE_EXTENSION_FUNCTION("processes.getProcessIdForTab",
150 PROCESSES_GETPROCESSIDFORTAB) 150 PROCESSES_GETPROCESSIDFORTAB)
151 }; 151 };
152 152
153 // Extension function that allows terminating Chrome subprocesses, by supplying 153 // Extension function that allows terminating Chrome subprocesses, by supplying
154 // the unique ID for the process coming from the ChildProcess ID pool. 154 // the unique ID for the process coming from the ChildProcess ID pool.
155 // Using unique IDs instead of OS process IDs allows two advantages: 155 // Using unique IDs instead of OS process IDs allows two advantages:
156 // * guaranteed uniqueness, since OS process IDs can be reused 156 // * guaranteed uniqueness, since OS process IDs can be reused
157 // * guards against killing non-Chrome processes 157 // * guards against killing non-Chrome processes
158 class TerminateFunction : public ChromeAsyncExtensionFunction { 158 class TerminateFunction : public ChromeAsyncExtensionFunction {
159 public: 159 public:
160 TerminateFunction(); 160 TerminateFunction();
161 161
162 private: 162 private:
163 virtual ~TerminateFunction() {} 163 virtual ~TerminateFunction() {}
164 virtual bool RunImpl() OVERRIDE; 164 virtual bool RunAsync() OVERRIDE;
165
166 165
167 void TerminateProcess(); 166 void TerminateProcess();
168 167
169 // Storage for the process ID parameter. 168 // Storage for the process ID parameter.
170 int process_id_; 169 int process_id_;
171 170
172 DECLARE_EXTENSION_FUNCTION("processes.terminate", 171 DECLARE_EXTENSION_FUNCTION("processes.terminate",
173 PROCESSES_TERMINATE) 172 PROCESSES_TERMINATE)
174 }; 173 };
175 174
176 // Extension function which returns a set of Process objects, containing the 175 // Extension function which returns a set of Process objects, containing the
177 // details corresponding to the process IDs supplied as input. 176 // details corresponding to the process IDs supplied as input.
178 class GetProcessInfoFunction : public ChromeAsyncExtensionFunction { 177 class GetProcessInfoFunction : public ChromeAsyncExtensionFunction {
179 public: 178 public:
180 GetProcessInfoFunction(); 179 GetProcessInfoFunction();
181 180
182 private: 181 private:
183 virtual ~GetProcessInfoFunction(); 182 virtual ~GetProcessInfoFunction();
184 virtual bool RunImpl() OVERRIDE; 183 virtual bool RunAsync() OVERRIDE;
185 184
186 void GatherProcessInfo(); 185 void GatherProcessInfo();
187 186
188 // Member variables to store the function parameters 187 // Member variables to store the function parameters
189 std::vector<int> process_ids_; 188 std::vector<int> process_ids_;
190 #if defined(ENABLE_TASK_MANAGER) 189 #if defined(ENABLE_TASK_MANAGER)
191 bool memory_; 190 bool memory_;
192 #endif 191 #endif
193 192
194 DECLARE_EXTENSION_FUNCTION("processes.getProcessInfo", 193 DECLARE_EXTENSION_FUNCTION("processes.getProcessInfo",
195 PROCESSES_GETPROCESSINFO) 194 PROCESSES_GETPROCESSINFO)
196 }; 195 };
197 196
198 } // namespace extensions 197 } // namespace extensions
199 198
200 #endif // CHROME_BROWSER_EXTENSIONS_API_PROCESSES_PROCESSES_API_H__ 199 #endif // CHROME_BROWSER_EXTENSIONS_API_PROCESSES_PROCESSES_API_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698