OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/assignment_source.h" | 5 #include "blimp/client/session/assignment_source.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/numerics/safe_conversions.h" | 10 #include "base/numerics/safe_conversions.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 net::IPAddress GetBlimpletIPAddress() { | 24 net::IPAddress GetBlimpletIPAddress() { |
25 std::string host; | 25 std::string host; |
26 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 26 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
27 switches::kBlimpletHost)) { | 27 switches::kBlimpletHost)) { |
28 host = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 28 host = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
29 switches::kBlimpletHost); | 29 switches::kBlimpletHost); |
30 } else { | 30 } else { |
31 host = kDefaultBlimpletIPAddress; | 31 host = kDefaultBlimpletIPAddress; |
32 } | 32 } |
33 net::IPAddress ip_address; | 33 net::IPAddress ip_address; |
34 if (!net::IPAddress::FromIPLiteral(host, &ip_address)) | 34 if (!ip_address.AssignFromIPLiteral(host)) |
35 CHECK(false) << "Invalid BlimpletAssignment host " << host; | 35 CHECK(false) << "Invalid BlimpletAssignment host " << host; |
36 return ip_address; | 36 return ip_address; |
37 } | 37 } |
38 | 38 |
39 uint16_t GetBlimpletTCPPort() { | 39 uint16_t GetBlimpletTCPPort() { |
40 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 40 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
41 switches::kBlimpletTCPPort)) { | 41 switches::kBlimpletTCPPort)) { |
42 std::string port_str = | 42 std::string port_str = |
43 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 43 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
44 switches::kBlimpletTCPPort); | 44 switches::kBlimpletTCPPort); |
(...skipping 22 matching lines...) Expand all Loading... |
67 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 67 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
68 Assignment assignment; | 68 Assignment assignment; |
69 assignment.ip_endpoint = | 69 assignment.ip_endpoint = |
70 net::IPEndPoint(GetBlimpletIPAddress(), GetBlimpletTCPPort()); | 70 net::IPEndPoint(GetBlimpletIPAddress(), GetBlimpletTCPPort()); |
71 assignment.client_token = kDummyClientToken; | 71 assignment.client_token = kDummyClientToken; |
72 main_task_runner_->PostTask(FROM_HERE, base::Bind(callback, assignment)); | 72 main_task_runner_->PostTask(FROM_HERE, base::Bind(callback, assignment)); |
73 } | 73 } |
74 | 74 |
75 } // namespace client | 75 } // namespace client |
76 } // namespace blimp | 76 } // namespace blimp |
OLD | NEW |