| OLD | NEW |
| 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 namespace chrome { | |
| 16 class WebViewGuest; | 15 class WebViewGuest; |
| 17 } // namespace chrome | |
| 18 | 16 |
| 19 // This class keeps track of renderer state for use on the IO thread. All | 17 // This class keeps track of renderer state for use on the IO thread. All |
| 20 // methods should be called on the IO thread except for Init and Shutdown. | 18 // methods should be called on the IO thread except for Init and Shutdown. |
| 21 class ExtensionRendererState { | 19 class ExtensionRendererState { |
| 22 public: | 20 public: |
| 23 struct WebViewInfo { | 21 struct WebViewInfo { |
| 24 int embedder_process_id; | 22 int embedder_process_id; |
| 25 int embedder_routing_id; | 23 int embedder_routing_id; |
| 26 int guest_instance_id; | 24 int guest_instance_id; |
| 27 int instance_id; | 25 int instance_id; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 41 | 39 |
| 42 // Looks up the tab and window ID for a given render view. Returns true | 40 // Looks up the tab and window ID for a given render view. Returns true |
| 43 // if we have the IDs in our map. Called on the IO thread. | 41 // if we have the IDs in our map. Called on the IO thread. |
| 44 bool GetTabAndWindowId( | 42 bool GetTabAndWindowId( |
| 45 int render_process_host_id, int routing_id, int* tab_id, int* window_id); | 43 int render_process_host_id, int routing_id, int* tab_id, int* window_id); |
| 46 | 44 |
| 47 private: | 45 private: |
| 48 class RenderViewHostObserver; | 46 class RenderViewHostObserver; |
| 49 class TabObserver; | 47 class TabObserver; |
| 50 friend class TabObserver; | 48 friend class TabObserver; |
| 51 friend class chrome::WebViewGuest; | 49 friend class WebViewGuest; |
| 52 friend struct DefaultSingletonTraits<ExtensionRendererState>; | 50 friend struct DefaultSingletonTraits<ExtensionRendererState>; |
| 53 | 51 |
| 54 typedef std::pair<int, int> RenderId; | 52 typedef std::pair<int, int> RenderId; |
| 55 typedef std::pair<int, int> TabAndWindowId; | 53 typedef std::pair<int, int> TabAndWindowId; |
| 56 typedef std::map<RenderId, TabAndWindowId> TabAndWindowIdMap; | 54 typedef std::map<RenderId, TabAndWindowId> TabAndWindowIdMap; |
| 57 typedef std::map<RenderId, WebViewInfo> WebViewInfoMap; | 55 typedef std::map<RenderId, WebViewInfo> WebViewInfoMap; |
| 58 | 56 |
| 59 ExtensionRendererState(); | 57 ExtensionRendererState(); |
| 60 ~ExtensionRendererState(); | 58 ~ExtensionRendererState(); |
| 61 | 59 |
| 62 // Adds or removes a render view from our map. | 60 // Adds or removes a render view from our map. |
| 63 void SetTabAndWindowId( | 61 void SetTabAndWindowId( |
| 64 int render_process_host_id, int routing_id, int tab_id, int window_id); | 62 int render_process_host_id, int routing_id, int tab_id, int window_id); |
| 65 void ClearTabAndWindowId( | 63 void ClearTabAndWindowId( |
| 66 int render_process_host_id, int routing_id); | 64 int render_process_host_id, int routing_id); |
| 67 | 65 |
| 68 // Adds or removes a <webview> guest render process from the set. | 66 // Adds or removes a <webview> guest render process from the set. |
| 69 void AddWebView(int render_process_host_id, int routing_id, | 67 void AddWebView(int render_process_host_id, int routing_id, |
| 70 const WebViewInfo& webview_info); | 68 const WebViewInfo& webview_info); |
| 71 void RemoveWebView(int render_process_host_id, int routing_id); | 69 void RemoveWebView(int render_process_host_id, int routing_id); |
| 72 | 70 |
| 73 TabObserver* observer_; | 71 TabObserver* observer_; |
| 74 TabAndWindowIdMap map_; | 72 TabAndWindowIdMap map_; |
| 75 WebViewInfoMap webview_info_map_; | 73 WebViewInfoMap webview_info_map_; |
| 76 | 74 |
| 77 DISALLOW_COPY_AND_ASSIGN(ExtensionRendererState); | 75 DISALLOW_COPY_AND_ASSIGN(ExtensionRendererState); |
| 78 }; | 76 }; |
| 79 | 77 |
| 80 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_RENDERER_STATE_H_ | 78 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_RENDERER_STATE_H_ |
| OLD | NEW |