Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(467)

Side by Side Diff: ppapi/proxy/ppp_instance_proxy.cc

Issue 11421066: Refactor PPB_Flash_Fullscreen to the new resource model. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/proxy/ppb_instance_proxy.cc ('k') | ppapi/shared_impl/resource.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ppapi/proxy/ppp_instance_proxy.h" 5 #include "ppapi/proxy/ppp_instance_proxy.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "ppapi/c/pp_var.h" 10 #include "ppapi/c/pp_var.h"
11 #include "ppapi/c/ppb_core.h" 11 #include "ppapi/c/ppb_core.h"
12 #include "ppapi/c/ppb_fullscreen.h" 12 #include "ppapi/c/ppb_fullscreen.h"
13 #include "ppapi/c/ppp_instance.h" 13 #include "ppapi/c/ppp_instance.h"
14 #include "ppapi/c/private/ppb_flash_fullscreen.h"
15 #include "ppapi/proxy/host_dispatcher.h" 14 #include "ppapi/proxy/host_dispatcher.h"
16 #include "ppapi/proxy/plugin_dispatcher.h" 15 #include "ppapi/proxy/plugin_dispatcher.h"
17 #include "ppapi/proxy/plugin_resource_tracker.h" 16 #include "ppapi/proxy/plugin_resource_tracker.h"
18 #include "ppapi/proxy/ppapi_messages.h" 17 #include "ppapi/proxy/ppapi_messages.h"
19 #include "ppapi/proxy/ppb_url_loader_proxy.h" 18 #include "ppapi/proxy/ppb_url_loader_proxy.h"
20 #include "ppapi/shared_impl/ppapi_globals.h" 19 #include "ppapi/shared_impl/ppapi_globals.h"
21 #include "ppapi/shared_impl/ppb_view_shared.h" 20 #include "ppapi/shared_impl/ppb_view_shared.h"
22 #include "ppapi/shared_impl/scoped_pp_resource.h" 21 #include "ppapi/shared_impl/scoped_pp_resource.h"
23 #include "ppapi/thunk/enter.h" 22 #include "ppapi/thunk/enter.h"
23 #include "ppapi/thunk/ppb_flash_fullscreen_api.h"
24 #include "ppapi/thunk/ppb_view_api.h" 24 #include "ppapi/thunk/ppb_view_api.h"
25 25
26 namespace ppapi { 26 namespace ppapi {
27 namespace proxy { 27 namespace proxy {
28 28
29 using thunk::EnterInstanceAPINoLock;
30 using thunk::EnterInstanceNoLock;
31 using thunk::EnterResourceNoLock;
32 using thunk::PPB_Flash_Fullscreen_API;
33 using thunk::PPB_Instance_API;
34 using thunk::PPB_View_API;
35
29 namespace { 36 namespace {
30 37
31 #if !defined(OS_NACL) 38 #if !defined(OS_NACL)
32 PP_Bool IsFlashFullscreen(PP_Instance instance,
33 HostDispatcher* dispatcher) {
34 const PPB_FlashFullscreen* flash_fullscreen_interface =
35 static_cast<const PPB_FlashFullscreen*>(
36 dispatcher->local_get_interface()(PPB_FLASHFULLSCREEN_INTERFACE));
37 DCHECK(flash_fullscreen_interface);
38 return flash_fullscreen_interface->IsFullscreen(instance);
39 }
40
41 PP_Bool DidCreate(PP_Instance instance, 39 PP_Bool DidCreate(PP_Instance instance,
42 uint32_t argc, 40 uint32_t argc,
43 const char* argn[], 41 const char* argn[],
44 const char* argv[]) { 42 const char* argv[]) {
45 std::vector<std::string> argn_vect; 43 std::vector<std::string> argn_vect;
46 std::vector<std::string> argv_vect; 44 std::vector<std::string> argv_vect;
47 for (uint32_t i = 0; i < argc; i++) { 45 for (uint32_t i = 0; i < argc; i++) {
48 argn_vect.push_back(std::string(argn[i])); 46 argn_vect.push_back(std::string(argn[i]));
49 argv_vect.push_back(std::string(argv[i])); 47 argv_vect.push_back(std::string(argv[i]));
50 } 48 }
51 49
52 PP_Bool result = PP_FALSE; 50 PP_Bool result = PP_FALSE;
53 HostDispatcher::GetForInstance(instance)->Send( 51 HostDispatcher::GetForInstance(instance)->Send(
54 new PpapiMsg_PPPInstance_DidCreate(API_ID_PPP_INSTANCE, instance, 52 new PpapiMsg_PPPInstance_DidCreate(API_ID_PPP_INSTANCE, instance,
55 argn_vect, argv_vect, &result)); 53 argn_vect, argv_vect, &result));
56 return result; 54 return result;
57 } 55 }
58 56
59 void DidDestroy(PP_Instance instance) { 57 void DidDestroy(PP_Instance instance) {
60 HostDispatcher::GetForInstance(instance)->Send( 58 HostDispatcher::GetForInstance(instance)->Send(
61 new PpapiMsg_PPPInstance_DidDestroy(API_ID_PPP_INSTANCE, instance)); 59 new PpapiMsg_PPPInstance_DidDestroy(API_ID_PPP_INSTANCE, instance));
62 } 60 }
63 61
64 void DidChangeView(PP_Instance instance, PP_Resource view_resource) { 62 void DidChangeView(PP_Instance instance, PP_Resource view_resource) {
65 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); 63 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance);
66 64
67 thunk::EnterResourceNoLock<thunk::PPB_View_API> enter(view_resource, false); 65 EnterResourceNoLock<PPB_View_API> enter_view(view_resource, false);
68 if (enter.failed()) { 66 if (enter_view.failed()) {
69 NOTREACHED(); 67 NOTREACHED();
70 return; 68 return;
71 } 69 }
72 70
71 PP_Bool flash_fullscreen = PP_FALSE;
72 EnterInstanceNoLock enter_instance(instance);
73 if (!enter_instance.failed())
74 flash_fullscreen = enter_instance.functions()->FlashIsFullscreen(instance);
73 dispatcher->Send(new PpapiMsg_PPPInstance_DidChangeView( 75 dispatcher->Send(new PpapiMsg_PPPInstance_DidChangeView(
74 API_ID_PPP_INSTANCE, instance, enter.object()->GetData(), 76 API_ID_PPP_INSTANCE, instance, enter_view.object()->GetData(),
75 IsFlashFullscreen(instance, dispatcher))); 77 flash_fullscreen));
76 } 78 }
77 79
78 void DidChangeFocus(PP_Instance instance, PP_Bool has_focus) { 80 void DidChangeFocus(PP_Instance instance, PP_Bool has_focus) {
79 HostDispatcher::GetForInstance(instance)->Send( 81 HostDispatcher::GetForInstance(instance)->Send(
80 new PpapiMsg_PPPInstance_DidChangeFocus(API_ID_PPP_INSTANCE, 82 new PpapiMsg_PPPInstance_DidChangeFocus(API_ID_PPP_INSTANCE,
81 instance, has_focus)); 83 instance, has_focus));
82 } 84 }
83 85
84 PP_Bool HandleDocumentLoad(PP_Instance instance, 86 PP_Bool HandleDocumentLoad(PP_Instance instance,
85 PP_Resource url_loader) { 87 PP_Resource url_loader) {
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 void PPP_Instance_Proxy::OnPluginMsgDidChangeView( 218 void PPP_Instance_Proxy::OnPluginMsgDidChangeView(
217 PP_Instance instance, 219 PP_Instance instance,
218 const ViewData& new_data, 220 const ViewData& new_data,
219 PP_Bool flash_fullscreen) { 221 PP_Bool flash_fullscreen) {
220 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); 222 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
221 if (!dispatcher) 223 if (!dispatcher)
222 return; 224 return;
223 InstanceData* data = dispatcher->GetInstanceData(instance); 225 InstanceData* data = dispatcher->GetInstanceData(instance);
224 if (!data) 226 if (!data)
225 return; 227 return;
228 data->view = new_data;
226 229
227 data->view = new_data; 230 #if !defined(OS_NACL)
228 data->flash_fullscreen = flash_fullscreen; 231 EnterInstanceAPINoLock<PPB_Flash_Fullscreen_API> enter(instance);
232 if (!enter.failed())
233 enter.functions()->SetLocalIsFullscreen(instance, flash_fullscreen);
234 #endif // !defined(OS_NACL)
229 235
230 ScopedPPResource resource( 236 ScopedPPResource resource(
231 ScopedPPResource::PassRef(), 237 ScopedPPResource::PassRef(),
232 (new PPB_View_Shared(OBJECT_IS_PROXY, 238 (new PPB_View_Shared(OBJECT_IS_PROXY,
233 instance, new_data))->GetReference()); 239 instance, new_data))->GetReference());
234 240
235 combined_interface_->DidChangeView(instance, resource, 241 combined_interface_->DidChangeView(instance, resource,
236 &new_data.rect, 242 &new_data.rect,
237 &new_data.clip_rect); 243 &new_data.clip_rect);
238 } 244 }
(...skipping 15 matching lines...) Expand all
254 // with. The plugin will normally take an additional reference which will keep 260 // with. The plugin will normally take an additional reference which will keep
255 // the resource alive in the plugin (and the one reference in the renderer 261 // the resource alive in the plugin (and the one reference in the renderer
256 // representing all plugin references). 262 // representing all plugin references).
257 // Once all references at the plugin side are released, the renderer side will 263 // Once all references at the plugin side are released, the renderer side will
258 // be notified and release the reference added in HandleDocumentLoad() above. 264 // be notified and release the reference added in HandleDocumentLoad() above.
259 PpapiGlobals::Get()->GetResourceTracker()->ReleaseResource(plugin_loader); 265 PpapiGlobals::Get()->GetResourceTracker()->ReleaseResource(plugin_loader);
260 } 266 }
261 267
262 } // namespace proxy 268 } // namespace proxy
263 } // namespace ppapi 269 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/ppb_instance_proxy.cc ('k') | ppapi/shared_impl/resource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698