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