| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "base/logging.h" | 5 #include "base/logging.h" |
| 6 #include "base/macros.h" | 6 #include "base/macros.h" |
| 7 #include "base/memory/linked_ptr.h" | 7 #include "base/memory/linked_ptr.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 ~WebSocketClientImpl() override {} | 278 ~WebSocketClientImpl() override {} |
| 279 | 279 |
| 280 // Establishes a connection from the client side. | 280 // Establishes a connection from the client side. |
| 281 void Connect(WebSocketPtr web_socket, const std::string& url) { | 281 void Connect(WebSocketPtr web_socket, const std::string& url) { |
| 282 web_socket_ = web_socket.Pass(); | 282 web_socket_ = web_socket.Pass(); |
| 283 | 283 |
| 284 DataPipe data_pipe; | 284 DataPipe data_pipe; |
| 285 send_stream_ = data_pipe.producer_handle.Pass(); | 285 send_stream_ = data_pipe.producer_handle.Pass(); |
| 286 write_send_stream_.reset(new WebSocketWriteQueue(send_stream_.get())); | 286 write_send_stream_.reset(new WebSocketWriteQueue(send_stream_.get())); |
| 287 | 287 |
| 288 web_socket_->Connect(url, Array<String>(0), "http://example.com", | 288 web_socket_->Connect(url, Array<String>::New(0), "http://example.com", |
| 289 data_pipe.consumer_handle.Pass(), | 289 data_pipe.consumer_handle.Pass(), |
| 290 client_handle_.Pass()); | 290 client_handle_.Pass()); |
| 291 } | 291 } |
| 292 | 292 |
| 293 // Establishes a connection from the server side. | 293 // Establishes a connection from the server side. |
| 294 void AcceptConnectRequest( | 294 void AcceptConnectRequest( |
| 295 const HttpConnectionDelegate::OnReceivedWebSocketRequestCallback& | 295 const HttpConnectionDelegate::OnReceivedWebSocketRequestCallback& |
| 296 callback) { | 296 callback) { |
| 297 InterfaceRequest<WebSocket> web_socket_request = GetProxy(&web_socket_); | 297 InterfaceRequest<WebSocket> web_socket_request = GetProxy(&web_socket_); |
| 298 | 298 |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 | 682 |
| 683 socket_1.Send("How do"); | 683 socket_1.Send("How do"); |
| 684 socket_1.Send("you do?"); | 684 socket_1.Send("you do?"); |
| 685 | 685 |
| 686 socket_0.WaitForMessage(2); | 686 socket_0.WaitForMessage(2); |
| 687 EXPECT_EQ("How do", socket_0.received_messages()[0]); | 687 EXPECT_EQ("How do", socket_0.received_messages()[0]); |
| 688 EXPECT_EQ("you do?", socket_0.received_messages()[1]); | 688 EXPECT_EQ("you do?", socket_0.received_messages()[1]); |
| 689 } | 689 } |
| 690 | 690 |
| 691 } // namespace mojo | 691 } // namespace mojo |
| OLD | NEW |