Chromium Code Reviews| Index: content/browser/loader/mojo_async_resource_handler.h |
| diff --git a/content/browser/loader/mojo_async_resource_handler.h b/content/browser/loader/mojo_async_resource_handler.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..64e6513577a56048ed2faaf4f2bd98ba6cc0b344 |
| --- /dev/null |
| +++ b/content/browser/loader/mojo_async_resource_handler.h |
| @@ -0,0 +1,83 @@ |
| +// 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_H_ |
| +#define CONTENT_BROWSER_LOADER_MOJO_ASYNC_RESOURCE_HANDLER_H_ |
| + |
| +#include <stdint.h> |
| + |
| +#include <memory> |
| +#include <string> |
| + |
| +#include "base/macros.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "base/timer/timer.h" |
| +#include "content/browser/loader/resource_handler.h" |
| +#include "content/common/url_loader.mojom.h" |
| +#include "mojo/message_pump/handle_watcher.h" |
| +#include "mojo/public/cpp/system/data_pipe.h" |
| +#include "net/base/io_buffer.h" |
| +#include "url/gurl.h" |
| + |
| +namespace net { |
| +class URLRequest; |
| +} |
| + |
| +namespace content { |
| +class ResourceDispatcherHostImpl; |
| + |
| +// Used to complete an asynchronous resource request in response to resource |
| +// load events from the resource dispatcher host. This class is used only |
| +// when LoadingWithMojo runtime enabled flag is enabled. |
|
mmenke
2016/05/26 21:46:09
Could you add TODOs about what this does not yet s
yhirano
2016/05/27 11:30:34
Done.
|
| +class MojoAsyncResourceHandler : public ResourceHandler { |
| + public: |
| + MojoAsyncResourceHandler(net::URLRequest* request, |
| + ResourceDispatcherHostImpl* rdh, |
| + std::unique_ptr<mojom::URLLoader> url_loader, |
| + mojom::URLLoaderClientPtr url_loader_client); |
| + ~MojoAsyncResourceHandler() override; |
| + |
| + // ResourceHandler implementation: |
| + bool OnRequestRedirected(const net::RedirectInfo& redirect_info, |
| + ResourceResponse* response, |
| + bool* defer) override; |
| + bool OnResponseStarted(ResourceResponse* response, bool* defer) override; |
| + bool OnWillStart(const GURL& url, bool* defer) override; |
| + bool OnBeforeNetworkStart(const GURL& url, bool* defer) override; |
| + bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, |
| + int* buf_size, |
| + int min_size) override; |
| + bool OnReadCompleted(int bytes_read, bool* defer) override; |
| + void OnResponseCompleted(const net::URLRequestStatus& status, |
| + const std::string& security_info, |
| + bool* defer) override; |
| + void OnDataDownloaded(int bytes_downloaded) override; |
| + |
| + private: |
| + // IPC message handlers: |
| + void OnFollowRedirect(int request_id); |
| + |
| + void ResumeIfDeferred(); |
| + void OnDefer(); |
| + bool CheckForSufficientResource(); |
| + void OnWritable(MojoResult result); |
| + |
| + ResourceDispatcherHostImpl* rdh_; |
| + |
| + bool did_defer_ = false; |
| + bool has_checked_for_sufficient_resources_ = false; |
| + bool sent_received_response_message_ = false; |
| + base::TimeTicks response_started_ticks_; |
| + |
| + mojo::ScopedDataPipeProducerHandle writer_; |
| + mojo::common::HandleWatcher handle_watcher_; |
| + std::unique_ptr<mojom::URLLoader> url_loader_; |
| + mojom::URLLoaderClientPtr url_loader_client_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(MojoAsyncResourceHandler); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_BROWSER_LOADER_MOJO_ASYNC_RESOURCE_HANDLER_H_ |