| OLD | NEW | 
|    1 // Copyright 2016 The Chromium Authors. All rights reserved. |    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 |    2 // Use of this source code is governed by a BSD-style license that can be | 
|    3 // found in the LICENSE file. |    3 // found in the LICENSE file. | 
|    4  |    4  | 
|    5 #ifndef CONTENT_BROWSER_LOADER_MOJO_ASYNC_RESOURCE_HANDLER_H_ |    5 #ifndef CONTENT_BROWSER_LOADER_MOJO_ASYNC_RESOURCE_HANDLER_H_ | 
|    6 #define CONTENT_BROWSER_LOADER_MOJO_ASYNC_RESOURCE_HANDLER_H_ |    6 #define CONTENT_BROWSER_LOADER_MOJO_ASYNC_RESOURCE_HANDLER_H_ | 
|    7  |    7  | 
|    8 #include <stdint.h> |    8 #include <stdint.h> | 
|    9  |    9  | 
|   10 #include <memory> |   10 #include <memory> | 
|   11 #include <string> |   11 #include <string> | 
|   12  |   12  | 
|   13 #include "base/macros.h" |   13 #include "base/macros.h" | 
|   14 #include "base/memory/ref_counted.h" |   14 #include "base/memory/ref_counted.h" | 
|   15 #include "base/timer/timer.h" |   15 #include "base/timer/timer.h" | 
|   16 #include "content/browser/loader/resource_handler.h" |   16 #include "content/browser/loader/resource_handler.h" | 
|   17 #include "content/common/content_export.h" |   17 #include "content/common/content_export.h" | 
|   18 #include "content/common/url_loader.mojom.h" |   18 #include "content/common/url_loader.mojom.h" | 
|   19 #include "mojo/public/cpp/bindings/binding.h" |   19 #include "mojo/public/cpp/bindings/associated_binding.h" | 
|   20 #include "mojo/public/cpp/system/watcher.h" |   20 #include "mojo/public/cpp/system/watcher.h" | 
|   21 #include "net/base/io_buffer.h" |   21 #include "net/base/io_buffer.h" | 
|   22 #include "url/gurl.h" |   22 #include "url/gurl.h" | 
|   23  |   23  | 
|   24 namespace net { |   24 namespace net { | 
|   25 class URLRequest; |   25 class URLRequest; | 
|   26 } |   26 } | 
|   27  |   27  | 
|   28 namespace content { |   28 namespace content { | 
|   29 class ResourceDispatcherHostImpl; |   29 class ResourceDispatcherHostImpl; | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
|   41 // TODO(yhirano): Send cached metadata. |   41 // TODO(yhirano): Send cached metadata. | 
|   42 // |   42 // | 
|   43 // This class can be inherited only for tests. |   43 // This class can be inherited only for tests. | 
|   44 class CONTENT_EXPORT MojoAsyncResourceHandler |   44 class CONTENT_EXPORT MojoAsyncResourceHandler | 
|   45     : public ResourceHandler, |   45     : public ResourceHandler, | 
|   46       public NON_EXPORTED_BASE(mojom::URLLoader) { |   46       public NON_EXPORTED_BASE(mojom::URLLoader) { | 
|   47  public: |   47  public: | 
|   48   MojoAsyncResourceHandler( |   48   MojoAsyncResourceHandler( | 
|   49       net::URLRequest* request, |   49       net::URLRequest* request, | 
|   50       ResourceDispatcherHostImpl* rdh, |   50       ResourceDispatcherHostImpl* rdh, | 
|   51       mojo::InterfaceRequest<mojom::URLLoader> mojo_request, |   51       mojom::URLLoaderAssociatedRequest mojo_request, | 
|   52       mojom::URLLoaderClientPtr url_loader_client); |   52       mojom::URLLoaderClientAssociatedPtr url_loader_client); | 
|   53   ~MojoAsyncResourceHandler() override; |   53   ~MojoAsyncResourceHandler() override; | 
|   54  |   54  | 
|   55   // ResourceHandler implementation: |   55   // ResourceHandler implementation: | 
|   56   bool OnRequestRedirected(const net::RedirectInfo& redirect_info, |   56   bool OnRequestRedirected(const net::RedirectInfo& redirect_info, | 
|   57                            ResourceResponse* response, |   57                            ResourceResponse* response, | 
|   58                            bool* defer) override; |   58                            bool* defer) override; | 
|   59   bool OnResponseStarted(ResourceResponse* response, bool* defer) override; |   59   bool OnResponseStarted(ResourceResponse* response, bool* defer) override; | 
|   60   bool OnWillStart(const GURL& url, bool* defer) override; |   60   bool OnWillStart(const GURL& url, bool* defer) override; | 
|   61   bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, |   61   bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, | 
|   62                   int* buf_size, |   62                   int* buf_size, | 
| (...skipping 28 matching lines...) Expand all  Loading... | 
|   91   // successfully. |   91   // successfully. | 
|   92   bool AllocateWriterIOBuffer(scoped_refptr<net::IOBufferWithSize>* buf, |   92   bool AllocateWriterIOBuffer(scoped_refptr<net::IOBufferWithSize>* buf, | 
|   93                               bool* defer); |   93                               bool* defer); | 
|   94  |   94  | 
|   95   void Resume(); |   95   void Resume(); | 
|   96   void OnDefer(); |   96   void OnDefer(); | 
|   97   bool CheckForSufficientResource(); |   97   bool CheckForSufficientResource(); | 
|   98   void OnWritable(MojoResult result); |   98   void OnWritable(MojoResult result); | 
|   99  |   99  | 
|  100   ResourceDispatcherHostImpl* rdh_; |  100   ResourceDispatcherHostImpl* rdh_; | 
|  101   mojo::Binding<mojom::URLLoader> binding_; |  101   mojo::AssociatedBinding<mojom::URLLoader> binding_; | 
|  102  |  102  | 
|  103   bool has_checked_for_sufficient_resources_ = false; |  103   bool has_checked_for_sufficient_resources_ = false; | 
|  104   bool sent_received_response_message_ = false; |  104   bool sent_received_response_message_ = false; | 
|  105   bool is_using_io_buffer_not_from_writer_ = false; |  105   bool is_using_io_buffer_not_from_writer_ = false; | 
|  106   bool did_defer_ = false; |  106   bool did_defer_ = false; | 
|  107   base::TimeTicks response_started_ticks_; |  107   base::TimeTicks response_started_ticks_; | 
|  108  |  108  | 
|  109   mojo::Watcher handle_watcher_; |  109   mojo::Watcher handle_watcher_; | 
|  110   std::unique_ptr<mojom::URLLoader> url_loader_; |  110   std::unique_ptr<mojom::URLLoader> url_loader_; | 
|  111   mojom::URLLoaderClientPtr url_loader_client_; |  111   mojom::URLLoaderClientAssociatedPtr url_loader_client_; | 
|  112   scoped_refptr<net::IOBufferWithSize> buffer_; |  112   scoped_refptr<net::IOBufferWithSize> buffer_; | 
|  113   size_t buffer_offset_ = 0; |  113   size_t buffer_offset_ = 0; | 
|  114   size_t buffer_bytes_read_ = 0; |  114   size_t buffer_bytes_read_ = 0; | 
|  115   scoped_refptr<SharedWriter> shared_writer_; |  115   scoped_refptr<SharedWriter> shared_writer_; | 
|  116  |  116  | 
|  117   DISALLOW_COPY_AND_ASSIGN(MojoAsyncResourceHandler); |  117   DISALLOW_COPY_AND_ASSIGN(MojoAsyncResourceHandler); | 
|  118 }; |  118 }; | 
|  119  |  119  | 
|  120 }  // namespace content |  120 }  // namespace content | 
|  121  |  121  | 
|  122 #endif  // CONTENT_BROWSER_LOADER_MOJO_ASYNC_RESOURCE_HANDLER_H_ |  122 #endif  // CONTENT_BROWSER_LOADER_MOJO_ASYNC_RESOURCE_HANDLER_H_ | 
| OLD | NEW |