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

Side by Side Diff: content/browser/loader/test_url_loader_client.h

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 #ifndef CONTENT_BROWSER_LOADER_TEST_URL_LOADER_CLIENT_H_
6 #define CONTENT_BROWSER_LOADER_TEST_URL_LOADER_CLIENT_H_
7
8 #include "base/callback.h"
9 #include "base/macros.h"
10 #include "content/common/resource_request_completion_status.h"
11 #include "content/common/url_loader.mojom.h"
12 #include "content/public/common/resource_response.h"
13 #include "mojo/public/c/system/data_pipe.h"
14 #include "mojo/public/cpp/bindings/binding.h"
15
16 namespace content {
17
18 // A TestURLLoaderClient records URLLoaderClient function calls. It also calls
19 // the closure set via set_quit_closure if set, in order to make it possible to
20 // create a base::RunLoop, set its quit closure to this client and then run the
21 // RunLoop.
22 class TestURLLoaderClient final : public mojom::URLLoaderClient {
23 public:
24 TestURLLoaderClient();
25 ~TestURLLoaderClient() override;
26
27 void OnReceiveResponse(const ResourceResponseHead& response_head) override;
28 void OnStartLoadingResponseBody(
29 mojo::ScopedDataPipeConsumerHandle body) override;
30 void OnComplete(const ResourceRequestCompletionStatus& status) override;
31
32 bool has_received_response() const { return has_received_response_; }
33 bool has_received_completion() const { return has_received_completion_; }
34 const ResourceResponseHead& response_head() const { return response_head_; }
35 mojo::DataPipeConsumerHandle response_body() { return response_body_.get(); }
36 const ResourceRequestCompletionStatus& completion_status() const {
37 return completion_status_;
38 }
39
40 mojom::URLLoaderClientPtr CreateInterfacePtrAndBind();
41 void Unbind();
42
43 void RunUntilResponseReceived();
44 void RunUntilResponseBodyArrived();
45 void RunUntilComplete();
46
47 private:
48 mojo::Binding<mojom::URLLoaderClient> binding_;
49 ResourceResponseHead response_head_;
50 mojo::ScopedDataPipeConsumerHandle response_body_;
51 ResourceRequestCompletionStatus completion_status_;
52 bool has_received_response_ = false;
53 bool has_received_completion_ = false;
54 base::Closure quit_closure_for_on_received_response_;
55 base::Closure quit_closure_for_on_start_loading_response_body_;
56 base::Closure quit_closure_for_on_complete_;
57
58 DISALLOW_COPY_AND_ASSIGN(TestURLLoaderClient);
59 };
60
61 } // namespace content
62
63 #endif // CONTENT_BROWSER_LOADER_TEST_URL_LOADER_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698