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

Unified Diff: chrome/browser/extensions/extension_processes_api.h

Issue 3597016: Expands the chrome.experimental.processes extension API.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_processes_api.h
===================================================================
--- chrome/browser/extensions/extension_processes_api.h (revision 61514)
+++ chrome/browser/extensions/extension_processes_api.h (working copy)
@@ -6,14 +6,72 @@
#define CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESSES_API_H__
#pragma once
+#include <set>
+#include <string>
+
#include "chrome/browser/extensions/extension_function.h"
+#include "chrome/browser/task_manager/task_manager.h"
+#include "chrome/common/notification_observer.h"
+#include "chrome/common/notification_registrar.h"
+// Observes the Task Manager and routes the notifications as events to the
+// extension system.
+class ExtensionProcessesEventRouter : public TaskManagerModelObserver {
+ public:
+ // Single instance of the event router.
+ static ExtensionProcessesEventRouter* GetInstance();
+
+ // Safe to call multiple times.
+ void ObserveProfile(Profile* profile);
+
+ // Called when an extension process wants to listen to process events.
+ void ListenerAdded();
+
+ // Called when an extension process with a listener exits or removes it.
+ void ListenerRemoved();
+
+ private:
+ friend struct DefaultSingletonTraits<ExtensionProcessesEventRouter>;
+
+ ExtensionProcessesEventRouter();
+ virtual ~ExtensionProcessesEventRouter();
+
+ // TaskManagerModelObserver::OnModelChanged.
+ virtual void OnModelChanged() {}
+
+ // TaskManagerModelObserver::OnItemsChanged.
+ virtual void OnItemsChanged(int start, int length);
+
+ // TaskManagerModelObserver::OnItemsAdded.
+ virtual void OnItemsAdded(int start, int length) {}
+
+ // TaskManagerModelObserver::OnItemsRemoved.
+ virtual void OnItemsRemoved(int start, int length) {}
+
+ void DispatchEvent(Profile* profile,
+ const char* event_name,
+ const std::string& json_args);
+
+ // Used for tracking registrations to process related notifications.
+ NotificationRegistrar registrar_;
+
+ // Registered profiles.
+ typedef std::set<Profile*> ProfileSet;
+ ProfileSet profiles_;
+
+ // TaskManager to observe for updates.
+ TaskManagerModel* model_;
+
+ DISALLOW_COPY_AND_ASSIGN(ExtensionProcessesEventRouter);
+};
+
+
// This extension function returns the Process object for the renderer process
// currently in use by the specified Tab.
class GetProcessForTabFunction : public SyncExtensionFunction {
virtual ~GetProcessForTabFunction() {}
virtual bool RunImpl();
- DECLARE_EXTENSION_FUNCTION_NAME("experimental.processes.getProcessForTab")
+ DECLARE_EXTENSION_FUNCTION_NAME("experimental.processes.getProcessIdForTab")
};
#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESSES_API_H__
« no previous file with comments | « chrome/browser/extensions/extension_message_service.cc ('k') | chrome/browser/extensions/extension_processes_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698