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

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

Issue 12226022: <webview>: Store <webview> embedder info in ExtensionRendererState (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated comment on instance ID Created 7 years, 10 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_RENDERER_STATE_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_RENDERER_STATE_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_RENDERER_STATE_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_RENDERER_STATE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/memory/singleton.h" 13 #include "base/memory/singleton.h"
14 14
15 // This class keeps track of renderer state for use on the IO thread. All 15 // This class keeps track of renderer state for use on the IO thread. All
16 // methods should be called on the IO thread except for Init and Shutdown. 16 // methods should be called on the IO thread except for Init and Shutdown.
17 class ExtensionRendererState { 17 class ExtensionRendererState {
18 public: 18 public:
19 struct WebViewInfo {
20 int embedder_process_id;
21 int embedder_routing_id;
22 int web_view_instance_id;
23 };
24
19 static ExtensionRendererState* GetInstance(); 25 static ExtensionRendererState* GetInstance();
20 26
21 // These are called on the UI thread to start and stop listening to tab 27 // These are called on the UI thread to start and stop listening to tab
22 // notifications. 28 // notifications.
23 void Init(); 29 void Init();
24 void Shutdown(); 30 void Shutdown();
25 31
26 // Looks up whether the given render process is a guest renderer hosted by a 32 // Looks up the information for the embedder <webview> for a given render
27 // <webview>. 33 // view, if one exists. Called on the IO thread.
28 bool IsGuestProcess(int render_process_host_id); 34 bool GetWebViewInfo(int guest_process_id, int guest_routing_id,
35 WebViewInfo* web_view_info);
29 36
30 // Looks up the tab and window ID for a given render view. Returns true 37 // Looks up the tab and window ID for a given render view. Returns true
31 // if we have the IDs in our map. Called on the IO thread. 38 // if we have the IDs in our map. Called on the IO thread.
32 bool GetTabAndWindowId( 39 bool GetTabAndWindowId(
33 int render_process_host_id, int routing_id, int* tab_id, int* window_id); 40 int render_process_host_id, int routing_id, int* tab_id, int* window_id);
34 41
35 private: 42 private:
36 class TabObserver; 43 class TabObserver;
37 friend class TabObserver; 44 friend class TabObserver;
38 friend struct DefaultSingletonTraits<ExtensionRendererState>; 45 friend struct DefaultSingletonTraits<ExtensionRendererState>;
39 46
40 typedef std::pair<int, int> RenderId; 47 typedef std::pair<int, int> RenderId;
41 typedef std::pair<int, int> TabAndWindowId; 48 typedef std::pair<int, int> TabAndWindowId;
42 typedef std::map<RenderId, TabAndWindowId> TabAndWindowIdMap; 49 typedef std::map<RenderId, TabAndWindowId> TabAndWindowIdMap;
43 typedef std::set<int> ProcessIdGuestRenderProcessSet; 50 typedef std::map<RenderId, WebViewInfo> WebViewInfoMap;
44 51
45 ExtensionRendererState(); 52 ExtensionRendererState();
46 ~ExtensionRendererState(); 53 ~ExtensionRendererState();
47 54
48 // Adds or removes a render view from our map. 55 // Adds or removes a render view from our map.
49 void SetTabAndWindowId( 56 void SetTabAndWindowId(
50 int render_process_host_id, int routing_id, int tab_id, int window_id); 57 int render_process_host_id, int routing_id, int tab_id, int window_id);
51 void ClearTabAndWindowId( 58 void ClearTabAndWindowId(
52 int render_process_host_id, int routing_id); 59 int render_process_host_id, int routing_id);
53 60
54 // Adds or removes a <webview> guest render process from the set. 61 // Adds or removes a <webview> guest render process from the set.
55 void AddGuestProcess(int render_process_host_id); 62 void AddWebView(int render_process_host_id, int routing_id,
56 void RemoveGuestProcess(int render_process_host_id); 63 const WebViewInfo& web_view_info);
64 void RemoveWebView(int render_process_host_id, int routing_id);
57 65
58 TabObserver* observer_; 66 TabObserver* observer_;
59 TabAndWindowIdMap map_; 67 TabAndWindowIdMap map_;
60 ProcessIdGuestRenderProcessSet guest_set_; 68 WebViewInfoMap web_view_info_map_;
61 69
62 DISALLOW_COPY_AND_ASSIGN(ExtensionRendererState); 70 DISALLOW_COPY_AND_ASSIGN(ExtensionRendererState);
63 }; 71 };
64 72
65 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_RENDERER_STATE_H_ 73 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_RENDERER_STATE_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/web_request/web_request_api.cc ('k') | chrome/browser/extensions/extension_renderer_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698