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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/browser/loader/test_url_loader_client.h"
6
7 #include "base/run_loop.h"
8
9 namespace content {
10
11 TestURLLoaderClient::TestURLLoaderClient() : binding_(this) {}
12 TestURLLoaderClient::~TestURLLoaderClient() {}
13
14 void TestURLLoaderClient::OnReceiveResponse(
15 const ResourceResponseHead& response_head) {
16 has_received_response_ = true;
17 response_head_ = response_head;
18 if (quit_closure_for_on_received_response_)
19 quit_closure_for_on_received_response_.Run();
20 }
21
22 void TestURLLoaderClient::OnStartLoadingResponseBody(
23 mojo::ScopedDataPipeConsumerHandle body) {
24 response_body_ = std::move(body);
25 if (quit_closure_for_on_start_loading_response_body_)
26 quit_closure_for_on_start_loading_response_body_.Run();
27 }
28
29 void TestURLLoaderClient::OnComplete(
30 const ResourceRequestCompletionStatus& status) {
31 has_received_completion_ = true;
32 completion_status_ = status;
33 if (quit_closure_for_on_complete_)
34 quit_closure_for_on_complete_.Run();
35 }
36
37 mojom::URLLoaderClientPtr TestURLLoaderClient::CreateInterfacePtrAndBind() {
38 return binding_.CreateInterfacePtrAndBind();
39 }
40
41 void TestURLLoaderClient::Unbind() {
42 binding_.Unbind();
43 response_body_.reset();
44 }
45
46 void TestURLLoaderClient::RunUntilResponseReceived() {
47 base::RunLoop run_loop;
48 quit_closure_for_on_received_response_ = run_loop.QuitClosure();
49 run_loop.Run();
50 quit_closure_for_on_received_response_.Reset();
51 }
52
53 void TestURLLoaderClient::RunUntilResponseBodyArrived() {
54 base::RunLoop run_loop;
55 quit_closure_for_on_start_loading_response_body_ = run_loop.QuitClosure();
56 run_loop.Run();
57 quit_closure_for_on_start_loading_response_body_.Reset();
58 }
59
60 void TestURLLoaderClient::RunUntilComplete() {
61 base::RunLoop run_loop;
62 quit_closure_for_on_complete_ = run_loop.QuitClosure();
63 run_loop.Run();
64 quit_closure_for_on_complete_.Reset();
65 }
66
67 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/test_url_loader_client.h ('k') | content/browser/loader/url_loader_factory_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698