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_EXTENSION_PROCESSES_API_H__ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESSES_API_H__ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESSES_API_H__ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESSES_API_H__ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "chrome/browser/extensions/extension_function.h" | 11 #include "chrome/browser/extensions/extension_function.h" |
12 #include "chrome/browser/task_manager/task_manager.h" | 12 #include "chrome/browser/task_manager/task_manager.h" |
13 #include "content/public/browser/notification_registrar.h" | 13 #include "content/public/browser/notification_registrar.h" |
14 #include "content/public/browser/render_process_host.h" | 14 #include "content/public/browser/render_process_host.h" |
15 #include "content/public/browser/render_widget_host.h" | 15 #include "content/public/browser/render_widget_host.h" |
16 | 16 |
| 17 namespace base { |
| 18 class ListValue; |
| 19 } |
| 20 |
17 // Observes the Task Manager and routes the notifications as events to the | 21 // Observes the Task Manager and routes the notifications as events to the |
18 // extension system. | 22 // extension system. |
19 class ExtensionProcessesEventRouter : public TaskManagerModelObserver, | 23 class ExtensionProcessesEventRouter : public TaskManagerModelObserver, |
20 public content::NotificationObserver { | 24 public content::NotificationObserver { |
21 public: | 25 public: |
22 // Single instance of the event router. | 26 // Single instance of the event router. |
23 static ExtensionProcessesEventRouter* GetInstance(); | 27 static ExtensionProcessesEventRouter* GetInstance(); |
24 | 28 |
25 // Safe to call multiple times. | 29 // Safe to call multiple times. |
26 void ObserveProfile(Profile* profile); | 30 void ObserveProfile(Profile* profile); |
(...skipping 29 matching lines...) Expand all Loading... |
56 virtual void OnItemsChanged(int start, int length) OVERRIDE; | 60 virtual void OnItemsChanged(int start, int length) OVERRIDE; |
57 virtual void OnItemsRemoved(int start, int length) OVERRIDE {} | 61 virtual void OnItemsRemoved(int start, int length) OVERRIDE {} |
58 virtual void OnItemsToBeRemoved(int start, int length) OVERRIDE; | 62 virtual void OnItemsToBeRemoved(int start, int length) OVERRIDE; |
59 | 63 |
60 // Internal helpers for processing notifications. | 64 // Internal helpers for processing notifications. |
61 void ProcessHangEvent(content::RenderWidgetHost* widget); | 65 void ProcessHangEvent(content::RenderWidgetHost* widget); |
62 void ProcessClosedEvent( | 66 void ProcessClosedEvent( |
63 content::RenderProcessHost* rph, | 67 content::RenderProcessHost* rph, |
64 content::RenderProcessHost::RendererClosedDetails* details); | 68 content::RenderProcessHost::RendererClosedDetails* details); |
65 | 69 |
66 void NotifyProfiles(const char* event_name, std::string json_args); | 70 void NotifyProfiles(const char* event_name, |
| 71 scoped_ptr<base::ListValue> event_args); |
67 | 72 |
68 void DispatchEvent(Profile* profile, | 73 void DispatchEvent(Profile* profile, |
69 const char* event_name, | 74 const char* event_name, |
70 const std::string& json_args); | 75 scoped_ptr<base::ListValue> event_args); |
71 | 76 |
72 // Determines whether there is a registered listener for the specified event. | 77 // Determines whether there is a registered listener for the specified event. |
73 // It helps to avoid collecing data if no one is interested in it. | 78 // It helps to avoid collecing data if no one is interested in it. |
74 bool HasEventListeners(std::string& event_name); | 79 bool HasEventListeners(std::string& event_name); |
75 | 80 |
76 // Used for tracking registrations to process related notifications. | 81 // Used for tracking registrations to process related notifications. |
77 content::NotificationRegistrar registrar_; | 82 content::NotificationRegistrar registrar_; |
78 | 83 |
79 // Registered profiles. | 84 // Registered profiles. |
80 typedef std::set<Profile*> ProfileSet; | 85 typedef std::set<Profile*> ProfileSet; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 content::NotificationRegistrar registrar_; | 169 content::NotificationRegistrar registrar_; |
165 | 170 |
166 // Member variables to store the function parameters | 171 // Member variables to store the function parameters |
167 std::vector<int> process_ids_; | 172 std::vector<int> process_ids_; |
168 bool memory_; | 173 bool memory_; |
169 | 174 |
170 DECLARE_EXTENSION_FUNCTION_NAME("experimental.processes.getProcessInfo") | 175 DECLARE_EXTENSION_FUNCTION_NAME("experimental.processes.getProcessInfo") |
171 }; | 176 }; |
172 | 177 |
173 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESSES_API_H__ | 178 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESSES_API_H__ |
OLD | NEW |