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 "ppapi/cpp/dev/websocket_dev.h" | 5 #include "ppapi/cpp/dev/websocket_dev.h" |
6 | 6 |
7 #include "ppapi/c/pp_errors.h" | 7 #include "ppapi/c/pp_errors.h" |
8 #include "ppapi/c/pp_macros.h" | 8 #include "ppapi/c/pp_macros.h" |
9 #include "ppapi/cpp/completion_callback.h" | 9 #include "ppapi/cpp/completion_callback.h" |
10 #include "ppapi/cpp/instance.h" | 10 #include "ppapi/cpp/instance_handle.h" |
11 #include "ppapi/cpp/module.h" | 11 #include "ppapi/cpp/module.h" |
12 #include "ppapi/cpp/module_impl.h" | 12 #include "ppapi/cpp/module_impl.h" |
13 #include "ppapi/cpp/var.h" | 13 #include "ppapi/cpp/var.h" |
14 | 14 |
15 namespace pp { | 15 namespace pp { |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 template <> const char* interface_name<PPB_WebSocket_Dev>() { | 19 template <> const char* interface_name<PPB_WebSocket_Dev>() { |
20 return PPB_WEBSOCKET_DEV_INTERFACE; | 20 return PPB_WEBSOCKET_DEV_INTERFACE; |
21 } | 21 } |
22 | 22 |
23 } // namespace | 23 } // namespace |
24 | 24 |
25 WebSocket_Dev::WebSocket_Dev(Instance* instance) { | 25 WebSocket_Dev::WebSocket_Dev(const InstanceHandle& instance) { |
26 if (!has_interface<PPB_WebSocket_Dev>()) | 26 if (!has_interface<PPB_WebSocket_Dev>()) |
27 return; | 27 return; |
28 PassRefFromConstructor(get_interface<PPB_WebSocket_Dev>()->Create( | 28 PassRefFromConstructor(get_interface<PPB_WebSocket_Dev>()->Create( |
29 instance->pp_instance())); | 29 instance.pp_instance())); |
30 } | 30 } |
31 | 31 |
32 WebSocket_Dev::~WebSocket_Dev() { | 32 WebSocket_Dev::~WebSocket_Dev() { |
33 } | 33 } |
34 | 34 |
35 int32_t WebSocket_Dev::Connect(const Var& url, const Var protocols[], | 35 int32_t WebSocket_Dev::Connect(const Var& url, const Var protocols[], |
36 uint32_t protocol_count, const CompletionCallback& callback) { | 36 uint32_t protocol_count, const CompletionCallback& callback) { |
37 if (!has_interface<PPB_WebSocket_Dev>()) | 37 if (!has_interface<PPB_WebSocket_Dev>()) |
38 return PP_ERROR_BADRESOURCE; | 38 return PP_ERROR_BADRESOURCE; |
39 | 39 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 if (!has_interface<PPB_WebSocket_Dev>()) | 94 if (!has_interface<PPB_WebSocket_Dev>()) |
95 return 0; | 95 return 0; |
96 | 96 |
97 return get_interface<PPB_WebSocket_Dev>()->GetCloseCode(pp_resource()); | 97 return get_interface<PPB_WebSocket_Dev>()->GetCloseCode(pp_resource()); |
98 } | 98 } |
99 | 99 |
100 Var WebSocket_Dev::GetCloseReason() { | 100 Var WebSocket_Dev::GetCloseReason() { |
101 if (!has_interface<PPB_WebSocket_Dev>()) | 101 if (!has_interface<PPB_WebSocket_Dev>()) |
102 return 0; | 102 return 0; |
103 | 103 |
104 return Var(Var::PassRef(), | 104 return Var(PASS_REF, |
105 get_interface<PPB_WebSocket_Dev>()->GetCloseReason(pp_resource())); | 105 get_interface<PPB_WebSocket_Dev>()->GetCloseReason(pp_resource())); |
106 } | 106 } |
107 | 107 |
108 bool WebSocket_Dev::GetCloseWasClean() { | 108 bool WebSocket_Dev::GetCloseWasClean() { |
109 if (!has_interface<PPB_WebSocket_Dev>()) | 109 if (!has_interface<PPB_WebSocket_Dev>()) |
110 return false; | 110 return false; |
111 | 111 |
112 PP_Bool result = | 112 PP_Bool result = |
113 get_interface<PPB_WebSocket_Dev>()->GetCloseWasClean(pp_resource()); | 113 get_interface<PPB_WebSocket_Dev>()->GetCloseWasClean(pp_resource()); |
114 return PP_ToBool(result); | 114 return PP_ToBool(result); |
115 } | 115 } |
116 | 116 |
117 Var WebSocket_Dev::GetExtensions() { | 117 Var WebSocket_Dev::GetExtensions() { |
118 if (!has_interface<PPB_WebSocket_Dev>()) | 118 if (!has_interface<PPB_WebSocket_Dev>()) |
119 return Var(); | 119 return Var(); |
120 | 120 |
121 return Var(Var::PassRef(), | 121 return Var(PASS_REF, |
122 get_interface<PPB_WebSocket_Dev>()->GetExtensions(pp_resource())); | 122 get_interface<PPB_WebSocket_Dev>()->GetExtensions(pp_resource())); |
123 } | 123 } |
124 | 124 |
125 Var WebSocket_Dev::GetProtocol() { | 125 Var WebSocket_Dev::GetProtocol() { |
126 if (!has_interface<PPB_WebSocket_Dev>()) | 126 if (!has_interface<PPB_WebSocket_Dev>()) |
127 return Var(); | 127 return Var(); |
128 | 128 |
129 return Var(Var::PassRef(), | 129 return Var(PASS_REF, |
130 get_interface<PPB_WebSocket_Dev>()->GetProtocol(pp_resource())); | 130 get_interface<PPB_WebSocket_Dev>()->GetProtocol(pp_resource())); |
131 } | 131 } |
132 | 132 |
133 PP_WebSocketReadyState_Dev WebSocket_Dev::GetReadyState() { | 133 PP_WebSocketReadyState_Dev WebSocket_Dev::GetReadyState() { |
134 if (!has_interface<PPB_WebSocket_Dev>()) | 134 if (!has_interface<PPB_WebSocket_Dev>()) |
135 return PP_WEBSOCKETREADYSTATE_INVALID_DEV; | 135 return PP_WEBSOCKETREADYSTATE_INVALID_DEV; |
136 | 136 |
137 return get_interface<PPB_WebSocket_Dev>()->GetReadyState(pp_resource()); | 137 return get_interface<PPB_WebSocket_Dev>()->GetReadyState(pp_resource()); |
138 } | 138 } |
139 | 139 |
140 Var WebSocket_Dev::GetURL() { | 140 Var WebSocket_Dev::GetURL() { |
141 if (!has_interface<PPB_WebSocket_Dev>()) | 141 if (!has_interface<PPB_WebSocket_Dev>()) |
142 return Var(); | 142 return Var(); |
143 | 143 |
144 return Var(Var::PassRef(), | 144 return Var(PASS_REF, |
145 get_interface<PPB_WebSocket_Dev>()->GetURL(pp_resource())); | 145 get_interface<PPB_WebSocket_Dev>()->GetURL(pp_resource())); |
146 } | 146 } |
147 | 147 |
148 } // namespace pp | 148 } // namespace pp |
OLD | NEW |