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