blob: e1b75656b93e98a09d0335ca0a2d6e0630883418 [file] [log] [blame]
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <string>
#include "base/memory/scoped_refptr.h"
namespace base {
class SequencedTaskRunner;
namespace network {
namespace mojom {
class URLLoaderFactory;
} // namespace network
class NetAddress {
NetAddress(); // Creates an invalid address.
explicit NetAddress(int port); // Host is set to localhost.
NetAddress(const std::string& host, int port);
bool IsValid() const;
// Returns host:port.
std::string ToString() const;
const std::string& host() const;
int port() const;
std::string host_;
int port_;
void SetIOCapableTaskRunnerForTest(
scoped_refptr<base::SequencedTaskRunner> task_runner);
// Synchronously fetches data from a GET HTTP request to the given URL.
// Returns true if response is 200 OK and sets response body to |response|.
bool FetchUrl(const std::string& url,
network::mojom::URLLoaderFactory* factory,
std::string* response);