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 "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/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
14 #include "base/threading/sequenced_task_runner_handle.h" | 14 #include "base/threading/sequenced_task_runner_handle.h" |
15 #include "blimp/client/app/blimp_client_switches.h" | 15 #include "blimp/client/app/blimp_client_switches.h" |
16 #include "blimp/client/feature/navigation_feature.h" | 16 #include "blimp/client/feature/navigation_feature.h" |
17 #include "blimp/client/feature/render_widget_feature.h" | 17 #include "blimp/client/feature/render_widget_feature.h" |
18 #include "blimp/client/feature/tab_control_feature.h" | 18 #include "blimp/client/feature/tab_control_feature.h" |
19 #include "blimp/net/blimp_message_processor.h" | 19 #include "blimp/net/blimp_message_processor.h" |
20 #include "blimp/net/blimp_message_thread_pipe.h" | 20 #include "blimp/net/blimp_message_thread_pipe.h" |
21 #include "blimp/net/browser_connection_handler.h" | 21 #include "blimp/net/browser_connection_handler.h" |
22 #include "blimp/net/client_connection_manager.h" | 22 #include "blimp/net/client_connection_manager.h" |
23 #include "blimp/net/common.h" | 23 #include "blimp/net/common.h" |
24 #include "blimp/net/null_blimp_message_processor.h" | 24 #include "blimp/net/null_blimp_message_processor.h" |
25 #include "blimp/net/ssl_client_transport.h" | |
26 #include "blimp/net/tcp_client_transport.h" | 25 #include "blimp/net/tcp_client_transport.h" |
27 #include "net/base/address_list.h" | 26 #include "net/base/address_list.h" |
28 #include "net/base/ip_address.h" | 27 #include "net/base/ip_address.h" |
29 #include "net/base/ip_endpoint.h" | 28 #include "net/base/ip_endpoint.h" |
30 | 29 |
31 namespace blimp { | 30 namespace blimp { |
32 namespace client { | 31 namespace client { |
33 | 32 |
34 // This class's functions and destruction are all invoked on the IO thread by | 33 // This class's functions and destruction are all invoked on the IO thread by |
35 // the BlimpClientSession. | 34 // the BlimpClientSession. |
(...skipping 24 matching lines...) Expand all Loading... |
60 scoped_ptr<ClientConnectionManager> connection_manager_; | 59 scoped_ptr<ClientConnectionManager> connection_manager_; |
61 | 60 |
62 // Container for the feature-specific MessageProcessors. | 61 // Container for the feature-specific MessageProcessors. |
63 std::vector<scoped_ptr<BlimpMessageProcessor>> incoming_proxies_; | 62 std::vector<scoped_ptr<BlimpMessageProcessor>> incoming_proxies_; |
64 | 63 |
65 // Containers for the MessageProcessors used to write feature-specific | 64 // Containers for the MessageProcessors used to write feature-specific |
66 // messages to the network, and the thread-pipe endpoints through which | 65 // messages to the network, and the thread-pipe endpoints through which |
67 // they are used from the UI thread. | 66 // they are used from the UI thread. |
68 std::vector<scoped_ptr<BlimpMessageThreadPipe>> outgoing_pipes_; | 67 std::vector<scoped_ptr<BlimpMessageThreadPipe>> outgoing_pipes_; |
69 std::vector<scoped_ptr<BlimpMessageProcessor>> outgoing_message_processors_; | 68 std::vector<scoped_ptr<BlimpMessageProcessor>> outgoing_message_processors_; |
| 69 |
70 DISALLOW_COPY_AND_ASSIGN(ClientNetworkComponents); | 70 DISALLOW_COPY_AND_ASSIGN(ClientNetworkComponents); |
71 }; | 71 }; |
72 | 72 |
73 void ClientNetworkComponents::Initialize() { | 73 void ClientNetworkComponents::Initialize() { |
74 DCHECK(!connection_manager_); | 74 DCHECK(!connection_manager_); |
75 connection_manager_ = make_scoped_ptr( | 75 connection_manager_ = make_scoped_ptr( |
76 new ClientConnectionManager(browser_connection_handler_.get())); | 76 new ClientConnectionManager(browser_connection_handler_.get())); |
77 } | 77 } |
78 | 78 |
79 void ClientNetworkComponents::ConnectWithAssignment( | 79 void ClientNetworkComponents::ConnectWithAssignment( |
80 const Assignment& assignment) { | 80 const Assignment& assignment) { |
81 DCHECK(connection_manager_); | 81 DCHECK(connection_manager_); |
82 connection_manager_->set_client_token(assignment.client_token); | 82 connection_manager_->set_client_token(assignment.client_token); |
83 | 83 |
84 switch (assignment.transport_protocol) { | 84 connection_manager_->AddTransport(make_scoped_ptr(new TCPClientTransport( |
85 case Assignment::SSL: | 85 net::AddressList(assignment.ip_endpoint), nullptr))); |
86 DCHECK(assignment.cert); | |
87 connection_manager_->AddTransport(make_scoped_ptr(new SSLClientTransport( | |
88 assignment.engine_endpoint, std::move(assignment.cert), nullptr))); | |
89 break; | |
90 case Assignment::TCP: | |
91 connection_manager_->AddTransport(make_scoped_ptr( | |
92 new TCPClientTransport(assignment.engine_endpoint, nullptr))); | |
93 break; | |
94 case Assignment::UNKNOWN: | |
95 DLOG(FATAL) << "Uknown transport type."; | |
96 break; | |
97 } | |
98 | 86 |
99 connection_manager_->Connect(); | 87 connection_manager_->Connect(); |
100 } | 88 } |
101 | 89 |
102 void ClientNetworkComponents::RegisterFeature( | 90 void ClientNetworkComponents::RegisterFeature( |
103 BlimpMessage::Type type, | 91 BlimpMessage::Type type, |
104 scoped_ptr<BlimpMessageThreadPipe> outgoing_pipe, | 92 scoped_ptr<BlimpMessageThreadPipe> outgoing_pipe, |
105 scoped_ptr<BlimpMessageProcessor> incoming_proxy) { | 93 scoped_ptr<BlimpMessageProcessor> incoming_proxy) { |
106 if (!browser_connection_handler_) { | 94 if (!browser_connection_handler_) { |
107 browser_connection_handler_ = make_scoped_ptr(new BrowserConnectionHandler); | 95 browser_connection_handler_ = make_scoped_ptr(new BrowserConnectionHandler); |
(...skipping 15 matching lines...) Expand all Loading... |
123 : io_thread_("BlimpIOThread"), | 111 : io_thread_("BlimpIOThread"), |
124 tab_control_feature_(new TabControlFeature), | 112 tab_control_feature_(new TabControlFeature), |
125 navigation_feature_(new NavigationFeature), | 113 navigation_feature_(new NavigationFeature), |
126 render_widget_feature_(new RenderWidgetFeature), | 114 render_widget_feature_(new RenderWidgetFeature), |
127 net_components_(new ClientNetworkComponents), | 115 net_components_(new ClientNetworkComponents), |
128 weak_factory_(this) { | 116 weak_factory_(this) { |
129 base::Thread::Options options; | 117 base::Thread::Options options; |
130 options.message_loop_type = base::MessageLoop::TYPE_IO; | 118 options.message_loop_type = base::MessageLoop::TYPE_IO; |
131 io_thread_.StartWithOptions(options); | 119 io_thread_.StartWithOptions(options); |
132 | 120 |
133 assignment_source_.reset( | 121 assignment_source_.reset(new AssignmentSource( |
134 new AssignmentSource(io_thread_.task_runner(), io_thread_.task_runner())); | 122 base::ThreadTaskRunnerHandle::Get(), io_thread_.task_runner())); |
135 | 123 |
136 // Register features' message senders and receivers. | 124 // Register features' message senders and receivers. |
137 tab_control_feature_->set_outgoing_message_processor( | 125 tab_control_feature_->set_outgoing_message_processor( |
138 RegisterFeature(BlimpMessage::TAB_CONTROL, tab_control_feature_.get())); | 126 RegisterFeature(BlimpMessage::TAB_CONTROL, tab_control_feature_.get())); |
139 navigation_feature_->set_outgoing_message_processor( | 127 navigation_feature_->set_outgoing_message_processor( |
140 RegisterFeature(BlimpMessage::NAVIGATION, navigation_feature_.get())); | 128 RegisterFeature(BlimpMessage::NAVIGATION, navigation_feature_.get())); |
141 render_widget_feature_->set_outgoing_input_message_processor( | 129 render_widget_feature_->set_outgoing_input_message_processor( |
142 RegisterFeature(BlimpMessage::INPUT, render_widget_feature_.get())); | 130 RegisterFeature(BlimpMessage::INPUT, render_widget_feature_.get())); |
143 render_widget_feature_->set_outgoing_compositor_message_processor( | 131 render_widget_feature_->set_outgoing_compositor_message_processor( |
144 RegisterFeature(BlimpMessage::COMPOSITOR, render_widget_feature_.get())); | 132 RegisterFeature(BlimpMessage::COMPOSITOR, render_widget_feature_.get())); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 NavigationFeature* BlimpClientSession::GetNavigationFeature() const { | 206 NavigationFeature* BlimpClientSession::GetNavigationFeature() const { |
219 return navigation_feature_.get(); | 207 return navigation_feature_.get(); |
220 } | 208 } |
221 | 209 |
222 RenderWidgetFeature* BlimpClientSession::GetRenderWidgetFeature() const { | 210 RenderWidgetFeature* BlimpClientSession::GetRenderWidgetFeature() const { |
223 return render_widget_feature_.get(); | 211 return render_widget_feature_.get(); |
224 } | 212 } |
225 | 213 |
226 } // namespace client | 214 } // namespace client |
227 } // namespace blimp | 215 } // namespace blimp |
OLD | NEW |