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