OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 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 CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_CHANNEL_MANAGER_H_ | |
6 #define CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_CHANNEL_MANAGER_H_ | |
7 #pragma once | |
8 | |
9 #include <set> | |
10 | |
11 #include "base/id_map.h" | |
12 #include "content/public/renderer/render_process_observer.h" | |
13 #include "content/renderer/browser_plugin/guest_to_embedder_channel.h" | |
14 #include "content/renderer/render_view_impl.h" | |
15 | |
16 class GuestToEmbedderChannel; | |
17 struct ViewMsg_New_Params; | |
18 | |
19 namespace content { | |
20 | |
21 // BrowserPluginChannelManager manages the lifetime of GuestToEmbedderChannels. | |
22 // When a new RenderView is requested, it checks the embedder channel name | |
23 // in ViewMsg_New_Params and decides whether to reuse an existing channel or | |
24 // create a new channel. On the guest renderer process, it informs a | |
25 // RenderView once a channel has been established with its embedder. | |
26 // On the embedder side, it tells BrowserPlugin to load the guest | |
27 // PluginInstance once a channel has been established. | |
28 class BrowserPluginChannelManager | |
29 : public RenderProcessObserver { | |
30 public: | |
31 BrowserPluginChannelManager(); | |
32 | |
33 virtual ~BrowserPluginChannelManager(); | |
34 | |
35 void CreateRenderView(const ViewMsg_New_Params& params); | |
36 | |
37 void ReportChannelToEmbedder( | |
38 RenderViewImpl* render_view, | |
39 const IPC::ChannelHandle& embedder_channel_handle, | |
40 const std::string& embedder_channel_name, | |
41 int embedder_container_id); | |
42 | |
43 // Get the GuestToEmbedderChannel associated with the given | |
44 // embedder_channel_name. | |
45 GuestToEmbedderChannel* GetChannelByName( | |
46 const std::string& embedder_channel_name); | |
47 | |
48 // Remove the pointer to the GuestToEmbedderChannel associated with the given | |
49 // routing_id. | |
50 void RemoveChannelByName(const std::string& embedder_channel_name); | |
51 | |
52 void GuestReady(PP_Instance instance, | |
53 const std::string& embedder_channel_name, | |
54 int embedder_container_id); | |
55 | |
56 private: | |
57 typedef std::map<std::string, scoped_refptr<GuestToEmbedderChannel> > | |
58 EmbedderChannelNameToChannelMap; | |
59 | |
60 void OnLoadGuest(int instance_id, | |
61 int guest_renderer_id, | |
62 const IPC::ChannelHandle& channel_handle); | |
63 void OnAdvanceFocus(int instance_id, bool reverse); | |
64 | |
65 // RenderProcessObserver override. Call on render thread. | |
66 virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE; | |
67 | |
68 // Map from Host process ID to GuestToEmbedderChannel | |
69 EmbedderChannelNameToChannelMap embedder_channels_; | |
70 | |
71 // Map from <embedder_channel_name, embedder_container_id> to RenderViewImpl | |
72 // that points to RenderViewImpl guests that have been constructed but don't | |
73 // have a PP_Instance and so they aren't yet ready to composite. | |
74 std::map<std::pair<std::string, int>, | |
75 base::WeakPtr<RenderViewImpl> > pending_guests_; | |
76 | |
77 DISALLOW_COPY_AND_ASSIGN(BrowserPluginChannelManager); | |
78 }; | |
79 | |
80 } // namespace content | |
81 | |
82 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_CHANNEL_MANAGER_H_ | |
OLD | NEW |