| 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/utility/websocket/websocket_api.h" | 5 #include "ppapi/utility/websocket/websocket_api.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/instance.h" | 9 #include "ppapi/cpp/instance.h" |
| 10 #include "ppapi/cpp/module.h" | 10 #include "ppapi/cpp/module.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 if (result != PP_OK_COMPLETIONPENDING) { | 34 if (result != PP_OK_COMPLETIONPENDING) { |
| 35 // In synchronous cases, consumes callback here and invokes callback | 35 // In synchronous cases, consumes callback here and invokes callback |
| 36 // with PP_ERROR_ABORTED instead of result in order to avoid side effects | 36 // with PP_ERROR_ABORTED instead of result in order to avoid side effects |
| 37 // in DidConnect. DidConnect ignores this invocation and doesn't call | 37 // in DidConnect. DidConnect ignores this invocation and doesn't call |
| 38 // any delegate virtual method. | 38 // any delegate virtual method. |
| 39 callback.Run(PP_ERROR_ABORTED); | 39 callback.Run(PP_ERROR_ABORTED); |
| 40 } | 40 } |
| 41 return result; | 41 return result; |
| 42 } | 42 } |
| 43 | 43 |
| 44 int32_t Close(uint16_t code, const Var& reason) { | 44 int32_t Close(PP_WebSocketStatusCode code, const Var& reason) { |
| 45 CompletionCallback callback = | 45 CompletionCallback callback = |
| 46 callback_factory_.NewOptionalCallback(&Implement::DidClose); | 46 callback_factory_.NewOptionalCallback(&Implement::DidClose); |
| 47 int32_t result = WebSocket::Close(code, reason, callback); | 47 int32_t result = WebSocket::Close(code, reason, callback); |
| 48 if (result != PP_OK_COMPLETIONPENDING) { | 48 if (result != PP_OK_COMPLETIONPENDING) { |
| 49 // In synchronous cases, consumes callback here and invokes callback | 49 // In synchronous cases, consumes callback here and invokes callback |
| 50 // with PP_ERROR_ABORTED instead of result in order to avoid side effects | 50 // with PP_ERROR_ABORTED instead of result in order to avoid side effects |
| 51 // in DidConnect. DidConnect ignores this invocation and doesn't call | 51 // in DidConnect. DidConnect ignores this invocation and doesn't call |
| 52 // any delegate virtual method. | 52 // any delegate virtual method. |
| 53 callback.Run(PP_ERROR_ABORTED); | 53 callback.Run(PP_ERROR_ABORTED); |
| 54 } | 54 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 | 105 |
| 106 WebSocketAPI::~WebSocketAPI() { | 106 WebSocketAPI::~WebSocketAPI() { |
| 107 delete impl_; | 107 delete impl_; |
| 108 } | 108 } |
| 109 | 109 |
| 110 int32_t WebSocketAPI::Connect(const Var& url, const Var protocols[], | 110 int32_t WebSocketAPI::Connect(const Var& url, const Var protocols[], |
| 111 uint32_t protocol_count) { | 111 uint32_t protocol_count) { |
| 112 return impl_->Connect(url, protocols, protocol_count); | 112 return impl_->Connect(url, protocols, protocol_count); |
| 113 } | 113 } |
| 114 | 114 |
| 115 int32_t WebSocketAPI::Close(uint16_t code, const Var& reason) { | 115 int32_t WebSocketAPI::Close(PP_WebSocketStatusCode code, const Var& reason) { |
| 116 return impl_->Close(code, reason); | 116 return impl_->Close(code, reason); |
| 117 } | 117 } |
| 118 | 118 |
| 119 int32_t WebSocketAPI::Send(const Var& data) { | 119 int32_t WebSocketAPI::Send(const Var& data) { |
| 120 return impl_->SendMessage(data); | 120 return impl_->SendMessage(data); |
| 121 } | 121 } |
| 122 | 122 |
| 123 uint64_t WebSocketAPI::GetBufferedAmount() { | 123 uint64_t WebSocketAPI::GetBufferedAmount() { |
| 124 return impl_->GetBufferedAmount(); | 124 return impl_->GetBufferedAmount(); |
| 125 } | 125 } |
| 126 | 126 |
| 127 Var WebSocketAPI::GetExtensions() { | 127 Var WebSocketAPI::GetExtensions() { |
| 128 return impl_->GetExtensions(); | 128 return impl_->GetExtensions(); |
| 129 } | 129 } |
| 130 | 130 |
| 131 Var WebSocketAPI::GetProtocol() { | 131 Var WebSocketAPI::GetProtocol() { |
| 132 return impl_->GetProtocol(); | 132 return impl_->GetProtocol(); |
| 133 } | 133 } |
| 134 | 134 |
| 135 PP_WebSocketReadyState WebSocketAPI::GetReadyState() { | 135 PP_WebSocketReadyState WebSocketAPI::GetReadyState() { |
| 136 return impl_->GetReadyState(); | 136 return impl_->GetReadyState(); |
| 137 } | 137 } |
| 138 | 138 |
| 139 Var WebSocketAPI::GetURL() { | 139 Var WebSocketAPI::GetURL() { |
| 140 return impl_->GetURL(); | 140 return impl_->GetURL(); |
| 141 } | 141 } |
| 142 | 142 |
| 143 } // namespace pp | 143 } // namespace pp |
| OLD | NEW |