| Index: content/browser/loader/test_url_loader_client.cc
|
| diff --git a/content/browser/loader/test_url_loader_client.cc b/content/browser/loader/test_url_loader_client.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..2f7234fa3762b7a71fad302d1933ed61ffe7f69e
|
| --- /dev/null
|
| +++ b/content/browser/loader/test_url_loader_client.cc
|
| @@ -0,0 +1,67 @@
|
| +// Copyright 2016 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 "content/browser/loader/test_url_loader_client.h"
|
| +
|
| +#include "base/run_loop.h"
|
| +
|
| +namespace content {
|
| +
|
| +TestURLLoaderClient::TestURLLoaderClient() : binding_(this) {}
|
| +TestURLLoaderClient::~TestURLLoaderClient() {}
|
| +
|
| +void TestURLLoaderClient::OnReceiveResponse(
|
| + const ResourceResponseHead& response_head) {
|
| + has_received_response_ = true;
|
| + response_head_ = response_head;
|
| + if (quit_closure_for_on_received_response_)
|
| + quit_closure_for_on_received_response_.Run();
|
| +}
|
| +
|
| +void TestURLLoaderClient::OnStartLoadingResponseBody(
|
| + mojo::ScopedDataPipeConsumerHandle body) {
|
| + response_body_ = std::move(body);
|
| + if (quit_closure_for_on_start_loading_response_body_)
|
| + quit_closure_for_on_start_loading_response_body_.Run();
|
| +}
|
| +
|
| +void TestURLLoaderClient::OnComplete(
|
| + const ResourceRequestCompletionStatus& status) {
|
| + has_received_completion_ = true;
|
| + completion_status_ = status;
|
| + if (quit_closure_for_on_complete_)
|
| + quit_closure_for_on_complete_.Run();
|
| +}
|
| +
|
| +mojom::URLLoaderClientPtr TestURLLoaderClient::CreateInterfacePtrAndBind() {
|
| + return binding_.CreateInterfacePtrAndBind();
|
| +}
|
| +
|
| +void TestURLLoaderClient::Unbind() {
|
| + binding_.Unbind();
|
| + response_body_.reset();
|
| +}
|
| +
|
| +void TestURLLoaderClient::RunUntilResponseReceived() {
|
| + base::RunLoop run_loop;
|
| + quit_closure_for_on_received_response_ = run_loop.QuitClosure();
|
| + run_loop.Run();
|
| + quit_closure_for_on_received_response_.Reset();
|
| +}
|
| +
|
| +void TestURLLoaderClient::RunUntilResponseBodyArrived() {
|
| + base::RunLoop run_loop;
|
| + quit_closure_for_on_start_loading_response_body_ = run_loop.QuitClosure();
|
| + run_loop.Run();
|
| + quit_closure_for_on_start_loading_response_body_.Reset();
|
| +}
|
| +
|
| +void TestURLLoaderClient::RunUntilComplete() {
|
| + base::RunLoop run_loop;
|
| + quit_closure_for_on_complete_ = run_loop.QuitClosure();
|
| + run_loop.Run();
|
| + quit_closure_for_on_complete_.Reset();
|
| +}
|
| +
|
| +} // namespace content
|
|
|