Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1119)

Unified Diff: content/browser/loader/test_url_loader_client.cc

Issue 2968293002: Introduce SystemNetworkContextManager. (Closed)
Patch Set: Response to comments Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
deleted file mode 100644
index 569500206d8cfdd078b3aefbde69dc0e731a3d83..0000000000000000000000000000000000000000
--- a/content/browser/loader/test_url_loader_client.cc
+++ /dev/null
@@ -1,196 +0,0 @@
-// 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/memory/ref_counted.h"
-#include "base/run_loop.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace content {
-
-TestURLLoaderClient::TestURLLoaderClient() : binding_(this) {}
-TestURLLoaderClient::~TestURLLoaderClient() {}
-
-void TestURLLoaderClient::OnReceiveResponse(
- const ResourceResponseHead& response_head,
- const base::Optional<net::SSLInfo>& ssl_info,
- mojom::DownloadedTempFilePtr downloaded_file) {
- EXPECT_FALSE(has_received_response_);
- EXPECT_FALSE(has_received_cached_metadata_);
- EXPECT_FALSE(has_received_completion_);
- has_received_response_ = true;
- response_head_ = response_head;
- ssl_info_ = ssl_info;
- if (quit_closure_for_on_receive_response_)
- quit_closure_for_on_receive_response_.Run();
- binding_.set_connection_error_handler(base::Bind(
- &TestURLLoaderClient::OnConnectionError, base::Unretained(this)));
-}
-
-void TestURLLoaderClient::OnReceiveRedirect(
- const net::RedirectInfo& redirect_info,
- const ResourceResponseHead& response_head) {
- EXPECT_FALSE(has_received_cached_metadata_);
- EXPECT_FALSE(response_body_.is_valid());
- EXPECT_FALSE(has_received_response_);
- // Use ClearHasReceivedRedirect to accept more redirects.
- EXPECT_FALSE(has_received_redirect_);
- EXPECT_FALSE(has_received_completion_);
- has_received_redirect_ = true;
- redirect_info_ = redirect_info;
- response_head_ = response_head;
- if (quit_closure_for_on_receive_redirect_)
- quit_closure_for_on_receive_redirect_.Run();
-}
-
-void TestURLLoaderClient::OnDataDownloaded(int64_t data_length,
- int64_t encoded_data_length) {
- EXPECT_TRUE(has_received_response_);
- EXPECT_FALSE(has_received_completion_);
- has_data_downloaded_ = true;
- download_data_length_ += data_length;
- encoded_download_data_length_ += encoded_data_length;
- if (quit_closure_for_on_data_downloaded_)
- quit_closure_for_on_data_downloaded_.Run();
-}
-
-void TestURLLoaderClient::OnReceiveCachedMetadata(
- const std::vector<uint8_t>& data) {
- EXPECT_FALSE(has_received_cached_metadata_);
- EXPECT_TRUE(has_received_response_);
- EXPECT_FALSE(has_received_completion_);
- has_received_cached_metadata_ = true;
- cached_metadata_ =
- std::string(reinterpret_cast<const char*>(data.data()), data.size());
- if (quit_closure_for_on_receive_cached_metadata_)
- quit_closure_for_on_receive_cached_metadata_.Run();
-}
-
-void TestURLLoaderClient::OnTransferSizeUpdated(int32_t transfer_size_diff) {
- EXPECT_TRUE(has_received_response_);
- EXPECT_FALSE(has_received_completion_);
- EXPECT_GT(transfer_size_diff, 0);
- body_transfer_size_ += transfer_size_diff;
-}
-
-void TestURLLoaderClient::OnUploadProgress(
- int64_t current_position,
- int64_t total_size,
- OnUploadProgressCallback ack_callback) {
- EXPECT_TRUE(ack_callback);
- EXPECT_FALSE(has_received_response_);
- EXPECT_FALSE(has_received_completion_);
- EXPECT_LT(0, current_position);
- EXPECT_LE(current_position, total_size);
-
- has_received_upload_progress_ = true;
- current_upload_position_ = current_position;
- total_upload_size_ = total_size;
- std::move(ack_callback).Run();
-}
-
-void TestURLLoaderClient::OnStartLoadingResponseBody(
- mojo::ScopedDataPipeConsumerHandle body) {
- EXPECT_TRUE(has_received_response_);
- EXPECT_FALSE(has_received_completion_);
- 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) {
- EXPECT_FALSE(has_received_completion_);
- has_received_completion_ = true;
- completion_status_ = status;
- if (quit_closure_for_on_complete_)
- quit_closure_for_on_complete_.Run();
-}
-
-void TestURLLoaderClient::ClearHasReceivedRedirect() {
- has_received_redirect_ = false;
-}
-
-mojom::URLLoaderClientPtr TestURLLoaderClient::CreateInterfacePtr() {
- mojom::URLLoaderClientPtr client_ptr;
- binding_.Bind(mojo::MakeRequest(&client_ptr));
- return client_ptr;
-}
-
-void TestURLLoaderClient::Unbind() {
- binding_.Unbind();
- response_body_.reset();
-}
-
-void TestURLLoaderClient::RunUntilResponseReceived() {
- if (has_received_response_)
- return;
- base::RunLoop run_loop;
- quit_closure_for_on_receive_response_ = run_loop.QuitClosure();
- run_loop.Run();
- quit_closure_for_on_receive_response_.Reset();
-}
-
-void TestURLLoaderClient::RunUntilRedirectReceived() {
- if (has_received_redirect_)
- return;
- base::RunLoop run_loop;
- quit_closure_for_on_receive_redirect_ = run_loop.QuitClosure();
- run_loop.Run();
- quit_closure_for_on_receive_redirect_.Reset();
-}
-
-void TestURLLoaderClient::RunUntilDataDownloaded() {
- if (has_data_downloaded_)
- return;
- base::RunLoop run_loop;
- quit_closure_for_on_data_downloaded_ = run_loop.QuitClosure();
- run_loop.Run();
- quit_closure_for_on_data_downloaded_.Reset();
-}
-
-void TestURLLoaderClient::RunUntilCachedMetadataReceived() {
- if (has_received_cached_metadata_)
- return;
- base::RunLoop run_loop;
- quit_closure_for_on_receive_cached_metadata_ = run_loop.QuitClosure();
- run_loop.Run();
- quit_closure_for_on_receive_cached_metadata_.Reset();
-}
-
-void TestURLLoaderClient::RunUntilResponseBodyArrived() {
- if (response_body_.is_valid())
- return;
- 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() {
- if (has_received_completion_)
- return;
- base::RunLoop run_loop;
- quit_closure_for_on_complete_ = run_loop.QuitClosure();
- run_loop.Run();
- quit_closure_for_on_complete_.Reset();
-}
-
-void TestURLLoaderClient::RunUntilConnectionError() {
- if (has_received_connection_error_)
- return;
- base::RunLoop run_loop;
- quit_closure_for_on_connection_error_ = run_loop.QuitClosure();
- run_loop.Run();
- quit_closure_for_on_connection_error_.Reset();
-}
-
-void TestURLLoaderClient::OnConnectionError() {
- has_received_connection_error_ = true;
- if (quit_closure_for_on_connection_error_)
- quit_closure_for_on_connection_error_.Run();
-}
-
-} // namespace content
« no previous file with comments | « content/browser/loader/test_url_loader_client.h ('k') | content/browser/loader/url_loader_factory_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698