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

Side by Side Diff: chrome/browser/extensions/extension_processes_api.h

Issue 3801008: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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>
10 #include <string>
11
9 #include "chrome/browser/extensions/extension_function.h" 12 #include "chrome/browser/extensions/extension_function.h"
13 #include "chrome/browser/task_manager/task_manager.h"
14 #include "chrome/common/notification_observer.h"
15 #include "chrome/common/notification_registrar.h"
16
17 // Observes the Task Manager and routes the notifications as events to the
18 // extension system.
19 class ExtensionProcessesEventRouter : public TaskManagerModelObserver {
20 public:
21 // Single instance of the event router.
22 static ExtensionProcessesEventRouter* GetInstance();
23
24 // Safe to call multiple times.
25 void ObserveProfile(Profile* profile);
26
27 // Called when an extension process wants to listen to process events.
28 void ListenerAdded();
29
30 // Called when an extension process with a listener exits or removes it.
31 void ListenerRemoved();
32
33 private:
34 friend struct DefaultSingletonTraits<ExtensionProcessesEventRouter>;
35
36 ExtensionProcessesEventRouter();
37 virtual ~ExtensionProcessesEventRouter();
38
39 // TaskManagerModelObserver methods.
40 virtual void OnModelChanged() {}
41 virtual void OnItemsChanged(int start, int length);
42 virtual void OnItemsAdded(int start, int length) {}
43 virtual void OnItemsRemoved(int start, int length) {}
44
45 void DispatchEvent(Profile* profile,
46 const char* event_name,
47 const std::string& json_args);
48
49 // Used for tracking registrations to process related notifications.
50 NotificationRegistrar registrar_;
51
52 // Registered profiles.
53 typedef std::set<Profile*> ProfileSet;
54 ProfileSet profiles_;
55
56 // TaskManager to observe for updates.
57 TaskManagerModel* model_;
58
59 DISALLOW_COPY_AND_ASSIGN(ExtensionProcessesEventRouter);
60 };
61
10 62
11 // This extension function returns the Process object for the renderer process 63 // This extension function returns the Process object for the renderer process
12 // currently in use by the specified Tab. 64 // currently in use by the specified Tab.
13 class GetProcessForTabFunction : public SyncExtensionFunction { 65 class GetProcessIdForTabFunction : public SyncExtensionFunction {
14 virtual ~GetProcessForTabFunction() {} 66 virtual ~GetProcessIdForTabFunction() {}
15 virtual bool RunImpl(); 67 virtual bool RunImpl();
16 DECLARE_EXTENSION_FUNCTION_NAME("experimental.processes.getProcessForTab") 68 DECLARE_EXTENSION_FUNCTION_NAME("experimental.processes.getProcessIdForTab")
17 }; 69 };
18 70
19 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESSES_API_H__ 71 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESSES_API_H__
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_function_dispatcher.cc ('k') | chrome/browser/extensions/extension_processes_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698