| 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 const content::NotificationSource& source, | 145 const content::NotificationSource& source, |
| 146 const content::NotificationDetails& details) OVERRIDE; | 146 const content::NotificationDetails& details) OVERRIDE; |
| 147 | 147 |
| 148 void GetProcessIdForTab(); | 148 void GetProcessIdForTab(); |
| 149 | 149 |
| 150 content::NotificationRegistrar registrar_; | 150 content::NotificationRegistrar registrar_; |
| 151 | 151 |
| 152 // Storage for the tab ID parameter. | 152 // Storage for the tab ID parameter. |
| 153 int tab_id_; | 153 int tab_id_; |
| 154 | 154 |
| 155 DECLARE_EXTENSION_FUNCTION("experimental.processes.getProcessIdForTab", | 155 DECLARE_EXTENSION_FUNCTION("processes.getProcessIdForTab", |
| 156 EXPERIMENTAL_PROCESSES_GETPROCESSIDFORTAB) | 156 PROCESSES_GETPROCESSIDFORTAB) |
| 157 }; | 157 }; |
| 158 | 158 |
| 159 // Extension function that allows terminating Chrome subprocesses, by supplying | 159 // Extension function that allows terminating Chrome subprocesses, by supplying |
| 160 // the unique ID for the process coming from the ChildProcess ID pool. | 160 // the unique ID for the process coming from the ChildProcess ID pool. |
| 161 // Using unique IDs instead of OS process IDs allows two advantages: | 161 // Using unique IDs instead of OS process IDs allows two advantages: |
| 162 // * guaranteed uniqueness, since OS process IDs can be reused | 162 // * guaranteed uniqueness, since OS process IDs can be reused |
| 163 // * guards against killing non-Chrome processes | 163 // * guards against killing non-Chrome processes |
| 164 class TerminateFunction : public AsyncExtensionFunction, | 164 class TerminateFunction : public AsyncExtensionFunction, |
| 165 public content::NotificationObserver { | 165 public content::NotificationObserver { |
| 166 public: | 166 public: |
| 167 TerminateFunction(); | 167 TerminateFunction(); |
| 168 | 168 |
| 169 private: | 169 private: |
| 170 virtual ~TerminateFunction() {} | 170 virtual ~TerminateFunction() {} |
| 171 virtual bool RunImpl() OVERRIDE; | 171 virtual bool RunImpl() OVERRIDE; |
| 172 | 172 |
| 173 // content::NotificationObserver implementation. | 173 // content::NotificationObserver implementation. |
| 174 virtual void Observe(int type, | 174 virtual void Observe(int type, |
| 175 const content::NotificationSource& source, | 175 const content::NotificationSource& source, |
| 176 const content::NotificationDetails& details) OVERRIDE; | 176 const content::NotificationDetails& details) OVERRIDE; |
| 177 | 177 |
| 178 void TerminateProcess(); | 178 void TerminateProcess(); |
| 179 | 179 |
| 180 content::NotificationRegistrar registrar_; | 180 content::NotificationRegistrar registrar_; |
| 181 | 181 |
| 182 // Storage for the process ID parameter. | 182 // Storage for the process ID parameter. |
| 183 int process_id_; | 183 int process_id_; |
| 184 | 184 |
| 185 DECLARE_EXTENSION_FUNCTION("experimental.processes.terminate", | 185 DECLARE_EXTENSION_FUNCTION("processes.terminate", |
| 186 EXPERIMENTAL_PROCESSES_TERMINATE) | 186 PROCESSES_TERMINATE) |
| 187 }; | 187 }; |
| 188 | 188 |
| 189 // Extension function which returns a set of Process objects, containing the | 189 // Extension function which returns a set of Process objects, containing the |
| 190 // details corresponding to the process IDs supplied as input. | 190 // details corresponding to the process IDs supplied as input. |
| 191 class GetProcessInfoFunction : public AsyncExtensionFunction, | 191 class GetProcessInfoFunction : public AsyncExtensionFunction, |
| 192 public content::NotificationObserver { | 192 public content::NotificationObserver { |
| 193 public: | 193 public: |
| 194 GetProcessInfoFunction(); | 194 GetProcessInfoFunction(); |
| 195 | 195 |
| 196 private: | 196 private: |
| 197 virtual ~GetProcessInfoFunction(); | 197 virtual ~GetProcessInfoFunction(); |
| 198 virtual bool RunImpl() OVERRIDE; | 198 virtual bool RunImpl() OVERRIDE; |
| 199 | 199 |
| 200 // content::NotificationObserver implementation. | 200 // content::NotificationObserver implementation. |
| 201 virtual void Observe(int type, | 201 virtual void Observe(int type, |
| 202 const content::NotificationSource& source, | 202 const content::NotificationSource& source, |
| 203 const content::NotificationDetails& details) OVERRIDE; | 203 const content::NotificationDetails& details) OVERRIDE; |
| 204 | 204 |
| 205 void GatherProcessInfo(); | 205 void GatherProcessInfo(); |
| 206 | 206 |
| 207 content::NotificationRegistrar registrar_; | 207 content::NotificationRegistrar registrar_; |
| 208 | 208 |
| 209 // Member variables to store the function parameters | 209 // Member variables to store the function parameters |
| 210 std::vector<int> process_ids_; | 210 std::vector<int> process_ids_; |
| 211 #if defined(ENABLE_TASK_MANAGER) | 211 #if defined(ENABLE_TASK_MANAGER) |
| 212 bool memory_; | 212 bool memory_; |
| 213 #endif | 213 #endif |
| 214 | 214 |
| 215 DECLARE_EXTENSION_FUNCTION("experimental.processes.getProcessInfo", | 215 DECLARE_EXTENSION_FUNCTION("processes.getProcessInfo", |
| 216 EXPERIMENTAL_PROCESSES_GETPROCESSINFO) | 216 PROCESSES_GETPROCESSINFO) |
| 217 }; | 217 }; |
| 218 | 218 |
| 219 } // namespace extensions | 219 } // namespace extensions |
| 220 | 220 |
| 221 #endif // CHROME_BROWSER_EXTENSIONS_API_PROCESSES_PROCESSES_API_H__ | 221 #endif // CHROME_BROWSER_EXTENSIONS_API_PROCESSES_PROCESSES_API_H__ |
| OLD | NEW |