OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 CONTENT_BROWSER_RENDERER_HOST_PEPPER_BROWSER_PPAPI_HOST_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_PEPPER_BROWSER_PPAPI_HOST_IMPL_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_PEPPER_BROWSER_PPAPI_HOST_IMPL_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_PEPPER_BROWSER_PPAPI_HOST_IMPL_H_ |
7 | 7 |
| 8 #include <map> |
| 9 |
8 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
10 #include "content/browser/renderer_host/pepper/content_browser_pepper_host_facto
ry.h" | 12 #include "content/browser/renderer_host/pepper/content_browser_pepper_host_facto
ry.h" |
11 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
12 #include "content/public/browser/browser_ppapi_host.h" | 14 #include "content/public/browser/browser_ppapi_host.h" |
13 #include "ipc/ipc_channel_proxy.h" | 15 #include "ipc/ipc_channel_proxy.h" |
14 #include "ppapi/host/ppapi_host.h" | 16 #include "ppapi/host/ppapi_host.h" |
15 | 17 |
16 namespace IPC { | 18 namespace IPC { |
17 class Sender; | 19 class Sender; |
(...skipping 10 matching lines...) Expand all Loading... |
28 // when this object is created). | 30 // when this object is created). |
29 BrowserPpapiHostImpl(IPC::Sender* sender, | 31 BrowserPpapiHostImpl(IPC::Sender* sender, |
30 const ppapi::PpapiPermissions& permissions); | 32 const ppapi::PpapiPermissions& permissions); |
31 | 33 |
32 // IPC::ChannelProxy::MessageFilter. | 34 // IPC::ChannelProxy::MessageFilter. |
33 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; | 35 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; |
34 | 36 |
35 // BrowserPpapiHost. | 37 // BrowserPpapiHost. |
36 virtual ppapi::host::PpapiHost* GetPpapiHost() OVERRIDE; | 38 virtual ppapi::host::PpapiHost* GetPpapiHost() OVERRIDE; |
37 virtual base::ProcessHandle GetPluginProcessHandle() const OVERRIDE; | 39 virtual base::ProcessHandle GetPluginProcessHandle() const OVERRIDE; |
| 40 virtual bool IsValidInstance(PP_Instance instance) const OVERRIDE; |
| 41 virtual bool GetRenderViewIDsForInstance(PP_Instance instance, |
| 42 int* render_process_id, |
| 43 int* render_view_id) const OVERRIDE; |
38 | 44 |
39 void set_plugin_process_handle(base::ProcessHandle handle) { | 45 void set_plugin_process_handle(base::ProcessHandle handle) { |
40 plugin_process_handle_ = handle; | 46 plugin_process_handle_ = handle; |
41 } | 47 } |
42 | 48 |
| 49 // These two functions are notifications that an instance has been created |
| 50 // or destroyed. They allow us to maintain a mapping of PP_Instance to view |
| 51 // IDs in the browser process. |
| 52 void AddInstanceForView(PP_Instance instance, |
| 53 int render_process_id, |
| 54 int render_view_id); |
| 55 void DeleteInstanceForView(PP_Instance instance); |
| 56 |
43 private: | 57 private: |
44 friend class BrowserPpapiHostTest; | 58 friend class BrowserPpapiHostTest; |
45 | 59 |
| 60 struct RenderViewIDs { |
| 61 int process_id; |
| 62 int view_id; |
| 63 }; |
| 64 typedef std::map<PP_Instance, RenderViewIDs> InstanceToViewMap; |
| 65 |
46 virtual ~BrowserPpapiHostImpl(); | 66 virtual ~BrowserPpapiHostImpl(); |
47 | 67 |
48 ContentBrowserPepperHostFactory host_factory_; | |
49 ppapi::host::PpapiHost ppapi_host_; | 68 ppapi::host::PpapiHost ppapi_host_; |
50 base::ProcessHandle plugin_process_handle_; | 69 base::ProcessHandle plugin_process_handle_; |
51 | 70 |
| 71 // Tracks all PP_Instances in this plugin and maps them to |
| 72 // RenderProcess/RenderView IDs. |
| 73 InstanceToViewMap instance_to_view_; |
| 74 |
52 DISALLOW_COPY_AND_ASSIGN(BrowserPpapiHostImpl); | 75 DISALLOW_COPY_AND_ASSIGN(BrowserPpapiHostImpl); |
53 }; | 76 }; |
54 | 77 |
55 } // namespace content | 78 } // namespace content |
56 | 79 |
57 #endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_BROWSER_PPAPI_HOST_IMPL_H_ | 80 #endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_BROWSER_PPAPI_HOST_IMPL_H_ |
OLD | NEW |