Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef PPAPI_PROXY_MESSAGE_HANDLER_H_ | |
| 6 #define PPAPI_PROXY_MESSAGE_HANDLER_H_ | |
| 7 | |
| 8 #include "base/memory/ref_counted.h" | |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "ppapi/c/pp_resource.h" | |
| 11 #include "ppapi/c/ppp_message_handler.h" | |
| 12 #include "ppapi/proxy/ppapi_proxy_export.h" | |
| 13 | |
| 14 namespace IPC { | |
| 15 class Message; | |
| 16 } | |
| 17 | |
| 18 namespace ppapi { | |
| 19 | |
| 20 class ScopedPPVar; | |
| 21 | |
| 22 namespace proxy { | |
| 23 | |
| 24 class MessageLoopResource; | |
| 25 | |
| 26 // MessageHandler wraps a PPP_MessageHandler to encapsulate calling methods | |
| 27 // on the right thread and calling the Destroy call when this MessageHandler is | |
|
raymes
2014/06/06 06:38:17
Destroy call-> Destroy function?
dmichael (off chromium)
2014/06/13 22:01:26
Done.
| |
| 28 // destroyed. | |
| 29 class PPAPI_PROXY_EXPORT MessageHandler { | |
| 30 public: | |
| 31 // Create a MessageHandler. If any parameters are invalid, it will return a | |
| 32 // null scoped_ptr and set |*error| appropriately. | |
| 33 // |handler_if| is the struct of function pointers we will invoke. All of | |
| 34 // the function pointers within must be valid, or we fail | |
| 35 // with PP_ERROR_BADARGUMENT. | |
| 36 // |user_data| is a pointer provided by the plugin that we pass back when we | |
| 37 // call functions in |handler_if|. | |
| 38 // |message_loop| is the message loop where we will invoke functions in | |
| 39 // |handler_if|. Must not be the main thread message loop, | |
| 40 // to try to force the plugin to not over-subscribe the main | |
| 41 // thread. If it's the main thread loop, |error| will be set | |
| 42 // to PP_ERROR_WRONGTHREAD. | |
| 43 // |error| is an out-param that will be set on failure. | |
|
raymes
2014/06/06 06:38:17
nit: This indentation style looks a little odd (ha
dmichael (off chromium)
2014/06/13 22:01:26
Done.
| |
| 44 static scoped_ptr<MessageHandler> Create( | |
| 45 PP_Instance instance, | |
| 46 const PPP_MessageHandler_0_1* handler_if, | |
| 47 void* user_data, | |
| 48 PP_Resource message_loop, | |
| 49 int32_t* error); | |
| 50 ~MessageHandler(); | |
| 51 | |
| 52 void HandleMessage(ScopedPPVar var); | |
| 53 void HandleBlockingMessage(ScopedPPVar var, | |
| 54 scoped_ptr<IPC::Message> reply_msg); | |
| 55 | |
| 56 private: | |
| 57 MessageHandler(PP_Instance instance, | |
| 58 const PPP_MessageHandler_0_1* handler_if, | |
| 59 void* user_data, | |
| 60 scoped_refptr<MessageLoopResource> message_loop); | |
| 61 | |
| 62 PP_Instance instance_; | |
| 63 const PPP_MessageHandler_0_1* handler_if_; | |
| 64 void* user_data_; | |
| 65 scoped_refptr<MessageLoopResource> message_loop_; | |
| 66 | |
| 67 DISALLOW_COPY_AND_ASSIGN(MessageHandler); | |
| 68 }; | |
| 69 | |
| 70 } // namespace proxy | |
| 71 } // namespace ppapi | |
| 72 | |
| 73 #endif // PPAPI_PROXY_MESSAGE_HANDLER_H_ | |
| OLD | NEW |