OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef PPAPI_PROXY_MESSAGE_HANDLER_H_ | 5 #ifndef PPAPI_PROXY_MESSAGE_HANDLER_H_ |
6 #define PPAPI_PROXY_MESSAGE_HANDLER_H_ | 6 #define PPAPI_PROXY_MESSAGE_HANDLER_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "ppapi/c/dev/ppb_messaging_deprecated.h" | |
11 #include "ppapi/c/pp_resource.h" | 10 #include "ppapi/c/pp_resource.h" |
12 #include "ppapi/c/ppp_message_handler.h" | 11 #include "ppapi/c/ppp_message_handler.h" |
13 #include "ppapi/proxy/ppapi_proxy_export.h" | 12 #include "ppapi/proxy/ppapi_proxy_export.h" |
14 | 13 |
15 namespace IPC { | 14 namespace IPC { |
16 class Message; | 15 class Message; |
17 } | 16 } |
18 | 17 |
19 namespace ppapi { | 18 namespace ppapi { |
20 | 19 |
(...skipping 20 matching lines...) Expand all Loading... |
41 // to try to force the plugin to not over-subscribe the main | 40 // to try to force the plugin to not over-subscribe the main |
42 // thread. If it's the main thread loop, |error| will be set | 41 // thread. If it's the main thread loop, |error| will be set |
43 // to PP_ERROR_WRONGTHREAD. | 42 // to PP_ERROR_WRONGTHREAD. |
44 // |error| is an out-param that will be set on failure. | 43 // |error| is an out-param that will be set on failure. |
45 static scoped_ptr<MessageHandler> Create( | 44 static scoped_ptr<MessageHandler> Create( |
46 PP_Instance instance, | 45 PP_Instance instance, |
47 const PPP_MessageHandler_0_2* handler_if, | 46 const PPP_MessageHandler_0_2* handler_if, |
48 void* user_data, | 47 void* user_data, |
49 PP_Resource message_loop, | 48 PP_Resource message_loop, |
50 int32_t* error); | 49 int32_t* error); |
51 // Provide temporary backwards compatibility. TODO(dmichael): Remove all | |
52 // references to PPB_Messaging_1_1 and PPP_MessageHandler_0_1. | |
53 // crbug.com/414398 | |
54 static scoped_ptr<MessageHandler> CreateDeprecated( | |
55 PP_Instance instance, | |
56 const PPP_MessageHandler_0_1_Deprecated* handler_if, | |
57 void* user_data, | |
58 PP_Resource message_loop, | |
59 int32_t* error); | |
60 ~MessageHandler(); | 50 ~MessageHandler(); |
61 | 51 |
62 bool LoopIsValid() const; | 52 bool LoopIsValid() const; |
63 | 53 |
64 void HandleMessage(ScopedPPVar var); | 54 void HandleMessage(ScopedPPVar var); |
65 void HandleBlockingMessage(ScopedPPVar var, | 55 void HandleBlockingMessage(ScopedPPVar var, |
66 scoped_ptr<IPC::Message> reply_msg); | 56 scoped_ptr<IPC::Message> reply_msg); |
67 | 57 |
68 private: | 58 private: |
69 MessageHandler(PP_Instance instance, | 59 MessageHandler(PP_Instance instance, |
70 const PPP_MessageHandler_0_2* handler_if, | 60 const PPP_MessageHandler_0_2* handler_if, |
71 void* user_data, | 61 void* user_data, |
72 scoped_refptr<MessageLoopResource> message_loop); | 62 scoped_refptr<MessageLoopResource> message_loop); |
73 MessageHandler(PP_Instance instance, | |
74 const PPP_MessageHandler_0_1_Deprecated* handler_if, | |
75 void* user_data, | |
76 scoped_refptr<MessageLoopResource> message_loop); | |
77 | |
78 | |
79 PP_Instance instance_; | 63 PP_Instance instance_; |
80 const PPP_MessageHandler_0_2* handler_if_; | 64 const PPP_MessageHandler_0_2* handler_if_; |
81 const PPP_MessageHandler_0_1_Deprecated* handler_if_0_1_; | |
82 void* user_data_; | 65 void* user_data_; |
83 scoped_refptr<MessageLoopResource> message_loop_; | 66 scoped_refptr<MessageLoopResource> message_loop_; |
84 | 67 |
85 DISALLOW_COPY_AND_ASSIGN(MessageHandler); | 68 DISALLOW_COPY_AND_ASSIGN(MessageHandler); |
86 }; | 69 }; |
87 | 70 |
88 } // namespace proxy | 71 } // namespace proxy |
89 } // namespace ppapi | 72 } // namespace ppapi |
90 | 73 |
91 #endif // PPAPI_PROXY_MESSAGE_HANDLER_H_ | 74 #endif // PPAPI_PROXY_MESSAGE_HANDLER_H_ |
OLD | NEW |