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

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

Issue 8371008: Revert 106717 - Revert 106677 (caused several PPAPI test timeouts, see http://crbug.com/101154) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 2 months 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.h ('k') | ppapi/proxy/ppb_url_loader_proxy.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/ppb_instance_proxy.h" 5 #include "ppapi/proxy/ppb_instance_proxy.h"
6 6
7 #include "ppapi/c/pp_errors.h" 7 #include "ppapi/c/pp_errors.h"
8 #include "ppapi/c/pp_var.h" 8 #include "ppapi/c/pp_var.h"
9 #include "ppapi/c/ppb_instance.h" 9 #include "ppapi/c/ppb_instance.h"
10 #include "ppapi/c/ppb_messaging.h" 10 #include "ppapi/c/ppb_messaging.h"
11 #include "ppapi/c/ppb_mouse_lock.h" 11 #include "ppapi/c/ppb_mouse_lock.h"
12 #include "ppapi/proxy/enter_proxy.h"
12 #include "ppapi/proxy/host_dispatcher.h" 13 #include "ppapi/proxy/host_dispatcher.h"
13 #include "ppapi/proxy/plugin_dispatcher.h" 14 #include "ppapi/proxy/plugin_dispatcher.h"
14 #include "ppapi/proxy/ppapi_messages.h" 15 #include "ppapi/proxy/ppapi_messages.h"
15 #include "ppapi/proxy/serialized_var.h" 16 #include "ppapi/proxy/serialized_var.h"
16 #include "ppapi/shared_impl/ppapi_globals.h" 17 #include "ppapi/shared_impl/ppapi_globals.h"
17 #include "ppapi/shared_impl/url_util_impl.h" 18 #include "ppapi/shared_impl/url_util_impl.h"
18 #include "ppapi/thunk/enter.h" 19 #include "ppapi/thunk/enter.h"
19 #include "ppapi/thunk/thunk.h" 20 #include "ppapi/thunk/thunk.h"
20 21
21 // Windows headers interfere with this file. 22 // Windows headers interfere with this file.
(...skipping 12 matching lines...) Expand all
34 35
35 typedef EnterFunctionNoLock<PPB_Instance_FunctionAPI> EnterInstanceNoLock; 36 typedef EnterFunctionNoLock<PPB_Instance_FunctionAPI> EnterInstanceNoLock;
36 37
37 InterfaceProxy* CreateInstanceProxy(Dispatcher* dispatcher) { 38 InterfaceProxy* CreateInstanceProxy(Dispatcher* dispatcher) {
38 return new PPB_Instance_Proxy(dispatcher); 39 return new PPB_Instance_Proxy(dispatcher);
39 } 40 }
40 41
41 } // namespace 42 } // namespace
42 43
43 PPB_Instance_Proxy::PPB_Instance_Proxy(Dispatcher* dispatcher) 44 PPB_Instance_Proxy::PPB_Instance_Proxy(Dispatcher* dispatcher)
44 : InterfaceProxy(dispatcher) { 45 : InterfaceProxy(dispatcher),
46 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
45 } 47 }
46 48
47 PPB_Instance_Proxy::~PPB_Instance_Proxy() { 49 PPB_Instance_Proxy::~PPB_Instance_Proxy() {
48 } 50 }
49 51
50 // static 52 // static
51 const InterfaceProxy::Info* PPB_Instance_Proxy::GetInfoPrivate() { 53 const InterfaceProxy::Info* PPB_Instance_Proxy::GetInfoPrivate() {
52 static const Info info = { 54 static const Info info = {
53 ppapi::thunk::GetPPB_Instance_Private_Thunk(), 55 ppapi::thunk::GetPPB_Instance_Private_Thunk(),
54 PPB_INSTANCE_PRIVATE_INTERFACE, 56 PPB_INSTANCE_PRIVATE_INTERFACE,
55 API_ID_NONE, // 1_0 is the canonical one. 57 API_ID_NONE, // 1_0 is the canonical one.
56 false, 58 false,
57 &CreateInstanceProxy, 59 &CreateInstanceProxy,
58 }; 60 };
59 return &info; 61 return &info;
60 } 62 }
61 63
62 bool PPB_Instance_Proxy::OnMessageReceived(const IPC::Message& msg) { 64 bool PPB_Instance_Proxy::OnMessageReceived(const IPC::Message& msg) {
63 // Prevent the dispatcher from going away during a call to ExecuteScript. 65 // Prevent the dispatcher from going away during a call to ExecuteScript.
64 // This must happen OUTSIDE of ExecuteScript since the SerializedVars use 66 // This must happen OUTSIDE of ExecuteScript since the SerializedVars use
65 // the dispatcher upon return of the function (converting the 67 // the dispatcher upon return of the function (converting the
66 // SerializedVarReturnValue/OutParam to a SerializedVar in the destructor). 68 // SerializedVarReturnValue/OutParam to a SerializedVar in the destructor).
67 ScopedModuleReference death_grip(dispatcher()); 69 ScopedModuleReference death_grip(dispatcher());
68 70
69 bool handled = true; 71 bool handled = true;
70 IPC_BEGIN_MESSAGE_MAP(PPB_Instance_Proxy, msg) 72 IPC_BEGIN_MESSAGE_MAP(PPB_Instance_Proxy, msg)
73 // Plugin -> Host messages.
71 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetWindowObject, 74 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetWindowObject,
72 OnMsgGetWindowObject) 75 OnMsgGetWindowObject)
73 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetOwnerElementObject, 76 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetOwnerElementObject,
74 OnMsgGetOwnerElementObject) 77 OnMsgGetOwnerElementObject)
75 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_BindGraphics, 78 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_BindGraphics,
76 OnMsgBindGraphics) 79 OnMsgBindGraphics)
77 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_IsFullFrame, 80 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_IsFullFrame,
78 OnMsgIsFullFrame) 81 OnMsgIsFullFrame)
79 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_ExecuteScript, 82 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_ExecuteScript,
80 OnMsgExecuteScript) 83 OnMsgExecuteScript)
(...skipping 24 matching lines...) Expand all
105 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_ResolveRelativeToDocument, 108 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_ResolveRelativeToDocument,
106 OnMsgResolveRelativeToDocument) 109 OnMsgResolveRelativeToDocument)
107 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DocumentCanRequest, 110 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DocumentCanRequest,
108 OnMsgDocumentCanRequest) 111 OnMsgDocumentCanRequest)
109 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DocumentCanAccessDocument, 112 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DocumentCanAccessDocument,
110 OnMsgDocumentCanAccessDocument) 113 OnMsgDocumentCanAccessDocument)
111 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetDocumentURL, 114 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetDocumentURL,
112 OnMsgGetDocumentURL) 115 OnMsgGetDocumentURL)
113 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetPluginInstanceURL, 116 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetPluginInstanceURL,
114 OnMsgGetPluginInstanceURL) 117 OnMsgGetPluginInstanceURL)
118
119 // Host -> Plugin messages.
120 IPC_MESSAGE_HANDLER(PpapiMsg_PPBInstance_MouseLockComplete,
121 OnMsgMouseLockComplete)
122
115 IPC_MESSAGE_UNHANDLED(handled = false) 123 IPC_MESSAGE_UNHANDLED(handled = false)
116 IPC_END_MESSAGE_MAP() 124 IPC_END_MESSAGE_MAP()
117 return handled; 125 return handled;
118 } 126 }
119 127
120 PPB_Instance_FunctionAPI* PPB_Instance_Proxy::AsPPB_Instance_FunctionAPI() { 128 PPB_Instance_FunctionAPI* PPB_Instance_Proxy::AsPPB_Instance_FunctionAPI() {
121 return this; 129 return this;
122 } 130 }
123 131
124 PP_Bool PPB_Instance_Proxy::BindGraphics(PP_Instance instance, 132 PP_Bool PPB_Instance_Proxy::BindGraphics(PP_Instance instance,
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 dispatcher()->Send(new PpapiHostMsg_PPBInstance_PostMessage( 363 dispatcher()->Send(new PpapiHostMsg_PPBInstance_PostMessage(
356 API_ID_PPB_INSTANCE, 364 API_ID_PPB_INSTANCE,
357 instance, SerializedVarSendInput(dispatcher(), message))); 365 instance, SerializedVarSendInput(dispatcher(), message)));
358 } 366 }
359 367
360 int32_t PPB_Instance_Proxy::LockMouse(PP_Instance instance, 368 int32_t PPB_Instance_Proxy::LockMouse(PP_Instance instance,
361 PP_CompletionCallback callback) { 369 PP_CompletionCallback callback) {
362 if (!callback.func) 370 if (!callback.func)
363 return PP_ERROR_BADARGUMENT; 371 return PP_ERROR_BADARGUMENT;
364 372
373 // Save the mouse callback on the instance data.
374 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())->
375 GetInstanceData(instance);
376 if (!data)
377 return PP_ERROR_BADARGUMENT;
378 if (data->mouse_lock_callback.func)
379 return PP_ERROR_INPROGRESS; // Already have a pending callback.
380 data->mouse_lock_callback = callback;
381
365 dispatcher()->Send(new PpapiHostMsg_PPBInstance_LockMouse( 382 dispatcher()->Send(new PpapiHostMsg_PPBInstance_LockMouse(
366 API_ID_PPB_INSTANCE, instance, SendCallback(callback))); 383 API_ID_PPB_INSTANCE, instance));
367 return PP_OK_COMPLETIONPENDING; 384 return PP_OK_COMPLETIONPENDING;
368 } 385 }
369 386
370 void PPB_Instance_Proxy::UnlockMouse(PP_Instance instance) { 387 void PPB_Instance_Proxy::UnlockMouse(PP_Instance instance) {
371 dispatcher()->Send(new PpapiHostMsg_PPBInstance_UnlockMouse( 388 dispatcher()->Send(new PpapiHostMsg_PPBInstance_UnlockMouse(
372 API_ID_PPB_INSTANCE, instance)); 389 API_ID_PPB_INSTANCE, instance));
373 } 390 }
374 391
375 void PPB_Instance_Proxy::OnMsgGetWindowObject( 392 void PPB_Instance_Proxy::OnMsgGetWindowObject(
376 PP_Instance instance, 393 PP_Instance instance,
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 enter.functions()->ClearInputEventRequest(instance, event_classes); 524 enter.functions()->ClearInputEventRequest(instance, event_classes);
508 } 525 }
509 526
510 void PPB_Instance_Proxy::OnMsgPostMessage(PP_Instance instance, 527 void PPB_Instance_Proxy::OnMsgPostMessage(PP_Instance instance,
511 SerializedVarReceiveInput message) { 528 SerializedVarReceiveInput message) {
512 EnterInstanceNoLock enter(instance, false); 529 EnterInstanceNoLock enter(instance, false);
513 if (enter.succeeded()) 530 if (enter.succeeded())
514 enter.functions()->PostMessage(instance, message.Get(dispatcher())); 531 enter.functions()->PostMessage(instance, message.Get(dispatcher()));
515 } 532 }
516 533
517 void PPB_Instance_Proxy::OnMsgLockMouse(PP_Instance instance, 534 void PPB_Instance_Proxy::OnMsgLockMouse(PP_Instance instance) {
518 uint32_t serialized_callback) { 535 EnterHostFunctionForceCallback<PPB_Instance_FunctionAPI> enter(
519 EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, true); 536 instance, callback_factory_,
520 if (enter.failed()) 537 &PPB_Instance_Proxy::MouseLockCompleteInHost, instance);
521 return; 538 if (enter.succeeded())
522 PP_CompletionCallback callback = ReceiveCallback(serialized_callback); 539 enter.SetResult(enter.functions()->LockMouse(instance, enter.callback()));
523 int32_t result = enter.functions()->LockMouse(instance, callback);
524 if (result != PP_OK_COMPLETIONPENDING)
525 PP_RunCompletionCallback(&callback, result);
526 } 540 }
527 541
528 void PPB_Instance_Proxy::OnMsgUnlockMouse(PP_Instance instance) { 542 void PPB_Instance_Proxy::OnMsgUnlockMouse(PP_Instance instance) {
529 EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, true); 543 EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, true);
530 if (enter.succeeded()) 544 if (enter.succeeded())
531 enter.functions()->UnlockMouse(instance); 545 enter.functions()->UnlockMouse(instance);
532 } 546 }
533 547
534 void PPB_Instance_Proxy::OnMsgResolveRelativeToDocument( 548 void PPB_Instance_Proxy::OnMsgResolveRelativeToDocument(
535 PP_Instance instance, 549 PP_Instance instance,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 void PPB_Instance_Proxy::OnMsgGetPluginInstanceURL( 587 void PPB_Instance_Proxy::OnMsgGetPluginInstanceURL(
574 PP_Instance instance, 588 PP_Instance instance,
575 SerializedVarReturnValue result) { 589 SerializedVarReturnValue result) {
576 EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, true); 590 EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, true);
577 if (enter.succeeded()) { 591 if (enter.succeeded()) {
578 result.Return(dispatcher(), 592 result.Return(dispatcher(),
579 enter.functions()->GetPluginInstanceURL(instance, NULL)); 593 enter.functions()->GetPluginInstanceURL(instance, NULL));
580 } 594 }
581 } 595 }
582 596
597 void PPB_Instance_Proxy::OnMsgMouseLockComplete(PP_Instance instance,
598 int32_t result) {
599 // Save the mouse callback on the instance data.
600 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())->
601 GetInstanceData(instance);
602 if (!data)
603 return; // Instance was probably deleted.
604 if (!data->mouse_lock_callback.func) {
605 NOTREACHED();
606 return;
607 }
608 PP_RunAndClearCompletionCallback(&data->mouse_lock_callback, result);
609 }
610
611 void PPB_Instance_Proxy::MouseLockCompleteInHost(int32_t result,
612 PP_Instance instance) {
613 dispatcher()->Send(new PpapiMsg_PPBInstance_MouseLockComplete(
614 API_ID_PPB_INSTANCE, instance, result));
615 }
616
583 } // namespace proxy 617 } // namespace proxy
584 } // namespace ppapi 618 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/ppb_instance_proxy.h ('k') | ppapi/proxy/ppb_url_loader_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698