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

Side by Side Diff: blimp/engine/session/blimp_engine_session.cc

Issue 2292563003: Add command line flag to allow testing clients not connected to localhost. Otherwise, restrict conn… (Closed)
Patch Set: Created 4 years, 3 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
« blimp/engine/app/switches.cc ('K') | « blimp/engine/app/switches.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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
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 GetListeningIPAddress() {
Wez 2016/08/30 21:42:00 nit: I'd suggest just GetListeningAddress, since I
104 if (base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
105 kEngineListenOutside) == "1") {
Wez 2016/08/30 21:42:00 Since this is a Boolean parameter and defaults to
106 return net::IPAddress::IPv4AllZeros();
107 }
108 return net::IPAddress::IPv4Localhost();
109 }
110
107 uint16_t GetListeningPort() { 111 uint16_t GetListeningPort() {
108 unsigned port_parsed = 0; 112 unsigned port_parsed = 0;
109 if (!base::StringToUint( 113 if (!base::StringToUint(
110 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 114 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
111 kEnginePort), 115 kEnginePort),
112 &port_parsed)) { 116 &port_parsed)) {
113 return kDefaultPort; 117 return kDefaultPort;
114 } 118 }
115 if (port_parsed > 65535) { 119 if (port_parsed > 65535) {
116 LOG(FATAL) << "--engine-port must be a value between 0 and 65535."; 120 LOG(FATAL) << "--engine-port must be a value between 0 and 65535.";
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 base::MakeUnique<EngineAuthenticationHandler>(this, client_token); 191 base::MakeUnique<EngineAuthenticationHandler>(this, client_token);
188 192
189 // Plumb unauthenticated connections to |authentication_handler_|. 193 // Plumb unauthenticated connections to |authentication_handler_|.
190 connection_manager_ = 194 connection_manager_ =
191 base::MakeUnique<EngineConnectionManager>(authentication_handler_.get()); 195 base::MakeUnique<EngineConnectionManager>(authentication_handler_.get());
192 196
193 blob_channel_service_ = 197 blob_channel_service_ =
194 base::MakeUnique<BlobChannelService>(blob_channel_sender, ui_task_runner); 198 base::MakeUnique<BlobChannelService>(blob_channel_sender, ui_task_runner);
195 199
196 // Adds BlimpTransports to connection_manager_. 200 // Adds BlimpTransports to connection_manager_.
197 net::IPEndPoint address(GetIPv4AnyAddress(), GetListeningPort()); 201 net::IPEndPoint address(GetListeningIPAddress(), GetListeningPort());
198 TCPEngineTransport* transport = new TCPEngineTransport(address, net_log_); 202 TCPEngineTransport* transport = new TCPEngineTransport(address, net_log_);
199 connection_manager_->AddTransport(base::WrapUnique(transport)); 203 connection_manager_->AddTransport(base::WrapUnique(transport));
200 204
201 transport->GetLocalAddress(&address); 205 transport->GetLocalAddress(&address);
202 port_ = address.port(); 206 port_ = address.port();
203 DVLOG(1) << "Engine port #: " << port_; 207 DVLOG(1) << "Engine port #: " << port_;
204 } 208 }
205 209
206 void EngineNetworkComponents::HandleConnection( 210 void EngineNetworkComponents::HandleConnection(
207 std::unique_ptr<BlimpConnection> connection) { 211 std::unique_ptr<BlimpConnection> connection) {
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 parent->AddChild(content); 584 parent->AddChild(content);
581 content->Show(); 585 content->Show();
582 586
583 tab_ = base::MakeUnique<Tab>(std::move(new_contents), target_tab_id, 587 tab_ = base::MakeUnique<Tab>(std::move(new_contents), target_tab_id,
584 &render_widget_feature_, 588 &render_widget_feature_,
585 navigation_message_sender_.get()); 589 navigation_message_sender_.get());
586 } 590 }
587 591
588 } // namespace engine 592 } // namespace engine
589 } // namespace blimp 593 } // namespace blimp
OLDNEW
« blimp/engine/app/switches.cc ('K') | « blimp/engine/app/switches.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698