| 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 <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include <iostream> | 10 #include <iostream> |
| (...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 773 // mock instead. | 773 // mock instead. |
| 774 virtual scoped_ptr<WebSocketEventInterface> CreateEventInterface() { | 774 virtual scoped_ptr<WebSocketEventInterface> CreateEventInterface() { |
| 775 return scoped_ptr<WebSocketEventInterface>(new FakeWebSocketEventInterface); | 775 return scoped_ptr<WebSocketEventInterface>(new FakeWebSocketEventInterface); |
| 776 } | 776 } |
| 777 | 777 |
| 778 // This method serves no other purpose than to provide a nice syntax for | 778 // This method serves no other purpose than to provide a nice syntax for |
| 779 // assigning to stream_. class T must be a subclass of WebSocketStream or you | 779 // assigning to stream_. class T must be a subclass of WebSocketStream or you |
| 780 // will have unpleasant compile errors. | 780 // will have unpleasant compile errors. |
| 781 template <class T> | 781 template <class T> |
| 782 void set_stream(scoped_ptr<T> stream) { | 782 void set_stream(scoped_ptr<T> stream) { |
| 783 // Since the definition of "PassAs" depends on the type T, the C++ standard | 783 stream_ = stream.Pass(); |
| 784 // requires the "template" keyword to indicate that "PassAs" should be | |
| 785 // parsed as a template method. | |
| 786 stream_ = stream.template PassAs<WebSocketStream>(); | |
| 787 } | 784 } |
| 788 | 785 |
| 789 // A struct containing the data that will be used to connect the channel. | 786 // A struct containing the data that will be used to connect the channel. |
| 790 // Grouped for readability. | 787 // Grouped for readability. |
| 791 struct ConnectData { | 788 struct ConnectData { |
| 792 ConnectData() : socket_url("ws://ws/"), origin("http://ws") {} | 789 ConnectData() : socket_url("ws://ws/"), origin("http://ws") {} |
| 793 | 790 |
| 794 // URLRequestContext object. | 791 // URLRequestContext object. |
| 795 URLRequestContext url_request_context; | 792 URLRequestContext url_request_context; |
| 796 | 793 |
| (...skipping 2631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3428 channel_->StartClosingHandshake(kWebSocketNormalClosure, "OK"); | 3425 channel_->StartClosingHandshake(kWebSocketNormalClosure, "OK"); |
| 3429 ASSERT_TRUE(read_frames); | 3426 ASSERT_TRUE(read_frames); |
| 3430 // Provide the "Close" message from the server. | 3427 // Provide the "Close" message from the server. |
| 3431 *read_frames = CreateFrameVector(frames); | 3428 *read_frames = CreateFrameVector(frames); |
| 3432 read_callback.Run(OK); | 3429 read_callback.Run(OK); |
| 3433 completion.WaitForResult(); | 3430 completion.WaitForResult(); |
| 3434 } | 3431 } |
| 3435 | 3432 |
| 3436 } // namespace | 3433 } // namespace |
| 3437 } // namespace net | 3434 } // namespace net |
| OLD | NEW |