Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(231)

Side by Side Diff: webkit/plugins/ppapi/ppb_websocket_impl.cc

Issue 8989046: WebSocket Pepper API: add interfaces to handle binaryType attribute (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix reviewed points Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/plugins/ppapi/ppb_websocket_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 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"
11 #include "base/logging.h" 11 #include "base/logging.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 bool InValidStateToReceive(PP_WebSocketReadyState_Dev state) { 68 bool InValidStateToReceive(PP_WebSocketReadyState_Dev state) {
69 return state == PP_WEBSOCKETREADYSTATE_OPEN_DEV || 69 return state == PP_WEBSOCKETREADYSTATE_OPEN_DEV ||
70 state == PP_WEBSOCKETREADYSTATE_CLOSING_DEV; 70 state == PP_WEBSOCKETREADYSTATE_CLOSING_DEV;
71 } 71 }
72 72
73 } // namespace 73 } // namespace
74 74
75 namespace webkit { 75 namespace webkit {
76 namespace ppapi { 76 namespace ppapi {
77 77
78 // TODO(toyoshim): Default value of binary_type_ must be
79 // PP_WEBSOCKETBINARYTYPE_BLOB_DEV after supporting Blob.
78 PPB_WebSocket_Impl::PPB_WebSocket_Impl(PP_Instance instance) 80 PPB_WebSocket_Impl::PPB_WebSocket_Impl(PP_Instance instance)
79 : Resource(instance), 81 : Resource(instance),
80 state_(PP_WEBSOCKETREADYSTATE_INVALID_DEV), 82 state_(PP_WEBSOCKETREADYSTATE_INVALID_DEV),
83 binary_type_(PP_WEBSOCKETBINARYTYPE_ARRAYBUFFER_DEV),
81 error_was_received_(false), 84 error_was_received_(false),
82 receive_callback_var_(NULL), 85 receive_callback_var_(NULL),
83 wait_for_receive_(false), 86 wait_for_receive_(false),
84 close_code_(0), 87 close_code_(0),
85 close_was_clean_(PP_FALSE), 88 close_was_clean_(PP_FALSE),
86 empty_string_(new StringVar("", 0)), 89 empty_string_(new StringVar("", 0)),
87 buffered_amount_(0), 90 buffered_amount_(0),
88 buffered_amount_after_close_(0) { 91 buffered_amount_after_close_(0) {
89 } 92 }
90 93
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 PP_WebSocketReadyState_Dev PPB_WebSocket_Impl::GetReadyState() { 415 PP_WebSocketReadyState_Dev PPB_WebSocket_Impl::GetReadyState() {
413 return state_; 416 return state_;
414 } 417 }
415 418
416 PP_Var PPB_WebSocket_Impl::GetURL() { 419 PP_Var PPB_WebSocket_Impl::GetURL() {
417 if (!url_) 420 if (!url_)
418 return empty_string_->GetPPVar(); 421 return empty_string_->GetPPVar();
419 return url_->GetPPVar(); 422 return url_->GetPPVar();
420 } 423 }
421 424
425 PP_Bool PPB_WebSocket_Impl::SetBinaryType(
426 PP_WebSocketBinaryType_Dev binary_type) {
427 // TODO(toyoshim): Use WebKit new API to set the receiving binary type.
428 return PP_FALSE;
429 }
430
431 PP_WebSocketBinaryType_Dev PPB_WebSocket_Impl::GetBinaryType() {
432 return binary_type_;
433 }
434
422 void PPB_WebSocket_Impl::didConnect() { 435 void PPB_WebSocket_Impl::didConnect() {
423 DCHECK_EQ(PP_WEBSOCKETREADYSTATE_CONNECTING_DEV, state_); 436 DCHECK_EQ(PP_WEBSOCKETREADYSTATE_CONNECTING_DEV, state_);
424 state_ = PP_WEBSOCKETREADYSTATE_OPEN_DEV; 437 state_ = PP_WEBSOCKETREADYSTATE_OPEN_DEV;
425 TrackedCallback::ClearAndRun(&connect_callback_, PP_OK); 438 TrackedCallback::ClearAndRun(&connect_callback_, PP_OK);
426 } 439 }
427 440
428 void PPB_WebSocket_Impl::didReceiveMessage(const WebString& message) { 441 void PPB_WebSocket_Impl::didReceiveMessage(const WebString& message) {
429 // Dispose packets after receiving an error or in invalid state. 442 // Dispose packets after receiving an error or in invalid state.
430 if (error_was_received_ || !InValidStateToReceive(state_)) 443 if (error_was_received_ || !InValidStateToReceive(state_))
431 return; 444 return;
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 550
538 *receive_callback_var_ = received_messages_.front(); 551 *receive_callback_var_ = received_messages_.front();
539 received_messages_.pop(); 552 received_messages_.pop();
540 receive_callback_var_ = NULL; 553 receive_callback_var_ = NULL;
541 wait_for_receive_ = false; 554 wait_for_receive_ = false;
542 return PP_OK; 555 return PP_OK;
543 } 556 }
544 557
545 } // namespace ppapi 558 } // namespace ppapi
546 } // namespace webkit 559 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/ppb_websocket_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698