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

Side by Side Diff: content/browser/loader/mojo_async_resource_handler_test_util.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, 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 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_MOJO_ASYNC_RESOURCE_HANDLER_TEST_UTIL_H_
6 #define CONTENT_BROWSER_LOADER_MOJO_ASYNC_RESOURCE_HANDLER_TEST_UTIL_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 FakeURLLoaderClient 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 FakeURLLoaderClient final : public mojom::URLLoaderClient {
mmenke 2016/07/25 22:03:53 The thing is this is a real URLLoaderClient - URLL
yhirano 2016/07/27 16:13:28 Done.
23 public:
24 FakeURLLoaderClient();
25 ~FakeURLLoaderClient() 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 // The set closure will be called when one of On* functions is called.
44 void set_quit_closure(const base::Closure& quit_closure) {
45 quit_closure_ = quit_closure;
46 }
47
48 private:
49 mojo::Binding<mojom::URLLoaderClient> binding_;
50 ResourceResponseHead response_head_;
51 mojo::ScopedDataPipeConsumerHandle response_body_;
52 ResourceRequestCompletionStatus completion_status_;
53 bool has_received_response_ = false;
54 bool has_received_completion_ = false;
55 base::Closure quit_closure_;
56
57 DISALLOW_COPY_AND_ASSIGN(FakeURLLoaderClient);
58 };
59
60 } // namespace content
61
62 #endif // CONTENT_BROWSER_LOADER_MOJO_ASYNC_RESOURCE_HANDLER_TEST_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698