| 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/engine/session/blimp_engine_session.h" | 5 #include "blimp/engine/session/blimp_engine_session.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 #include "blimp/net/blimp_connection.h" | 30 #include "blimp/net/blimp_connection.h" |
| 31 #include "blimp/net/blimp_message_multiplexer.h" | 31 #include "blimp/net/blimp_message_multiplexer.h" |
| 32 #include "blimp/net/blimp_message_thread_pipe.h" | 32 #include "blimp/net/blimp_message_thread_pipe.h" |
| 33 #include "blimp/net/blimp_stats.h" | 33 #include "blimp/net/blimp_stats.h" |
| 34 #include "blimp/net/blob_channel/blob_channel_sender_impl.h" | 34 #include "blimp/net/blob_channel/blob_channel_sender_impl.h" |
| 35 #include "blimp/net/blob_channel/helium_blob_sender_delegate.h" | 35 #include "blimp/net/blob_channel/helium_blob_sender_delegate.h" |
| 36 #include "blimp/net/browser_connection_handler.h" | 36 #include "blimp/net/browser_connection_handler.h" |
| 37 #include "blimp/net/common.h" | 37 #include "blimp/net/common.h" |
| 38 #include "blimp/net/engine_authentication_handler.h" | 38 #include "blimp/net/engine_authentication_handler.h" |
| 39 #include "blimp/net/engine_connection_manager.h" | 39 #include "blimp/net/engine_connection_manager.h" |
| 40 #include "blimp/net/grpc_engine_transport.h" |
| 40 #include "blimp/net/null_blimp_message_processor.h" | 41 #include "blimp/net/null_blimp_message_processor.h" |
| 41 #include "blimp/net/tcp_engine_transport.h" | 42 #include "blimp/net/tcp_engine_transport.h" |
| 42 #include "blimp/net/thread_pipe_manager.h" | 43 #include "blimp/net/thread_pipe_manager.h" |
| 43 #include "content/public/browser/browser_context.h" | 44 #include "content/public/browser/browser_context.h" |
| 44 #include "content/public/browser/browser_thread.h" | 45 #include "content/public/browser/browser_thread.h" |
| 45 #include "content/public/browser/navigation_controller.h" | 46 #include "content/public/browser/navigation_controller.h" |
| 46 #include "content/public/browser/navigation_entry.h" | 47 #include "content/public/browser/navigation_entry.h" |
| 47 #include "content/public/browser/render_view_host.h" | 48 #include "content/public/browser/render_view_host.h" |
| 48 #include "content/public/browser/render_widget_host.h" | 49 #include "content/public/browser/render_widget_host.h" |
| 49 #include "content/public/browser/render_widget_host_view.h" | 50 #include "content/public/browser/render_widget_host_view.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 65 | 66 |
| 66 namespace blimp { | 67 namespace blimp { |
| 67 namespace engine { | 68 namespace engine { |
| 68 namespace { | 69 namespace { |
| 69 | 70 |
| 70 const float kDefaultScaleFactor = 1.f; | 71 const float kDefaultScaleFactor = 1.f; |
| 71 const int kDefaultDisplayWidth = 800; | 72 const int kDefaultDisplayWidth = 800; |
| 72 const int kDefaultDisplayHeight = 600; | 73 const int kDefaultDisplayHeight = 600; |
| 73 const uint16_t kDefaultPort = 25467; | 74 const uint16_t kDefaultPort = 25467; |
| 74 | 75 |
| 75 const char kTcpTransport[] = "tcp"; | |
| 76 const char kGrpcTransport[] = "grpc"; | |
| 77 | |
| 78 // Focus rules that support activating an child window. | 76 // Focus rules that support activating an child window. |
| 79 class FocusRulesImpl : public wm::BaseFocusRules { | 77 class FocusRulesImpl : public wm::BaseFocusRules { |
| 80 public: | 78 public: |
| 81 FocusRulesImpl() {} | 79 FocusRulesImpl() {} |
| 82 ~FocusRulesImpl() override {} | 80 ~FocusRulesImpl() override {} |
| 83 | 81 |
| 84 bool SupportsChildActivation(aura::Window* window) const override { | 82 bool SupportsChildActivation(aura::Window* window) const override { |
| 85 return true; | 83 return true; |
| 86 } | 84 } |
| 87 | 85 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 explicit EngineNetworkComponents(net::NetLog* net_log); | 147 explicit EngineNetworkComponents(net::NetLog* net_log); |
| 150 ~EngineNetworkComponents() override; | 148 ~EngineNetworkComponents() override; |
| 151 | 149 |
| 152 // Sets up network components and starts listening for incoming connection. | 150 // Sets up network components and starts listening for incoming connection. |
| 153 // This should be called after all features have been registered so that | 151 // This should be called after all features have been registered so that |
| 154 // received messages can be properly handled. | 152 // received messages can be properly handled. |
| 155 void Initialize(scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, | 153 void Initialize(scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, |
| 156 base::WeakPtr<BlobChannelSender> blob_channel_sender, | 154 base::WeakPtr<BlobChannelSender> blob_channel_sender, |
| 157 const std::string& client_token); | 155 const std::string& client_token); |
| 158 | 156 |
| 159 // TODO(perumaal): Remove this once gRPC support is ready. | 157 AssignmentOptions GetAssignmentOptions() { return assignment_options_; } |
| 160 // See crbug.com/659279. | |
| 161 uint16_t GetPortForTesting() { return port_; } | |
| 162 | 158 |
| 163 BrowserConnectionHandler* connection_handler() { | 159 BrowserConnectionHandler* connection_handler() { |
| 164 return &connection_handler_; | 160 return &connection_handler_; |
| 165 } | 161 } |
| 166 | 162 |
| 167 BlobChannelService* blob_channel_service() { | 163 BlobChannelService* blob_channel_service() { |
| 168 return blob_channel_service_.get(); | 164 return blob_channel_service_.get(); |
| 169 } | 165 } |
| 170 | 166 |
| 171 private: | 167 private: |
| 172 // ConnectionHandler implementation. | 168 // ConnectionHandler implementation. |
| 173 void HandleConnection(std::unique_ptr<BlimpConnection> connection) override; | 169 void HandleConnection(std::unique_ptr<BlimpConnection> connection) override; |
| 174 | 170 |
| 175 // ConnectionErrorObserver implementation. | 171 // ConnectionErrorObserver implementation. |
| 176 // Signals the engine session that an authenticated connection was | 172 // Signals the engine session that an authenticated connection was |
| 177 // terminated. | 173 // terminated. |
| 178 void OnConnectionError(int error) override; | 174 void OnConnectionError(int error) override; |
| 179 | 175 |
| 180 net::NetLog* net_log_; | 176 net::NetLog* net_log_; |
| 181 uint16_t port_ = 0; | 177 AssignmentOptions assignment_options_; |
| 182 | 178 |
| 183 BrowserConnectionHandler connection_handler_; | 179 BrowserConnectionHandler connection_handler_; |
| 184 std::unique_ptr<EngineAuthenticationHandler> authentication_handler_; | 180 std::unique_ptr<EngineAuthenticationHandler> authentication_handler_; |
| 185 std::unique_ptr<EngineConnectionManager> connection_manager_; | 181 std::unique_ptr<EngineConnectionManager> connection_manager_; |
| 186 std::unique_ptr<BlobChannelService> blob_channel_service_; | 182 std::unique_ptr<BlobChannelService> blob_channel_service_; |
| 187 base::Closure quit_closure_; | 183 base::Closure quit_closure_; |
| 188 | 184 |
| 189 DISALLOW_COPY_AND_ASSIGN(EngineNetworkComponents); | 185 DISALLOW_COPY_AND_ASSIGN(EngineNetworkComponents); |
| 190 }; | 186 }; |
| 191 | 187 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 208 base::MakeUnique<EngineAuthenticationHandler>(this, client_token); | 204 base::MakeUnique<EngineAuthenticationHandler>(this, client_token); |
| 209 | 205 |
| 210 // Plumb unauthenticated connections to |authentication_handler_|. | 206 // Plumb unauthenticated connections to |authentication_handler_|. |
| 211 connection_manager_ = base::MakeUnique<EngineConnectionManager>( | 207 connection_manager_ = base::MakeUnique<EngineConnectionManager>( |
| 212 authentication_handler_.get(), net_log_); | 208 authentication_handler_.get(), net_log_); |
| 213 | 209 |
| 214 blob_channel_service_ = | 210 blob_channel_service_ = |
| 215 base::MakeUnique<BlobChannelService>(blob_channel_sender, ui_task_runner); | 211 base::MakeUnique<BlobChannelService>(blob_channel_sender, ui_task_runner); |
| 216 | 212 |
| 217 // Adds BlimpTransports to connection_manager_. | 213 // Adds BlimpTransports to connection_manager_. |
| 218 net::IPEndPoint address(GetListeningAddress(), GetListeningPort()); | 214 assignment_options_.engine_endpoint = |
| 219 connection_manager_->ConnectTransport(&address, GetTransportType()); | 215 net::IPEndPoint(GetListeningAddress(), GetListeningPort()); |
| 220 port_ = address.port(); | 216 connection_manager_->ConnectTransport(&assignment_options_, |
| 221 | 217 GetTransportType()); |
| 222 // Print the engine port for client_engine_integration script, please do not | 218 // Print the engine port for client_engine_integration script, please do not |
| 223 // remove this log. | 219 // remove this log. |
| 224 DVLOG(1) << "Engine port #: " << port_; | 220 DVLOG(1) << "Engine port #: " << assignment_options_.engine_endpoint.port(); |
| 225 } | 221 } |
| 226 | 222 |
| 227 void EngineNetworkComponents::HandleConnection( | 223 void EngineNetworkComponents::HandleConnection( |
| 228 std::unique_ptr<BlimpConnection> connection) { | 224 std::unique_ptr<BlimpConnection> connection) { |
| 229 // Observe |connection| for disconnection events. | 225 // Observe |connection| for disconnection events. |
| 230 connection->AddConnectionErrorObserver(this); | 226 connection->AddConnectionErrorObserver(this); |
| 231 connection_handler_.HandleConnection(std::move(connection)); | 227 connection_handler_.HandleConnection(std::move(connection)); |
| 232 } | 228 } |
| 233 | 229 |
| 234 void EngineNetworkComponents::OnConnectionError(int error) { | 230 void EngineNetworkComponents::OnConnectionError(int error) { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 base::Unretained(net_components_.get()), | 313 base::Unretained(net_components_.get()), |
| 318 base::ThreadTaskRunnerHandle::Get(), | 314 base::ThreadTaskRunnerHandle::Get(), |
| 319 blob_channel_sender_weak_factory_->GetWeakPtr(), | 315 blob_channel_sender_weak_factory_->GetWeakPtr(), |
| 320 engine_config_->client_auth_token())); | 316 engine_config_->client_auth_token())); |
| 321 } | 317 } |
| 322 | 318 |
| 323 BlobChannelService* BlimpEngineSession::GetBlobChannelService() { | 319 BlobChannelService* BlimpEngineSession::GetBlobChannelService() { |
| 324 return net_components_->blob_channel_service(); | 320 return net_components_->blob_channel_service(); |
| 325 } | 321 } |
| 326 | 322 |
| 327 void BlimpEngineSession::GetEnginePortForTesting( | 323 void BlimpEngineSession::GetAssignmentOptions( |
| 328 const GetPortCallback& callback) { | 324 const GetAssignmentOptionsCallback& callback) { |
| 329 content::BrowserThread::PostTaskAndReplyWithResult( | 325 content::BrowserThread::PostTaskAndReplyWithResult( |
| 330 content::BrowserThread::IO, FROM_HERE, | 326 content::BrowserThread::IO, FROM_HERE, |
| 331 base::Bind(&EngineNetworkComponents::GetPortForTesting, | 327 base::Bind(&EngineNetworkComponents::GetAssignmentOptions, |
| 332 base::Unretained(net_components_.get())), | 328 base::Unretained(net_components_.get())), |
| 333 callback); | 329 callback); |
| 334 } | 330 } |
| 335 | 331 |
| 336 void BlimpEngineSession::RegisterFeatures() { | 332 void BlimpEngineSession::RegisterFeatures() { |
| 337 thread_pipe_manager_.reset( | 333 thread_pipe_manager_.reset( |
| 338 new ThreadPipeManager(content::BrowserThread::GetTaskRunnerForThread( | 334 new ThreadPipeManager(content::BrowserThread::GetTaskRunnerForThread( |
| 339 content::BrowserThread::IO), | 335 content::BrowserThread::IO), |
| 340 net_components_->connection_handler())); | 336 net_components_->connection_handler())); |
| 341 | 337 |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 parent->AddChild(content); | 581 parent->AddChild(content); |
| 586 content->Show(); | 582 content->Show(); |
| 587 | 583 |
| 588 tab_ = base::MakeUnique<Tab>(std::move(new_contents), target_tab_id, | 584 tab_ = base::MakeUnique<Tab>(std::move(new_contents), target_tab_id, |
| 589 &render_widget_feature_, | 585 &render_widget_feature_, |
| 590 navigation_message_sender_.get()); | 586 navigation_message_sender_.get()); |
| 591 } | 587 } |
| 592 | 588 |
| 593 } // namespace engine | 589 } // namespace engine |
| 594 } // namespace blimp | 590 } // namespace blimp |
| OLD | NEW |