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 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" | 5 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 // Out-of-process constructor. | 41 // Out-of-process constructor. |
42 RendererPpapiHostImpl::RendererPpapiHostImpl( | 42 RendererPpapiHostImpl::RendererPpapiHostImpl( |
43 PluginModule* module, | 43 PluginModule* module, |
44 ppapi::proxy::HostDispatcher* dispatcher, | 44 ppapi::proxy::HostDispatcher* dispatcher, |
45 const ppapi::PpapiPermissions& permissions) | 45 const ppapi::PpapiPermissions& permissions) |
46 : module_(module), | 46 : module_(module), |
47 dispatcher_(dispatcher), | 47 dispatcher_(dispatcher), |
48 is_external_plugin_host_(false) { | 48 is_external_plugin_host_(false) { |
49 // Hook the PpapiHost up to the dispatcher for out-of-process communication. | 49 // Hook the PpapiHost up to the dispatcher for out-of-process communication. |
50 ppapi_host_.reset(new ppapi::host::PpapiHost(dispatcher, permissions)); | 50 ppapi_host_.reset(new ppapi::host::PpapiHost(dispatcher, permissions)); |
51 ppapi_host_->AddHostFactoryFilter(scoped_ptr<ppapi::host::HostFactory>( | 51 ppapi_host_->AddHostFactoryFilter(std::unique_ptr<ppapi::host::HostFactory>( |
52 new ContentRendererPepperHostFactory(this))); | 52 new ContentRendererPepperHostFactory(this))); |
53 dispatcher->AddFilter(ppapi_host_.get()); | 53 dispatcher->AddFilter(ppapi_host_.get()); |
54 is_running_in_process_ = false; | 54 is_running_in_process_ = false; |
55 } | 55 } |
56 | 56 |
57 // In-process constructor. | 57 // In-process constructor. |
58 RendererPpapiHostImpl::RendererPpapiHostImpl( | 58 RendererPpapiHostImpl::RendererPpapiHostImpl( |
59 PluginModule* module, | 59 PluginModule* module, |
60 const ppapi::PpapiPermissions& permissions) | 60 const ppapi::PpapiPermissions& permissions) |
61 : module_(module), dispatcher_(NULL), is_external_plugin_host_(false) { | 61 : module_(module), dispatcher_(NULL), is_external_plugin_host_(false) { |
62 // Hook the host up to the in-process router. | 62 // Hook the host up to the in-process router. |
63 in_process_router_.reset(new PepperInProcessRouter(this)); | 63 in_process_router_.reset(new PepperInProcessRouter(this)); |
64 ppapi_host_.reset(new ppapi::host::PpapiHost( | 64 ppapi_host_.reset(new ppapi::host::PpapiHost( |
65 in_process_router_->GetRendererToPluginSender(), permissions)); | 65 in_process_router_->GetRendererToPluginSender(), permissions)); |
66 ppapi_host_->AddHostFactoryFilter(scoped_ptr<ppapi::host::HostFactory>( | 66 ppapi_host_->AddHostFactoryFilter(std::unique_ptr<ppapi::host::HostFactory>( |
67 new ContentRendererPepperHostFactory(this))); | 67 new ContentRendererPepperHostFactory(this))); |
68 is_running_in_process_ = true; | 68 is_running_in_process_ = true; |
69 } | 69 } |
70 | 70 |
71 RendererPpapiHostImpl::~RendererPpapiHostImpl() { | 71 RendererPpapiHostImpl::~RendererPpapiHostImpl() { |
72 // Delete the host explicitly first. This shutdown will destroy the | 72 // Delete the host explicitly first. This shutdown will destroy the |
73 // resources, which may want to do cleanup in their destructors and expect | 73 // resources, which may want to do cleanup in their destructors and expect |
74 // their pointers to us to be valid. | 74 // their pointers to us to be valid. |
75 ppapi_host_.reset(); | 75 ppapi_host_.reset(); |
76 } | 76 } |
77 | 77 |
78 // static | 78 // static |
79 RendererPpapiHostImpl* RendererPpapiHostImpl::CreateOnModuleForOutOfProcess( | 79 RendererPpapiHostImpl* RendererPpapiHostImpl::CreateOnModuleForOutOfProcess( |
80 PluginModule* module, | 80 PluginModule* module, |
81 ppapi::proxy::HostDispatcher* dispatcher, | 81 ppapi::proxy::HostDispatcher* dispatcher, |
82 const ppapi::PpapiPermissions& permissions) { | 82 const ppapi::PpapiPermissions& permissions) { |
83 DCHECK(!module->renderer_ppapi_host()); | 83 DCHECK(!module->renderer_ppapi_host()); |
84 RendererPpapiHostImpl* result = | 84 RendererPpapiHostImpl* result = |
85 new RendererPpapiHostImpl(module, dispatcher, permissions); | 85 new RendererPpapiHostImpl(module, dispatcher, permissions); |
86 | 86 |
87 // Takes ownership of pointer. | 87 // Takes ownership of pointer. |
88 module->SetRendererPpapiHost(scoped_ptr<RendererPpapiHostImpl>(result)); | 88 module->SetRendererPpapiHost(std::unique_ptr<RendererPpapiHostImpl>(result)); |
89 | 89 |
90 return result; | 90 return result; |
91 } | 91 } |
92 | 92 |
93 // static | 93 // static |
94 RendererPpapiHostImpl* RendererPpapiHostImpl::CreateOnModuleForInProcess( | 94 RendererPpapiHostImpl* RendererPpapiHostImpl::CreateOnModuleForInProcess( |
95 PluginModule* module, | 95 PluginModule* module, |
96 const ppapi::PpapiPermissions& permissions) { | 96 const ppapi::PpapiPermissions& permissions) { |
97 DCHECK(!module->renderer_ppapi_host()); | 97 DCHECK(!module->renderer_ppapi_host()); |
98 RendererPpapiHostImpl* result = | 98 RendererPpapiHostImpl* result = |
99 new RendererPpapiHostImpl(module, permissions); | 99 new RendererPpapiHostImpl(module, permissions); |
100 | 100 |
101 // Takes ownership of pointer. | 101 // Takes ownership of pointer. |
102 module->SetRendererPpapiHost(scoped_ptr<RendererPpapiHostImpl>(result)); | 102 module->SetRendererPpapiHost(std::unique_ptr<RendererPpapiHostImpl>(result)); |
103 | 103 |
104 return result; | 104 return result; |
105 } | 105 } |
106 | 106 |
107 // static | 107 // static |
108 RendererPpapiHostImpl* RendererPpapiHostImpl::GetForPPInstance( | 108 RendererPpapiHostImpl* RendererPpapiHostImpl::GetForPPInstance( |
109 PP_Instance pp_instance) { | 109 PP_Instance pp_instance) { |
110 PepperPluginInstanceImpl* instance = | 110 PepperPluginInstanceImpl* instance = |
111 HostGlobals::Get()->GetInstance(pp_instance); | 111 HostGlobals::Get()->GetInstance(pp_instance); |
112 if (!instance) | 112 if (!instance) |
113 return NULL; | 113 return NULL; |
114 | 114 |
115 // All modules created by content will have their embedder state be the | 115 // All modules created by content will have their embedder state be the |
116 // host impl. | 116 // host impl. |
117 return instance->module()->renderer_ppapi_host(); | 117 return instance->module()->renderer_ppapi_host(); |
118 } | 118 } |
119 | 119 |
120 scoped_ptr<ppapi::thunk::ResourceCreationAPI> | 120 std::unique_ptr<ppapi::thunk::ResourceCreationAPI> |
121 RendererPpapiHostImpl::CreateInProcessResourceCreationAPI( | 121 RendererPpapiHostImpl::CreateInProcessResourceCreationAPI( |
122 PepperPluginInstanceImpl* instance) { | 122 PepperPluginInstanceImpl* instance) { |
123 return scoped_ptr<ppapi::thunk::ResourceCreationAPI>( | 123 return std::unique_ptr<ppapi::thunk::ResourceCreationAPI>( |
124 new PepperInProcessResourceCreation(this, instance)); | 124 new PepperInProcessResourceCreation(this, instance)); |
125 } | 125 } |
126 | 126 |
127 PepperPluginInstanceImpl* RendererPpapiHostImpl::GetPluginInstanceImpl( | 127 PepperPluginInstanceImpl* RendererPpapiHostImpl::GetPluginInstanceImpl( |
128 PP_Instance instance) const { | 128 PP_Instance instance) const { |
129 return GetAndValidateInstance(instance); | 129 return GetAndValidateInstance(instance); |
130 } | 130 } |
131 | 131 |
132 bool RendererPpapiHostImpl::IsExternalPluginHost() const { | 132 bool RendererPpapiHostImpl::IsExternalPluginHost() const { |
133 return is_external_plugin_host_; | 133 return is_external_plugin_host_; |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 PepperPluginInstanceImpl* instance = | 282 PepperPluginInstanceImpl* instance = |
283 HostGlobals::Get()->GetInstance(pp_instance); | 283 HostGlobals::Get()->GetInstance(pp_instance); |
284 if (!instance) | 284 if (!instance) |
285 return NULL; | 285 return NULL; |
286 if (!instance->IsValidInstanceOf(module_)) | 286 if (!instance->IsValidInstanceOf(module_)) |
287 return NULL; | 287 return NULL; |
288 return instance; | 288 return instance; |
289 } | 289 } |
290 | 290 |
291 } // namespace content | 291 } // namespace content |
OLD | NEW |