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

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

Issue 2467833002: Implement redirect handling on MojoAsyncResourceHandler (Closed)
Patch Set: rebase Created 4 years, 1 month 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
index 1a19ce9170f65379d5f95feb3953652821bd4744..caa858312f4fa30a36882447a638b2edc348fd77 100644
--- a/content/browser/loader/test_url_loader_client.cc
+++ b/content/browser/loader/test_url_loader_client.cc
@@ -6,6 +6,7 @@
#include "base/memory/ref_counted.h"
#include "base/run_loop.h"
+#include "testing/gtest/include/gtest/gtest.h"
namespace content {
@@ -16,8 +17,22 @@ 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();
+ if (quit_closure_for_on_receive_response_)
+ quit_closure_for_on_receive_response_.Run();
+}
+
+void TestURLLoaderClient::OnReceiveRedirect(
+ const net::RedirectInfo& redirect_info,
+ const ResourceResponseHead& response_head) {
+ EXPECT_FALSE(response_body_.is_valid());
+ EXPECT_FALSE(has_received_response_);
+ // Use ClearHasReceivedRedirect to accept more redirects.
+ EXPECT_FALSE(has_received_redirect_);
+ 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,
@@ -44,6 +59,10 @@ void TestURLLoaderClient::OnComplete(
quit_closure_for_on_complete_.Run();
}
+void TestURLLoaderClient::ClearHasReceivedRedirect() {
+ has_received_redirect_ = false;
+}
+
mojom::URLLoaderClientAssociatedPtrInfo
TestURLLoaderClient::CreateRemoteAssociatedPtrInfo(
mojo::AssociatedGroup* associated_group) {
@@ -59,9 +78,16 @@ void TestURLLoaderClient::Unbind() {
void TestURLLoaderClient::RunUntilResponseReceived() {
base::RunLoop run_loop;
- quit_closure_for_on_received_response_ = run_loop.QuitClosure();
+ quit_closure_for_on_receive_response_ = run_loop.QuitClosure();
+ run_loop.Run();
+ quit_closure_for_on_receive_response_.Reset();
+}
+
+void TestURLLoaderClient::RunUntilRedirectReceived() {
+ base::RunLoop run_loop;
+ quit_closure_for_on_receive_redirect_ = run_loop.QuitClosure();
run_loop.Run();
- quit_closure_for_on_received_response_.Reset();
+ quit_closure_for_on_receive_redirect_.Reset();
}
void TestURLLoaderClient::RunUntilDataDownloaded() {
« no previous file with comments | « content/browser/loader/test_url_loader_client.h ('k') | content/browser/service_worker/service_worker_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698