| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 ~FocusRulesImpl() override {} | 80 ~FocusRulesImpl() override {} |
| 81 | 81 |
| 82 bool SupportsChildActivation(aura::Window* window) const override { | 82 bool SupportsChildActivation(aura::Window* window) const override { |
| 83 return true; | 83 return true; |
| 84 } | 84 } |
| 85 | 85 |
| 86 private: | 86 private: |
| 87 DISALLOW_COPY_AND_ASSIGN(FocusRulesImpl); | 87 DISALLOW_COPY_AND_ASSIGN(FocusRulesImpl); |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 net::IPAddress GetIPv4AnyAddress() { | |
| 91 return net::IPAddress(0, 0, 0, 0); | |
| 92 } | |
| 93 | |
| 94 // Proxies calls to TaskRunner::PostTask while stripping the return value, | 90 // Proxies calls to TaskRunner::PostTask while stripping the return value, |
| 95 // which provides a suitable function prototype for binding a base::Closure. | 91 // which provides a suitable function prototype for binding a base::Closure. |
| 96 void PostTask(const scoped_refptr<base::TaskRunner>& task_runner, | 92 void PostTask(const scoped_refptr<base::TaskRunner>& task_runner, |
| 97 const base::Closure& closure) { | 93 const base::Closure& closure) { |
| 98 task_runner->PostTask(FROM_HERE, closure); | 94 task_runner->PostTask(FROM_HERE, closure); |
| 99 } | 95 } |
| 100 | 96 |
| 101 // Returns a closure that quits the current (bind-time) MessageLoop. | 97 // Returns a closure that quits the current (bind-time) MessageLoop. |
| 102 base::Closure QuitCurrentMessageLoopClosure() { | 98 base::Closure QuitCurrentMessageLoopClosure() { |
| 103 return base::Bind(&PostTask, base::ThreadTaskRunnerHandle::Get(), | 99 return base::Bind(&PostTask, base::ThreadTaskRunnerHandle::Get(), |
| 104 base::MessageLoop::QuitWhenIdleClosure()); | 100 base::MessageLoop::QuitWhenIdleClosure()); |
| 105 } | 101 } |
| 106 | 102 |
| 103 net::IPAddress GetListeningAddress() { |
| 104 if (base::CommandLine::ForCurrentProcess()->HasSwitch(kAllowNonLocalhost)) { |
| 105 return net::IPAddress::IPv4AllZeros(); |
| 106 } |
| 107 return net::IPAddress::IPv4Localhost(); |
| 108 } |
| 109 |
| 107 uint16_t GetListeningPort() { | 110 uint16_t GetListeningPort() { |
| 108 unsigned port_parsed = 0; | 111 unsigned port_parsed = 0; |
| 109 if (!base::StringToUint( | 112 if (!base::StringToUint( |
| 110 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 113 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 111 kEnginePort), | 114 kEnginePort), |
| 112 &port_parsed)) { | 115 &port_parsed)) { |
| 113 return kDefaultPort; | 116 return kDefaultPort; |
| 114 } | 117 } |
| 115 if (port_parsed > 65535) { | 118 if (port_parsed > 65535) { |
| 116 LOG(FATAL) << "--engine-port must be a value between 0 and 65535."; | 119 LOG(FATAL) << "--engine-port must be a value between 0 and 65535."; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 base::MakeUnique<EngineAuthenticationHandler>(this, client_token); | 190 base::MakeUnique<EngineAuthenticationHandler>(this, client_token); |
| 188 | 191 |
| 189 // Plumb unauthenticated connections to |authentication_handler_|. | 192 // Plumb unauthenticated connections to |authentication_handler_|. |
| 190 connection_manager_ = | 193 connection_manager_ = |
| 191 base::MakeUnique<EngineConnectionManager>(authentication_handler_.get()); | 194 base::MakeUnique<EngineConnectionManager>(authentication_handler_.get()); |
| 192 | 195 |
| 193 blob_channel_service_ = | 196 blob_channel_service_ = |
| 194 base::MakeUnique<BlobChannelService>(blob_channel_sender, ui_task_runner); | 197 base::MakeUnique<BlobChannelService>(blob_channel_sender, ui_task_runner); |
| 195 | 198 |
| 196 // Adds BlimpTransports to connection_manager_. | 199 // Adds BlimpTransports to connection_manager_. |
| 197 net::IPEndPoint address(GetIPv4AnyAddress(), GetListeningPort()); | 200 net::IPEndPoint address(GetListeningAddress(), GetListeningPort()); |
| 198 TCPEngineTransport* transport = new TCPEngineTransport(address, net_log_); | 201 TCPEngineTransport* transport = new TCPEngineTransport(address, net_log_); |
| 199 connection_manager_->AddTransport(base::WrapUnique(transport)); | 202 connection_manager_->AddTransport(base::WrapUnique(transport)); |
| 200 | 203 |
| 201 transport->GetLocalAddress(&address); | 204 transport->GetLocalAddress(&address); |
| 202 port_ = address.port(); | 205 port_ = address.port(); |
| 203 DVLOG(1) << "Engine port #: " << port_; | 206 DVLOG(1) << "Engine port #: " << port_; |
| 204 } | 207 } |
| 205 | 208 |
| 206 void EngineNetworkComponents::HandleConnection( | 209 void EngineNetworkComponents::HandleConnection( |
| 207 std::unique_ptr<BlimpConnection> connection) { | 210 std::unique_ptr<BlimpConnection> connection) { |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 parent->AddChild(content); | 583 parent->AddChild(content); |
| 581 content->Show(); | 584 content->Show(); |
| 582 | 585 |
| 583 tab_ = base::MakeUnique<Tab>(std::move(new_contents), target_tab_id, | 586 tab_ = base::MakeUnique<Tab>(std::move(new_contents), target_tab_id, |
| 584 &render_widget_feature_, | 587 &render_widget_feature_, |
| 585 navigation_message_sender_.get()); | 588 navigation_message_sender_.get()); |
| 586 } | 589 } |
| 587 | 590 |
| 588 } // namespace engine | 591 } // namespace engine |
| 589 } // namespace blimp | 592 } // namespace blimp |
| OLD | NEW |