| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/test/chromedriver/net/net_util.h" | 5 #include "chrome/test/chromedriver/net/net_util.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 std::string* response_; | 56 std::string* response_; |
| 57 base::WaitableEvent event_; | 57 base::WaitableEvent event_; |
| 58 std::unique_ptr<net::URLFetcher> fetcher_; | 58 std::unique_ptr<net::URLFetcher> fetcher_; |
| 59 bool success_; | 59 bool success_; |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 } // namespace | 62 } // namespace |
| 63 | 63 |
| 64 NetAddress::NetAddress() : port_(-1) {} | 64 NetAddress::NetAddress() : port_(-1) {} |
| 65 | 65 |
| 66 NetAddress::NetAddress(int port) : host_("127.0.0.1"), port_(port) {} | 66 NetAddress::NetAddress(int port) : host_("localhost"), port_(port) {} |
| 67 | 67 |
| 68 NetAddress::NetAddress(const std::string& host, int port) | 68 NetAddress::NetAddress(const std::string& host, int port) |
| 69 : host_(host), port_(port) {} | 69 : host_(host), port_(port) {} |
| 70 | 70 |
| 71 NetAddress::~NetAddress() {} | 71 NetAddress::~NetAddress() {} |
| 72 | 72 |
| 73 bool NetAddress::IsValid() const { | 73 bool NetAddress::IsValid() const { |
| 74 return port_ >= 0 && port_ < (1 << 16); | 74 return port_ >= 0 && port_ < (1 << 16); |
| 75 } | 75 } |
| 76 | 76 |
| 77 std::string NetAddress::ToString() const { | 77 std::string NetAddress::ToString() const { |
| 78 return host_ + base::StringPrintf(":%d", port_); | 78 return host_ + base::StringPrintf(":%d", port_); |
| 79 } | 79 } |
| 80 | 80 |
| 81 const std::string& NetAddress::host() const { | 81 const std::string& NetAddress::host() const { |
| 82 return host_; | 82 return host_; |
| 83 } | 83 } |
| 84 | 84 |
| 85 int NetAddress::port() const { | 85 int NetAddress::port() const { |
| 86 return port_; | 86 return port_; |
| 87 } | 87 } |
| 88 | 88 |
| 89 bool FetchUrl(const std::string& url, | 89 bool FetchUrl(const std::string& url, |
| 90 URLRequestContextGetter* getter, | 90 URLRequestContextGetter* getter, |
| 91 std::string* response) { | 91 std::string* response) { |
| 92 return SyncUrlFetcher(GURL(url), getter, response).Fetch(); | 92 return SyncUrlFetcher(GURL(url), getter, response).Fetch(); |
| 93 } | 93 } |
| OLD | NEW |