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

Side by Side Diff: blimp/client/session/blimp_client_session.cc

Issue 1696563002: Blimp: add support for SSL connections. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
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 "blimp/client/session/blimp_client_session.h" 5 #include "blimp/client/session/blimp_client_session.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/numerics/safe_conversions.h" 11 #include "base/numerics/safe_conversions.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/threading/sequenced_task_runner_handle.h" 13 #include "base/threading/sequenced_task_runner_handle.h"
14 #include "blimp/client/app/blimp_client_switches.h" 14 #include "blimp/client/app/blimp_client_switches.h"
15 #include "blimp/client/feature/navigation_feature.h" 15 #include "blimp/client/feature/navigation_feature.h"
16 #include "blimp/client/feature/render_widget_feature.h" 16 #include "blimp/client/feature/render_widget_feature.h"
17 #include "blimp/client/feature/tab_control_feature.h" 17 #include "blimp/client/feature/tab_control_feature.h"
18 #include "blimp/net/blimp_message_processor.h" 18 #include "blimp/net/blimp_message_processor.h"
19 #include "blimp/net/blimp_message_thread_pipe.h" 19 #include "blimp/net/blimp_message_thread_pipe.h"
20 #include "blimp/net/browser_connection_handler.h" 20 #include "blimp/net/browser_connection_handler.h"
21 #include "blimp/net/client_connection_manager.h" 21 #include "blimp/net/client_connection_manager.h"
22 #include "blimp/net/common.h" 22 #include "blimp/net/common.h"
23 #include "blimp/net/null_blimp_message_processor.h" 23 #include "blimp/net/null_blimp_message_processor.h"
24 #include "blimp/net/ssl_client_transport.h"
24 #include "blimp/net/tcp_client_transport.h" 25 #include "blimp/net/tcp_client_transport.h"
25 #include "net/base/address_list.h" 26 #include "net/base/address_list.h"
26 #include "net/base/ip_address.h" 27 #include "net/base/ip_address.h"
27 #include "net/base/ip_endpoint.h" 28 #include "net/base/ip_endpoint.h"
28 29
29 namespace blimp { 30 namespace blimp {
30 namespace client { 31 namespace client {
32 namespace {
33
34 net::AddressList CreateAddressList(const std::vector<net::IPAddress>& addresses,
35 int16_t port) {
36 net::AddressList output_list;
37 for (const auto& next_address : addresses) {
38 output_list.push_back(net::IPEndPoint(next_address, port));
39 }
40 return output_list;
41 }
42
43 } // namespace
31 44
32 // This class's functions and destruction are all invoked on the IO thread by 45 // This class's functions and destruction are all invoked on the IO thread by
33 // the BlimpClientSession. 46 // the BlimpClientSession.
34 // TODO(haibinlu): crbug/574884 47 // TODO(haibinlu): crbug/574884
35 class ClientNetworkComponents { 48 class ClientNetworkComponents {
36 public: 49 public:
37 // Can be created on any thread. 50 // Can be created on any thread.
38 ClientNetworkComponents() {} 51 ClientNetworkComponents() {}
39 52
40 ~ClientNetworkComponents() {} 53 ~ClientNetworkComponents() {}
(...skipping 17 matching lines...) Expand all
58 scoped_ptr<ClientConnectionManager> connection_manager_; 71 scoped_ptr<ClientConnectionManager> connection_manager_;
59 72
60 // Container for the feature-specific MessageProcessors. 73 // Container for the feature-specific MessageProcessors.
61 std::vector<scoped_ptr<BlimpMessageProcessor>> incoming_proxies_; 74 std::vector<scoped_ptr<BlimpMessageProcessor>> incoming_proxies_;
62 75
63 // Containers for the MessageProcessors used to write feature-specific 76 // Containers for the MessageProcessors used to write feature-specific
64 // messages to the network, and the thread-pipe endpoints through which 77 // messages to the network, and the thread-pipe endpoints through which
65 // they are used from the UI thread. 78 // they are used from the UI thread.
66 std::vector<scoped_ptr<BlimpMessageThreadPipe>> outgoing_pipes_; 79 std::vector<scoped_ptr<BlimpMessageThreadPipe>> outgoing_pipes_;
67 std::vector<scoped_ptr<BlimpMessageProcessor>> outgoing_message_processors_; 80 std::vector<scoped_ptr<BlimpMessageProcessor>> outgoing_message_processors_;
68
69 DISALLOW_COPY_AND_ASSIGN(ClientNetworkComponents); 81 DISALLOW_COPY_AND_ASSIGN(ClientNetworkComponents);
70 }; 82 };
71 83
72 void ClientNetworkComponents::Initialize() { 84 void ClientNetworkComponents::Initialize() {
73 DCHECK(!connection_manager_); 85 DCHECK(!connection_manager_);
74 connection_manager_ = make_scoped_ptr( 86 connection_manager_ = make_scoped_ptr(
75 new ClientConnectionManager(browser_connection_handler_.get())); 87 new ClientConnectionManager(browser_connection_handler_.get()));
76 } 88 }
77 89
78 void ClientNetworkComponents::ConnectWithAssignment( 90 void ClientNetworkComponents::ConnectWithAssignment(
79 const Assignment& assignment) { 91 const Assignment& assignment) {
80 DCHECK(connection_manager_); 92 DCHECK(connection_manager_);
81 connection_manager_->set_client_token(assignment.client_token); 93 connection_manager_->set_client_token(assignment.client_token);
82 94
83 connection_manager_->AddTransport(make_scoped_ptr(new TCPClientTransport( 95 if (assignment.ssl_port > 0) {
84 net::AddressList(assignment.ip_endpoint), nullptr))); 96 if (assignment.cert) {
97 connection_manager_->AddTransport(make_scoped_ptr(new SSLClientTransport(
98 CreateAddressList(assignment.ip_addresses, assignment.ssl_port),
99 assignment.cert, nullptr)));
100 } else {
101 DLOG(FATAL) << "SSL port provided but no cert was found.";
Wez 2016/02/12 02:31:14 This check should be at the command-line parsing l
Kevin M 2016/02/13 00:44:18 Done.
102 }
103 }
104
105 if (assignment.tcp_port > 0) {
106 connection_manager_->AddTransport(make_scoped_ptr(new TCPClientTransport(
107 CreateAddressList(assignment.ip_addresses, assignment.tcp_port),
108 nullptr)));
109 }
85 110
86 connection_manager_->Connect(); 111 connection_manager_->Connect();
87 } 112 }
88 113
89 void ClientNetworkComponents::RegisterFeature( 114 void ClientNetworkComponents::RegisterFeature(
90 BlimpMessage::Type type, 115 BlimpMessage::Type type,
91 scoped_ptr<BlimpMessageThreadPipe> outgoing_pipe, 116 scoped_ptr<BlimpMessageThreadPipe> outgoing_pipe,
92 scoped_ptr<BlimpMessageProcessor> incoming_proxy) { 117 scoped_ptr<BlimpMessageProcessor> incoming_proxy) {
93 if (!browser_connection_handler_) { 118 if (!browser_connection_handler_) {
94 browser_connection_handler_ = make_scoped_ptr(new BrowserConnectionHandler); 119 browser_connection_handler_ = make_scoped_ptr(new BrowserConnectionHandler);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 NavigationFeature* BlimpClientSession::GetNavigationFeature() const { 217 NavigationFeature* BlimpClientSession::GetNavigationFeature() const {
193 return navigation_feature_.get(); 218 return navigation_feature_.get();
194 } 219 }
195 220
196 RenderWidgetFeature* BlimpClientSession::GetRenderWidgetFeature() const { 221 RenderWidgetFeature* BlimpClientSession::GetRenderWidgetFeature() const {
197 return render_widget_feature_.get(); 222 return render_widget_feature_.get();
198 } 223 }
199 224
200 } // namespace client 225 } // namespace client
201 } // namespace blimp 226 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698