blob: 7abc4f521f507c044dee540aad49f310d6feb3cc [file] [log] [blame]
// Copyright 2017 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 <memory>
#include <string>
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/threading/thread_checker.h"
class GURL;
namespace base {
class SingleThreadTaskRunner;
} // namespace base
namespace net {
class ScopedPortException;
// RemoteTestServerSpawnerRequest is used by RemoteTestServer to send a request
// to the test server spawner.
class RemoteTestServerSpawnerRequest {
// Queries the specified URL. If |post_data| is empty then a GET request is
// sent. Otherwise |post_data| must be a json blob which is sent as a POST
// request body.
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
const GURL& url,
const std::string& post_data);
// Blocks until request is finished. If |response| isn't nullptr then server
// response is copied to *response. Returns true if the request was completed
// successfully.
bool WaitForCompletion(std::string* response) WARN_UNUSED_RESULT;
class Core;
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
// Core runs on |io_task_runner_|. It's responsible for sending the request
// and reading the response.
std::unique_ptr<Core> core_;
// Helper to add spawner port to the list of the globally explicitly allowed
// ports. It needs to be here instead of in Core because ScopedPortException
// is not thread-safe.
std::unique_ptr<ScopedPortException> allowed_port_;
} // namespace net