| 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/websocket.h" | 5 #include "ppapi/cpp/websocket.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_handle.h" | 10 #include "ppapi/cpp/instance_handle.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 c_protocols[i] = protocols[i].pp_var(); | 48 c_protocols[i] = protocols[i].pp_var(); |
| 49 | 49 |
| 50 int32_t result = get_interface<PPB_WebSocket_1_0>()->Connect( | 50 int32_t result = get_interface<PPB_WebSocket_1_0>()->Connect( |
| 51 pp_resource(), url.pp_var(), c_protocols, protocol_count, | 51 pp_resource(), url.pp_var(), c_protocols, protocol_count, |
| 52 callback.pp_completion_callback()); | 52 callback.pp_completion_callback()); |
| 53 if (c_protocols) | 53 if (c_protocols) |
| 54 delete[] c_protocols; | 54 delete[] c_protocols; |
| 55 return result; | 55 return result; |
| 56 } | 56 } |
| 57 | 57 |
| 58 int32_t WebSocket::Close(uint16_t code, const Var& reason, | 58 int32_t WebSocket::Close(PP_WebSocketStatusCode code, const Var& reason, |
| 59 const CompletionCallback& callback) { | 59 const CompletionCallback& callback) { |
| 60 if (!has_interface<PPB_WebSocket_1_0>()) | 60 if (!has_interface<PPB_WebSocket_1_0>()) |
| 61 return PP_ERROR_BADRESOURCE; | 61 return PP_ERROR_BADRESOURCE; |
| 62 | 62 |
| 63 return get_interface<PPB_WebSocket_1_0>()->Close( | 63 return get_interface<PPB_WebSocket_1_0>()->Close( |
| 64 pp_resource(), code, reason.pp_var(), | 64 pp_resource(), code, reason.pp_var(), |
| 65 callback.pp_completion_callback()); | 65 callback.pp_completion_callback()); |
| 66 } | 66 } |
| 67 | 67 |
| 68 int32_t WebSocket::ReceiveMessage(Var* message, | 68 int32_t WebSocket::ReceiveMessage(Var* message, |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 | 139 |
| 140 Var WebSocket::GetURL() { | 140 Var WebSocket::GetURL() { |
| 141 if (!has_interface<PPB_WebSocket_1_0>()) | 141 if (!has_interface<PPB_WebSocket_1_0>()) |
| 142 return Var(); | 142 return Var(); |
| 143 | 143 |
| 144 return Var(PASS_REF, | 144 return Var(PASS_REF, |
| 145 get_interface<PPB_WebSocket_1_0>()->GetURL(pp_resource())); | 145 get_interface<PPB_WebSocket_1_0>()->GetURL(pp_resource())); |
| 146 } | 146 } |
| 147 | 147 |
| 148 } // namespace pp | 148 } // namespace pp |
| OLD | NEW |