Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1219)

Side by Side Diff: blimp/client/core/session/client_network_components.cc

Issue 2439403003: Refactor BlimpConnection to TCPConnection (Closed)
Patch Set: Sync merge Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
(...skipping 17 matching lines...) Expand all
28 connection_manager_ = base::MakeUnique<ClientConnectionManager>(this); 28 connection_manager_ = base::MakeUnique<ClientConnectionManager>(this);
29 } 29 }
30 30
31 void ClientNetworkComponents::ConnectWithAssignment( 31 void ClientNetworkComponents::ConnectWithAssignment(
32 const Assignment& assignment) { 32 const Assignment& assignment) {
33 DCHECK(io_thread_checker_.CalledOnValidThread()); 33 DCHECK(io_thread_checker_.CalledOnValidThread());
34 DCHECK(connection_manager_); 34 DCHECK(connection_manager_);
35 35
36 connection_manager_->set_client_auth_token(assignment.client_auth_token); 36 connection_manager_->set_client_auth_token(assignment.client_auth_token);
37 const char* transport_type = "UNKNOWN"; 37 const char* transport_type = "UNKNOWN";
38 auto endpoint = assignment.engine_endpoint.ToString();
Garrett Casto 2016/10/25 18:33:49 Nit: I'm not sure why you pulled this out. It does
Kevin M 2016/10/25 18:49:22 Just inline this in VLOG? Otherwise we are computi
perumaal 2016/10/25 23:02:38 Done.
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.engine_endpoint, std::move(assignment.cert), nullptr));
43 transport_type = "SSL"; 44 transport_type = "SSL";
44 break; 45 break;
45 case Assignment::TCP: 46 case Assignment::TCP:
46 connection_manager_->AddTransport(base::MakeUnique<TCPClientTransport>( 47 connection_manager_->AddTransport(base::MakeUnique<TCPClientTransport>(
47 assignment.engine_endpoint, nullptr)); 48 assignment.engine_endpoint, nullptr));
48 transport_type = "TCP"; 49 transport_type = "TCP";
49 break; 50 break;
51 case Assignment::GRPC:
52 // TODO(perumaal): Unimplemented as yet.
Kevin M 2016/10/25 18:49:22 NOTIMPLEMENTED() ?
perumaal 2016/10/25 23:02:38 Nice! thx
53 // connection_manager_->AddTransport(
54 // base::MakeUnique<GrpcClientTransport>(endpoint));
55 transport_type = "GRPC";
56 LOG(FATAL) << "Not yet implemented!";
57 break;
50 case Assignment::UNKNOWN: 58 case Assignment::UNKNOWN:
51 LOG(FATAL) << "Unknown transport type."; 59 LOG(FATAL) << "Unknown transport type.";
52 break; 60 break;
53 } 61 }
54 62
55 VLOG(1) << "Connecting to " << assignment.engine_endpoint.ToString() << " (" 63 VLOG(1) << "Connecting to " << endpoint << " (" << transport_type << ")";
56 << transport_type << ")";
57 64
58 connection_manager_->Connect(); 65 connection_manager_->Connect();
59 } 66 }
60 67
61 BrowserConnectionHandler* 68 BrowserConnectionHandler*
62 ClientNetworkComponents::GetBrowserConnectionHandler() { 69 ClientNetworkComponents::GetBrowserConnectionHandler() {
63 DCHECK(io_thread_checker_.CalledOnValidThread()); 70 DCHECK(io_thread_checker_.CalledOnValidThread());
64 return &connection_handler_; 71 return &connection_handler_;
65 } 72 }
66 73
(...skipping 11 matching lines...) Expand all
78 if (result >= 0) { 85 if (result >= 0) {
79 VLOG(1) << "Disconnected with reason: " << result; 86 VLOG(1) << "Disconnected with reason: " << result;
80 } else { 87 } else {
81 VLOG(1) << "Connection error: " << net::ErrorToString(result); 88 VLOG(1) << "Connection error: " << net::ErrorToString(result);
82 } 89 }
83 network_observer_->OnDisconnected(result); 90 network_observer_->OnDisconnected(result);
84 } 91 }
85 92
86 } // namespace client 93 } // namespace client
87 } // namespace blimp 94 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698