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

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

Issue 1970693002: Use mojo for Chrome Loading, Part 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 4 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
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

Powered by Google App Engine
This is Rietveld 408576698