| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "blimp/client/core/session/client_network_components.h" | 5 #include "blimp/client/core/session/client_network_components.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "blimp/net/grpc_client_transport.h" |
| 11 #include "blimp/net/ssl_client_transport.h" | 12 #include "blimp/net/ssl_client_transport.h" |
| 12 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
| 13 | 14 |
| 14 namespace blimp { | 15 namespace blimp { |
| 15 namespace client { | 16 namespace client { |
| 16 | 17 |
| 17 ClientNetworkComponents::ClientNetworkComponents( | 18 ClientNetworkComponents::ClientNetworkComponents( |
| 18 std::unique_ptr<NetworkEventObserver> network_observer) | 19 std::unique_ptr<NetworkEventObserver> network_observer) |
| 19 : connection_handler_(), network_observer_(std::move(network_observer)) {} | 20 : connection_handler_(), network_observer_(std::move(network_observer)) {} |
| 20 | 21 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 32 const Assignment& assignment) { | 33 const Assignment& assignment) { |
| 33 DCHECK(io_thread_checker_.CalledOnValidThread()); | 34 DCHECK(io_thread_checker_.CalledOnValidThread()); |
| 34 DCHECK(connection_manager_); | 35 DCHECK(connection_manager_); |
| 35 | 36 |
| 36 connection_manager_->set_client_auth_token(assignment.client_auth_token); | 37 connection_manager_->set_client_auth_token(assignment.client_auth_token); |
| 37 const char* transport_type = "UNKNOWN"; | 38 const char* transport_type = "UNKNOWN"; |
| 38 switch (assignment.transport_protocol) { | 39 switch (assignment.transport_protocol) { |
| 39 case Assignment::SSL: | 40 case Assignment::SSL: |
| 40 DCHECK(assignment.cert); | 41 DCHECK(assignment.cert); |
| 41 connection_manager_->AddTransport(base::MakeUnique<SSLClientTransport>( | 42 connection_manager_->AddTransport(base::MakeUnique<SSLClientTransport>( |
| 42 assignment.engine_endpoint, std::move(assignment.cert), nullptr)); | 43 assignment.assignment_options.engine_endpoint, |
| 44 std::move(assignment.cert), nullptr)); |
| 43 transport_type = "SSL"; | 45 transport_type = "SSL"; |
| 44 break; | 46 break; |
| 45 case Assignment::TCP: | 47 case Assignment::TCP: |
| 46 connection_manager_->AddTransport(base::MakeUnique<TCPClientTransport>( | 48 connection_manager_->AddTransport(base::MakeUnique<TCPClientTransport>( |
| 47 assignment.engine_endpoint, nullptr)); | 49 assignment.assignment_options.engine_endpoint, nullptr)); |
| 48 transport_type = "TCP"; | 50 transport_type = "TCP"; |
| 49 break; | 51 break; |
| 50 case Assignment::GRPC: | 52 case Assignment::GRPC: |
| 51 // TODO(perumaal): Unimplemented as yet. | 53 connection_manager_->AddTransport( |
| 52 // connection_manager_->AddTransport( | 54 base::MakeUnique<GrpcClientTransport>(assignment.assignment_options)); |
| 53 // base::MakeUnique<GrpcClientTransport>(endpoint)); | |
| 54 transport_type = "GRPC"; | 55 transport_type = "GRPC"; |
| 55 NOTIMPLEMENTED(); | |
| 56 break; | 56 break; |
| 57 case Assignment::UNKNOWN: | 57 case Assignment::UNKNOWN: |
| 58 LOG(FATAL) << "Unknown transport type."; | 58 LOG(FATAL) << "Unknown transport type."; |
| 59 break; | 59 break; |
| 60 } | 60 } |
| 61 | 61 |
| 62 VLOG(1) << "Connecting to " << assignment.engine_endpoint.ToString() << " (" | 62 VLOG(1) << "Connecting to " |
| 63 << assignment.assignment_options.engine_endpoint.ToString() << " (" |
| 63 << transport_type << ")"; | 64 << transport_type << ")"; |
| 64 | 65 |
| 65 connection_manager_->Connect(); | 66 connection_manager_->Connect(); |
| 66 } | 67 } |
| 67 | 68 |
| 68 BrowserConnectionHandler* | 69 BrowserConnectionHandler* |
| 69 ClientNetworkComponents::GetBrowserConnectionHandler() { | 70 ClientNetworkComponents::GetBrowserConnectionHandler() { |
| 70 DCHECK(io_thread_checker_.CalledOnValidThread()); | 71 DCHECK(io_thread_checker_.CalledOnValidThread()); |
| 71 return &connection_handler_; | 72 return &connection_handler_; |
| 72 } | 73 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 85 if (result >= 0) { | 86 if (result >= 0) { |
| 86 VLOG(1) << "Disconnected with reason: " << result; | 87 VLOG(1) << "Disconnected with reason: " << result; |
| 87 } else { | 88 } else { |
| 88 VLOG(1) << "Connection error: " << net::ErrorToString(result); | 89 VLOG(1) << "Connection error: " << net::ErrorToString(result); |
| 89 } | 90 } |
| 90 network_observer_->OnDisconnected(result); | 91 network_observer_->OnDisconnected(result); |
| 91 } | 92 } |
| 92 | 93 |
| 93 } // namespace client | 94 } // namespace client |
| 94 } // namespace blimp | 95 } // namespace blimp |
| OLD | NEW |