| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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, |
| 69 const CompletionCallback& callback) { | 69 const CompletionCallback& callback) { |
| 70 if (!has_interface<PPB_WebSocket_1_0>()) | 70 if (!has_interface<PPB_WebSocket_1_0>()) |
| 71 return PP_ERROR_BADRESOURCE; | 71 return PP_ERROR_BADRESOURCE; |
| 72 | 72 |
| 73 // Initialize |message| to release old internal PP_Var of reused |message|. |
| 74 if (message) |
| 75 *message = Var(); |
| 76 |
| 73 return get_interface<PPB_WebSocket_1_0>()->ReceiveMessage( | 77 return get_interface<PPB_WebSocket_1_0>()->ReceiveMessage( |
| 74 pp_resource(), const_cast<PP_Var*>(&message->pp_var()), | 78 pp_resource(), const_cast<PP_Var*>(&message->pp_var()), |
| 75 callback.pp_completion_callback()); | 79 callback.pp_completion_callback()); |
| 76 } | 80 } |
| 77 | 81 |
| 78 int32_t WebSocket::SendMessage(const Var& message) { | 82 int32_t WebSocket::SendMessage(const Var& message) { |
| 79 if (!has_interface<PPB_WebSocket_1_0>()) | 83 if (!has_interface<PPB_WebSocket_1_0>()) |
| 80 return PP_ERROR_BADRESOURCE; | 84 return PP_ERROR_BADRESOURCE; |
| 81 | 85 |
| 82 return get_interface<PPB_WebSocket_1_0>()->SendMessage( | 86 return get_interface<PPB_WebSocket_1_0>()->SendMessage( |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 | 143 |
| 140 Var WebSocket::GetURL() { | 144 Var WebSocket::GetURL() { |
| 141 if (!has_interface<PPB_WebSocket_1_0>()) | 145 if (!has_interface<PPB_WebSocket_1_0>()) |
| 142 return Var(); | 146 return Var(); |
| 143 | 147 |
| 144 return Var(PASS_REF, | 148 return Var(PASS_REF, |
| 145 get_interface<PPB_WebSocket_1_0>()->GetURL(pp_resource())); | 149 get_interface<PPB_WebSocket_1_0>()->GetURL(pp_resource())); |
| 146 } | 150 } |
| 147 | 151 |
| 148 } // namespace pp | 152 } // namespace pp |
| OLD | NEW |