| 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> |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "mojo/public/cpp/system/watcher.h" | 21 #include "mojo/public/cpp/system/watcher.h" |
| 22 #include "net/base/io_buffer.h" | 22 #include "net/base/io_buffer.h" |
| 23 #include "url/gurl.h" | 23 #include "url/gurl.h" |
| 24 | 24 |
| 25 namespace net { | 25 namespace net { |
| 26 class IOBufferWithSize; | 26 class IOBufferWithSize; |
| 27 class URLRequest; | 27 class URLRequest; |
| 28 } | 28 } |
| 29 | 29 |
| 30 namespace content { | 30 namespace content { |
| 31 class ResourceController; |
| 31 class ResourceDispatcherHostImpl; | 32 class ResourceDispatcherHostImpl; |
| 32 struct ResourceResponse; | 33 struct ResourceResponse; |
| 33 | 34 |
| 34 // Used to complete an asynchronous resource request in response to resource | 35 // Used to complete an asynchronous resource request in response to resource |
| 35 // load events from the resource dispatcher host. This class is used only | 36 // load events from the resource dispatcher host. This class is used only |
| 36 // when LoadingWithMojo runtime flag is enabled. | 37 // when LoadingWithMojo runtime flag is enabled. |
| 37 // | 38 // |
| 38 // TODO(yhirano): Add histograms. | 39 // TODO(yhirano): Add histograms. |
| 39 // TODO(yhirano): Send cached metadata. | 40 // TODO(yhirano): Send cached metadata. |
| 40 // | 41 // |
| 41 // This class can be inherited only for tests. | 42 // This class can be inherited only for tests. |
| 42 class CONTENT_EXPORT MojoAsyncResourceHandler | 43 class CONTENT_EXPORT MojoAsyncResourceHandler |
| 43 : public ResourceHandler, | 44 : public ResourceHandler, |
| 44 public NON_EXPORTED_BASE(mojom::URLLoader) { | 45 public NON_EXPORTED_BASE(mojom::URLLoader) { |
| 45 public: | 46 public: |
| 46 MojoAsyncResourceHandler( | 47 MojoAsyncResourceHandler( |
| 47 net::URLRequest* request, | 48 net::URLRequest* request, |
| 48 ResourceDispatcherHostImpl* rdh, | 49 ResourceDispatcherHostImpl* rdh, |
| 49 mojom::URLLoaderAssociatedRequest mojo_request, | 50 mojom::URLLoaderAssociatedRequest mojo_request, |
| 50 mojom::URLLoaderClientAssociatedPtr url_loader_client); | 51 mojom::URLLoaderClientAssociatedPtr url_loader_client); |
| 51 ~MojoAsyncResourceHandler() override; | 52 ~MojoAsyncResourceHandler() override; |
| 52 | 53 |
| 53 // ResourceHandler implementation: | 54 // ResourceHandler implementation: |
| 54 bool OnRequestRedirected(const net::RedirectInfo& redirect_info, | 55 void OnRequestRedirected( |
| 55 ResourceResponse* response, | 56 const net::RedirectInfo& redirect_info, |
| 56 bool* defer) override; | 57 ResourceResponse* response, |
| 57 bool OnResponseStarted(ResourceResponse* response, bool* defer) override; | 58 std::unique_ptr<ResourceController> controller) override; |
| 58 bool OnWillStart(const GURL& url, bool* defer) override; | 59 void OnResponseStarted( |
| 60 ResourceResponse* response, |
| 61 std::unique_ptr<ResourceController> controller) override; |
| 62 void OnWillStart(const GURL& url, |
| 63 std::unique_ptr<ResourceController> controller) override; |
| 59 bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, | 64 bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, |
| 60 int* buf_size, | 65 int* buf_size, |
| 61 int min_size) override; | 66 int min_size) override; |
| 62 bool OnReadCompleted(int bytes_read, bool* defer) override; | 67 void OnReadCompleted(int bytes_read, |
| 63 void OnResponseCompleted(const net::URLRequestStatus& status, | 68 std::unique_ptr<ResourceController> controller) override; |
| 64 bool* defer) override; | 69 void OnResponseCompleted( |
| 70 const net::URLRequestStatus& status, |
| 71 std::unique_ptr<ResourceController> controller) override; |
| 65 void OnDataDownloaded(int bytes_downloaded) override; | 72 void OnDataDownloaded(int bytes_downloaded) override; |
| 66 | 73 |
| 67 // mojom::URLLoader implementation | 74 // mojom::URLLoader implementation |
| 68 void FollowRedirect() override; | 75 void FollowRedirect() override; |
| 69 | 76 |
| 70 void OnWritableForTesting(); | 77 void OnWritableForTesting(); |
| 71 static void SetAllocationSizeForTesting(size_t size); | 78 static void SetAllocationSizeForTesting(size_t size); |
| 72 static constexpr size_t kDefaultAllocationSize = 512 * 1024; | 79 static constexpr size_t kDefaultAllocationSize = 512 * 1024; |
| 73 | 80 |
| 74 protected: | 81 protected: |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 size_t buffer_bytes_read_ = 0; | 129 size_t buffer_bytes_read_ = 0; |
| 123 scoped_refptr<SharedWriter> shared_writer_; | 130 scoped_refptr<SharedWriter> shared_writer_; |
| 124 | 131 |
| 125 base::WeakPtrFactory<MojoAsyncResourceHandler> weak_factory_; | 132 base::WeakPtrFactory<MojoAsyncResourceHandler> weak_factory_; |
| 126 DISALLOW_COPY_AND_ASSIGN(MojoAsyncResourceHandler); | 133 DISALLOW_COPY_AND_ASSIGN(MojoAsyncResourceHandler); |
| 127 }; | 134 }; |
| 128 | 135 |
| 129 } // namespace content | 136 } // namespace content |
| 130 | 137 |
| 131 #endif // CONTENT_BROWSER_LOADER_MOJO_ASYNC_RESOURCE_HANDLER_H_ | 138 #endif // CONTENT_BROWSER_LOADER_MOJO_ASYNC_RESOURCE_HANDLER_H_ |
| OLD | NEW |