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

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

Issue 2624903006: Remove all blimp client code. (Closed)
Patch Set: Update buildbot configuration Created 3 years, 11 months 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "blimp/client/core/session/client_network_components.h"
6
7 #include <utility>
8
9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h"
11 #include "blimp/net/ssl_client_transport.h"
12 #include "net/base/net_errors.h"
13
14 namespace blimp {
15 namespace client {
16
17 ClientNetworkComponents::ClientNetworkComponents(
18 std::unique_ptr<NetworkEventObserver> network_observer)
19 : connection_handler_(), network_observer_(std::move(network_observer)) {}
20
21 ClientNetworkComponents::~ClientNetworkComponents() {
22 DCHECK(io_thread_checker_.CalledOnValidThread());
23 }
24
25 void ClientNetworkComponents::Initialize() {
26 io_thread_checker_.DetachFromThread();
27 DCHECK(!connection_manager_);
28 connection_manager_ = base::MakeUnique<ClientConnectionManager>(this);
29 }
30
31 void ClientNetworkComponents::ConnectWithAssignment(
32 const Assignment& assignment) {
33 DCHECK(io_thread_checker_.CalledOnValidThread());
34 DCHECK(connection_manager_);
35
36 connection_manager_->set_client_auth_token(assignment.client_auth_token);
37 const char* transport_type = "UNKNOWN";
38 switch (assignment.transport_protocol) {
39 case Assignment::SSL:
40 DCHECK(assignment.cert);
41 connection_manager_->AddTransport(base::MakeUnique<SSLClientTransport>(
42 assignment.engine_endpoint, std::move(assignment.cert), nullptr));
43 transport_type = "SSL";
44 break;
45 case Assignment::TCP:
46 connection_manager_->AddTransport(base::MakeUnique<TCPClientTransport>(
47 assignment.engine_endpoint, nullptr));
48 transport_type = "TCP";
49 break;
50 case Assignment::GRPC:
51 // TODO(perumaal): Unimplemented as yet.
52 // connection_manager_->AddTransport(
53 // base::MakeUnique<GrpcClientTransport>(endpoint));
54 transport_type = "GRPC";
55 NOTIMPLEMENTED();
56 break;
57 case Assignment::UNKNOWN:
58 LOG(FATAL) << "Unknown transport type.";
59 break;
60 }
61
62 VLOG(1) << "Connecting to " << assignment.engine_endpoint.ToString() << " ("
63 << transport_type << ")";
64
65 connection_manager_->Connect();
66 }
67
68 BrowserConnectionHandler*
69 ClientNetworkComponents::GetBrowserConnectionHandler() {
70 DCHECK(io_thread_checker_.CalledOnValidThread());
71 return &connection_handler_;
72 }
73
74 void ClientNetworkComponents::HandleConnection(
75 std::unique_ptr<BlimpConnection> connection) {
76 DCHECK(io_thread_checker_.CalledOnValidThread());
77 VLOG(1) << "Connection established.";
78 connection->AddConnectionErrorObserver(this);
79 connection_handler_.HandleConnection(std::move(connection));
80 network_observer_->OnConnected();
81 }
82
83 void ClientNetworkComponents::OnConnectionError(int result) {
84 DCHECK(io_thread_checker_.CalledOnValidThread());
85 if (result >= 0) {
86 VLOG(1) << "Disconnected with reason: " << result;
87 } else {
88 VLOG(1) << "Connection error: " << net::ErrorToString(result);
89 }
90 network_observer_->OnDisconnected(result);
91 }
92
93 } // namespace client
94 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/client/core/session/client_network_components.h ('k') | blimp/client/core/session/connection_status.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698