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 // Get the GuestToEmbedderChannel associated with the given |
| 38 // embedder_channel_name. |
| 39 GuestToEmbedderChannel* GetChannelByName( |
| 40 const std::string& embedder_channel_name); |
| 41 |
| 42 // Remove the pointer to the GuestToEmbedderChannel associated with the given |
| 43 // routing_id. |
| 44 void RemoveChannelByName(const std::string& embedder_channel_name); |
| 45 |
| 46 private: |
| 47 typedef std::map<std::string, scoped_refptr<GuestToEmbedderChannel> > |
| 48 EmbedderChannelNameToChannelMap; |
| 49 |
| 50 void OnCompleteNavigation(int guest_routing_id, |
| 51 PP_Instance instance); |
| 52 |
| 53 void OnLoadGuest(int instance_id, |
| 54 int guest_renderer_id, |
| 55 const IPC::ChannelHandle& channel_handle); |
| 56 |
| 57 // RenderProcessObserver override. Call on render thread. |
| 58 virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE; |
| 59 |
| 60 // Map from Host process ID to GuestToEmbedderChannel |
| 61 EmbedderChannelNameToChannelMap embedder_channels_; |
| 62 |
| 63 // Map from Routing ID to RenderViewImpl that points to RenderViewImpl |
| 64 // guests that have been constructed but don't have a PP_Instance and |
| 65 // so they aren't yet ready to composite. |
| 66 std::map<int, base::WeakPtr<RenderViewImpl> > pending_guests_; |
| 67 |
| 68 DISALLOW_COPY_AND_ASSIGN(BrowserPluginChannelManager); |
| 69 }; |
| 70 |
| 71 } // namespace content |
| 72 |
| 73 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_CHANNEL_MANAGER_H_ |
OLD | NEW |