Chromium Code Reviews| Index: content/browser/loader/mojo_async_resource_handler_test_util.h |
| diff --git a/content/browser/loader/mojo_async_resource_handler_test_util.h b/content/browser/loader/mojo_async_resource_handler_test_util.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..804607b19c0b46c5a1efcf9010d4410b2a270398 |
| --- /dev/null |
| +++ b/content/browser/loader/mojo_async_resource_handler_test_util.h |
| @@ -0,0 +1,59 @@ |
| +// 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. |
| + |
| +#ifndef CONTENT_BROWSER_LOADER_MOJO_ASYNC_RESOURCE_HANDLER_TEST_UTIL_H_ |
| +#define CONTENT_BROWSER_LOADER_MOJO_ASYNC_RESOURCE_HANDLER_TEST_UTIL_H_ |
| + |
| +#include "base/callback.h" |
| +#include "base/macros.h" |
| +#include "content/common/resource_request_completion_status.h" |
| +#include "content/common/url_loader.mojom.h" |
| +#include "content/public/common/resource_response.h" |
| +#include "mojo/public/c/system/data_pipe.h" |
| +#include "mojo/public/cpp/bindings/binding.h" |
| + |
| +namespace content { |
| + |
| +class FakeURLLoaderClient final : public mojom::URLLoaderClient { |
|
mmenke
2016/07/20 19:08:42
Class needs to be documented.
mmenke
2016/07/20 19:08:42
Is this really a fake client? I guess it doesn't
mmenke
2016/07/20 19:08:42
Can you call this fake_url_loader_client.h? test_
yhirano
2016/07/21 14:50:20
I don't feel it so unnatural but maybe my wording
yhirano
2016/07/21 14:50:21
Done.
yhirano
2016/07/21 14:50:21
Will do when we agree on the class name.
|
| + public: |
| + FakeURLLoaderClient(); |
| + ~FakeURLLoaderClient() override; |
| + |
| + void OnReceiveResponse(const ResourceResponseHead& response_head) override; |
| + void OnStartLoadingResponseBody( |
| + mojo::ScopedDataPipeConsumerHandle body) override; |
| + void OnComplete(const ResourceRequestCompletionStatus& status) override; |
| + |
| + bool has_received_response() const { return has_received_response_; } |
| + bool has_received_completion() const { return has_received_completion_; } |
| + const ResourceResponseHead& response_head() const { return response_head_; } |
| + mojo::DataPipeConsumerHandle response_body() { return response_body_.get(); } |
| + const ResourceRequestCompletionStatus& completion_status() const { |
| + return completion_status_; |
| + } |
| + |
| + mojom::URLLoaderClientPtr CreateInterfacePtrAndBind() { |
|
mmenke
2016/07/20 19:08:42
Shouldn't inline a non-trivial method.
yhirano
2016/07/21 14:50:21
Done.
|
| + return binding_.CreateInterfacePtrAndBind(); |
| + } |
| + void Unbind(); |
| + |
| + void set_quit_closure(const base::Closure& quit_closure) { |
|
mmenke
2016/07/20 19:08:42
Not at all clear when this is called. Also, is the
yhirano
2016/07/21 14:50:21
Done.
|
| + quit_closure_ = quit_closure; |
| + } |
| + |
| + private: |
| + mojo::Binding<mojom::URLLoaderClient> binding_; |
| + ResourceResponseHead response_head_; |
| + mojo::ScopedDataPipeConsumerHandle response_body_; |
| + ResourceRequestCompletionStatus completion_status_; |
| + bool has_received_response_ = false; |
| + bool has_received_completion_ = false; |
| + base::Closure quit_closure_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(FakeURLLoaderClient); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_BROWSER_LOADER_MOJO_ASYNC_RESOURCE_HANDLER_TEST_UTIL_H_ |