| 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 <cstring> | 5 #include <cstring> |
| 6 | 6 |
| 7 #include "base/synchronization/waitable_event.h" | 7 #include "base/synchronization/waitable_event.h" |
| 8 #include "ppapi/c/pp_var.h" | 8 #include "ppapi/c/pp_var.h" |
| 9 #include "ppapi/c/ppb_var.h" | 9 #include "ppapi/c/ppb_var.h" |
| 10 #include "ppapi/c/ppp_messaging.h" | 10 #include "ppapi/c/ppp_messaging.h" |
| 11 #include "ppapi/proxy/ppapi_messages.h" | 11 #include "ppapi/proxy/ppapi_messages.h" |
| 12 #include "ppapi/proxy/ppapi_proxy_test.h" | 12 #include "ppapi/proxy/ppapi_proxy_test.h" |
| 13 #include "ppapi/proxy/serialized_var.h" | 13 #include "ppapi/proxy/serialized_var.h" |
| 14 #include "ppapi/shared_impl/api_id.h" | 14 #include "ppapi/shared_impl/api_id.h" |
| 15 #include "ppapi/shared_impl/proxy_lock.h" | 15 #include "ppapi/shared_impl/proxy_lock.h" |
| 16 #include "ppapi/shared_impl/var.h" | 16 #include "ppapi/shared_impl/var.h" |
| 17 | 17 |
| 18 namespace ppapi { | 18 namespace ppapi { |
| 19 namespace proxy { | 19 namespace proxy { |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 // This is a poor man's mock of PPP_Messaging using global variables. Eventually | 23 // This is a poor man's mock of PPP_Messaging using global variables. Eventually |
| 24 // we should generalize making PPAPI interface mocks by using IDL or macro/ | 24 // we should generalize making PPAPI interface mocks by using IDL or macro/ |
| 25 // template magic. | 25 // template magic. |
| 26 PP_Instance received_instance; | 26 PP_Instance received_instance; |
| 27 PP_Var received_var; | 27 PP_Var received_var; |
| 28 base::WaitableEvent handle_message_called(false, false); | 28 base::WaitableEvent handle_message_called( |
| 29 base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 30 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 29 | 31 |
| 30 void HandleMessage(PP_Instance instance, PP_Var message_data) { | 32 void HandleMessage(PP_Instance instance, PP_Var message_data) { |
| 31 received_instance = instance; | 33 received_instance = instance; |
| 32 received_var = message_data; | 34 received_var = message_data; |
| 33 handle_message_called.Signal(); | 35 handle_message_called.Signal(); |
| 34 } | 36 } |
| 35 | 37 |
| 36 // Clear all the 'received' values for our mock. Call this before you expect | 38 // Clear all the 'received' values for our mock. Call this before you expect |
| 37 // one of the functions to be invoked. | 39 // one of the functions to be invoked. |
| 38 void ResetReceived() { | 40 void ResetReceived() { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 PostTaskOnRemoteHarness( | 139 PostTaskOnRemoteHarness( |
| 138 base::Bind(CompareAndReleaseStringVar, | 140 base::Bind(CompareAndReleaseStringVar, |
| 139 &plugin(), | 141 &plugin(), |
| 140 received_var, | 142 received_var, |
| 141 kTestString)); | 143 kTestString)); |
| 142 } | 144 } |
| 143 | 145 |
| 144 } // namespace proxy | 146 } // namespace proxy |
| 145 } // namespace ppapi | 147 } // namespace ppapi |
| 146 | 148 |
| OLD | NEW |