| 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 "webkit/plugins/ppapi/ppb_websocket_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_websocket_impl.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 if (reason.type != PP_VARTYPE_UNDEFINED) { | 229 if (reason.type != PP_VARTYPE_UNDEFINED) { |
| 230 // Validate |reason|. | 230 // Validate |reason|. |
| 231 reason_string = StringVar::FromPPVar(reason); | 231 reason_string = StringVar::FromPPVar(reason); |
| 232 if (!reason_string || | 232 if (!reason_string || |
| 233 reason_string->value().size() > kMaxReasonSizeInBytes) | 233 reason_string->value().size() > kMaxReasonSizeInBytes) |
| 234 return PP_ERROR_BADARGUMENT; | 234 return PP_ERROR_BADARGUMENT; |
| 235 web_reason = WebString::fromUTF8(reason_string->value()); | 235 web_reason = WebString::fromUTF8(reason_string->value()); |
| 236 } | 236 } |
| 237 | 237 |
| 238 // Check state. | 238 // Check state. |
| 239 if (state_ == PP_WEBSOCKETREADYSTATE_CLOSING || | 239 if (state_ == PP_WEBSOCKETREADYSTATE_CLOSING) |
| 240 state_ == PP_WEBSOCKETREADYSTATE_CLOSED) | |
| 241 return PP_ERROR_INPROGRESS; | 240 return PP_ERROR_INPROGRESS; |
| 241 if (state_ == PP_WEBSOCKETREADYSTATE_CLOSED) |
| 242 return PP_OK; |
| 242 | 243 |
| 243 // Validate |callback| (Doesn't support blocking callback) | 244 // Validate |callback| (Doesn't support blocking callback) |
| 244 if (!callback.func) | 245 if (!callback.func) |
| 245 return PP_ERROR_BLOCKS_MAIN_THREAD; | 246 return PP_ERROR_BLOCKS_MAIN_THREAD; |
| 246 | 247 |
| 247 // Install |callback|. | 248 // Install |callback|. |
| 248 close_callback_ = new TrackedCallback(this, callback); | 249 close_callback_ = new TrackedCallback(this, callback); |
| 249 | 250 |
| 250 // Abort ongoing connect. | 251 // Abort ongoing connect. |
| 251 if (state_ == PP_WEBSOCKETREADYSTATE_CONNECTING) { | 252 if (state_ == PP_WEBSOCKETREADYSTATE_CONNECTING) { |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 | 529 |
| 529 *receive_callback_var_ = received_messages_.front()->GetPPVar(); | 530 *receive_callback_var_ = received_messages_.front()->GetPPVar(); |
| 530 received_messages_.pop(); | 531 received_messages_.pop(); |
| 531 receive_callback_var_ = NULL; | 532 receive_callback_var_ = NULL; |
| 532 wait_for_receive_ = false; | 533 wait_for_receive_ = false; |
| 533 return PP_OK; | 534 return PP_OK; |
| 534 } | 535 } |
| 535 | 536 |
| 536 } // namespace ppapi | 537 } // namespace ppapi |
| 537 } // namespace webkit | 538 } // namespace webkit |
| OLD | NEW |