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

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

Issue 159882: Implements extensions devtools API (Closed)
Patch Set: Fixes flakiness in tests by grabbing tab ID in C++ land and passing it down Created 11 years, 4 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
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_DEVTOOLS_MANAGER_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_DEVTOOLS_MANAGER_H_
7
8 #include <map>
9 #include <set>
10 #include <string>
11 #include "base/linked_ptr.h"
12 #include "base/ref_counted.h"
13
14 class ExtensionDevToolsBridge;
15 class MessageLoop;
16 class Profile;
17
18 // This class manages the lifetimes of ExtensionDevToolsBridge objects.
19 // The manager is owned by the Profile.
20 //
21 // The lifetime of an ExtensionDevToolsBridge object is determined by:
22 // * the existence of registered event handlers for the bridge's tab
23 // * the lifetime of the inspected tab
24 //
25 // The manager is alerted whenever an event listener is added or removed and
26 // keeps track of the set of renderers with event listeners registered for each
27 // tab. A new bridge object is created for a tab when the first event listener
28 // is registered on that tab. A bridge object is destroyed when all event
29 // listeners are removed, the inspected tab closes, or when the manager itself
30 // is destroyed.
31
32 class ExtensionDevToolsManager
33 : public base::RefCountedThreadSafe<ExtensionDevToolsManager> {
34 public:
35 // UI thread only:
36 explicit ExtensionDevToolsManager(Profile* profile);
37 ~ExtensionDevToolsManager();
38
39 void AddEventListener(const std::string& event_name,
40 int render_process_id);
41
42 void RemoveEventListener(const std::string& event_name,
43 int render_process_id);
44
45 void BridgeClosingForTab(int tab_id);
46
47 private:
48
49 // Map of tab IDs to the ExtensionDevToolsBridge connected to the tab
50 std::map<int, linked_ptr<ExtensionDevToolsBridge> > tab_id_to_bridge_;
51
52 // Map of tab IDs to the set of render_process_ids that have registered
53 // event handlers for the tab.
54 std::map<int, std::set<int> > tab_id_to_render_process_ids_;
55
56 Profile* profile_;
57 MessageLoop* ui_loop_;
58
59 DISALLOW_COPY_AND_ASSIGN(ExtensionDevToolsManager);
60 };
61
62 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_DEVTOOLS_MANAGER_H_
63
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_devtools_events.cc ('k') | chrome/browser/extensions/extension_devtools_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698