OLD | NEW |
(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 class FakeURLLoaderClient final : public mojom::URLLoaderClient { |
| 19 public: |
| 20 FakeURLLoaderClient(); |
| 21 ~FakeURLLoaderClient() override; |
| 22 |
| 23 void OnReceiveResponse(const ResourceResponseHead& response_head) override; |
| 24 void OnStartLoadingResponseBody( |
| 25 mojo::ScopedDataPipeConsumerHandle body) override; |
| 26 void OnComplete(const ResourceRequestCompletionStatus& status) override; |
| 27 |
| 28 bool has_received_response() const { return has_received_response_; } |
| 29 bool has_received_completion() const { return has_received_completion_; } |
| 30 const ResourceResponseHead& response_head() const { return response_head_; } |
| 31 mojo::DataPipeConsumerHandle response_body() { return response_body_.get(); } |
| 32 const ResourceRequestCompletionStatus& completion_status() const { |
| 33 return completion_status_; |
| 34 } |
| 35 |
| 36 mojom::URLLoaderClientPtr CreateInterfacePtrAndBind() { |
| 37 return binding_.CreateInterfacePtrAndBind(); |
| 38 } |
| 39 void Unbind(); |
| 40 |
| 41 void set_quit_closure(const base::Closure& quit_closure) { |
| 42 quit_closure_ = quit_closure; |
| 43 } |
| 44 |
| 45 private: |
| 46 mojo::Binding<mojom::URLLoaderClient> binding_; |
| 47 ResourceResponseHead response_head_; |
| 48 mojo::ScopedDataPipeConsumerHandle response_body_; |
| 49 ResourceRequestCompletionStatus completion_status_; |
| 50 bool has_received_response_ = false; |
| 51 bool has_received_completion_ = false; |
| 52 base::Closure quit_closure_; |
| 53 |
| 54 DISALLOW_COPY_AND_ASSIGN(FakeURLLoaderClient); |
| 55 }; |
| 56 |
| 57 } // namespace content |
| 58 |
| 59 #endif // CONTENT_BROWSER_LOADER_MOJO_ASYNC_RESOURCE_HANDLER_TEST_UTIL_H_ |
OLD | NEW |