OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "net/websockets/websocket_channel.h" | 5 #include "net/websockets/websocket_channel.h" |
6 | 6 |
7 #include <limits.h> | 7 #include <limits.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <string.h> | 9 #include <string.h> |
10 | 10 |
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 MOCK_CONST_METHOD0(GetSubProtocol, std::string()); | 692 MOCK_CONST_METHOD0(GetSubProtocol, std::string()); |
693 MOCK_CONST_METHOD0(GetExtensions, std::string()); | 693 MOCK_CONST_METHOD0(GetExtensions, std::string()); |
694 MOCK_METHOD0(AsWebSocketStream, WebSocketStream*()); | 694 MOCK_METHOD0(AsWebSocketStream, WebSocketStream*()); |
695 }; | 695 }; |
696 | 696 |
697 struct ArgumentCopyingWebSocketStreamCreator { | 697 struct ArgumentCopyingWebSocketStreamCreator { |
698 std::unique_ptr<WebSocketStreamRequest> Create( | 698 std::unique_ptr<WebSocketStreamRequest> Create( |
699 const GURL& socket_url, | 699 const GURL& socket_url, |
700 const std::vector<std::string>& requested_subprotocols, | 700 const std::vector<std::string>& requested_subprotocols, |
701 const url::Origin& origin, | 701 const url::Origin& origin, |
| 702 const std::string& additional_headers, |
702 URLRequestContext* url_request_context, | 703 URLRequestContext* url_request_context, |
703 const BoundNetLog& net_log, | 704 const BoundNetLog& net_log, |
704 std::unique_ptr<WebSocketStream::ConnectDelegate> connect_delegate) { | 705 std::unique_ptr<WebSocketStream::ConnectDelegate> connect_delegate) { |
705 this->socket_url = socket_url; | 706 this->socket_url = socket_url; |
706 this->requested_subprotocols = requested_subprotocols; | 707 this->requested_subprotocols = requested_subprotocols; |
707 this->origin = origin; | 708 this->origin = origin; |
708 this->url_request_context = url_request_context; | 709 this->url_request_context = url_request_context; |
709 this->net_log = net_log; | 710 this->net_log = net_log; |
710 this->connect_delegate = std::move(connect_delegate); | 711 this->connect_delegate = std::move(connect_delegate); |
711 return base::WrapUnique(new WebSocketStreamRequest); | 712 return base::WrapUnique(new WebSocketStreamRequest); |
(...skipping 25 matching lines...) Expand all Loading... |
737 class WebSocketChannelTest : public ::testing::Test { | 738 class WebSocketChannelTest : public ::testing::Test { |
738 protected: | 739 protected: |
739 WebSocketChannelTest() : stream_(new FakeWebSocketStream) {} | 740 WebSocketChannelTest() : stream_(new FakeWebSocketStream) {} |
740 | 741 |
741 // Creates a new WebSocketChannel and connects it, using the settings stored | 742 // Creates a new WebSocketChannel and connects it, using the settings stored |
742 // in |connect_data_|. | 743 // in |connect_data_|. |
743 void CreateChannelAndConnect() { | 744 void CreateChannelAndConnect() { |
744 channel_.reset(new WebSocketChannel(CreateEventInterface(), | 745 channel_.reset(new WebSocketChannel(CreateEventInterface(), |
745 &connect_data_.url_request_context)); | 746 &connect_data_.url_request_context)); |
746 channel_->SendAddChannelRequestForTesting( | 747 channel_->SendAddChannelRequestForTesting( |
747 connect_data_.socket_url, | 748 connect_data_.socket_url, connect_data_.requested_subprotocols, |
748 connect_data_.requested_subprotocols, | 749 connect_data_.origin, "", |
749 connect_data_.origin, | |
750 base::Bind(&ArgumentCopyingWebSocketStreamCreator::Create, | 750 base::Bind(&ArgumentCopyingWebSocketStreamCreator::Create, |
751 base::Unretained(&connect_data_.creator))); | 751 base::Unretained(&connect_data_.creator))); |
752 } | 752 } |
753 | 753 |
754 // Same as CreateChannelAndConnect(), but calls the on_success callback as | 754 // Same as CreateChannelAndConnect(), but calls the on_success callback as |
755 // well. This method is virtual so that subclasses can also set the stream. | 755 // well. This method is virtual so that subclasses can also set the stream. |
756 virtual void CreateChannelAndConnectSuccessfully() { | 756 virtual void CreateChannelAndConnectSuccessfully() { |
757 CreateChannelAndConnect(); | 757 CreateChannelAndConnect(); |
758 // Most tests aren't concerned with flow control from the renderer, so allow | 758 // Most tests aren't concerned with flow control from the renderer, so allow |
759 // MAX_INT quota units. | 759 // MAX_INT quota units. |
(...skipping 2732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3492 | 3492 |
3493 channel_->SendFrame( | 3493 channel_->SendFrame( |
3494 true, WebSocketFrameHeader::kOpCodeText, | 3494 true, WebSocketFrameHeader::kOpCodeText, |
3495 std::vector<char>(static_cast<size_t>(kMessageSize), 'a')); | 3495 std::vector<char>(static_cast<size_t>(kMessageSize), 'a')); |
3496 int new_send_quota = channel_->current_send_quota(); | 3496 int new_send_quota = channel_->current_send_quota(); |
3497 EXPECT_EQ(kMessageSize, initial_send_quota - new_send_quota); | 3497 EXPECT_EQ(kMessageSize, initial_send_quota - new_send_quota); |
3498 } | 3498 } |
3499 | 3499 |
3500 } // namespace | 3500 } // namespace |
3501 } // namespace net | 3501 } // namespace net |
OLD | NEW |