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 17 matching lines...) Expand all Loading... |
28 namespace tracked_objects { | 28 namespace tracked_objects { |
29 class Location; | 29 class Location; |
30 } | 30 } |
31 | 31 |
32 namespace net { | 32 namespace net { |
33 class IOBufferWithSize; | 33 class IOBufferWithSize; |
34 class URLRequest; | 34 class URLRequest; |
35 } | 35 } |
36 | 36 |
37 namespace content { | 37 namespace content { |
| 38 class ResourceController; |
38 class ResourceDispatcherHostImpl; | 39 class ResourceDispatcherHostImpl; |
39 struct ResourceResponse; | 40 struct ResourceResponse; |
40 | 41 |
41 // Used to complete an asynchronous resource request in response to resource | 42 // Used to complete an asynchronous resource request in response to resource |
42 // load events from the resource dispatcher host. This class is used only | 43 // load events from the resource dispatcher host. This class is used only |
43 // when LoadingWithMojo runtime flag is enabled. | 44 // when LoadingWithMojo runtime flag is enabled. |
44 // | 45 // |
45 // TODO(yhirano): Add histograms. | 46 // TODO(yhirano): Add histograms. |
46 // TODO(yhirano): Send cached metadata. | 47 // TODO(yhirano): Send cached metadata. |
47 // | 48 // |
48 // This class can be inherited only for tests. | 49 // This class can be inherited only for tests. |
49 class CONTENT_EXPORT MojoAsyncResourceHandler | 50 class CONTENT_EXPORT MojoAsyncResourceHandler |
50 : public ResourceHandler, | 51 : public ResourceHandler, |
51 public NON_EXPORTED_BASE(mojom::URLLoader) { | 52 public NON_EXPORTED_BASE(mojom::URLLoader) { |
52 public: | 53 public: |
53 MojoAsyncResourceHandler( | 54 MojoAsyncResourceHandler( |
54 net::URLRequest* request, | 55 net::URLRequest* request, |
55 ResourceDispatcherHostImpl* rdh, | 56 ResourceDispatcherHostImpl* rdh, |
56 mojom::URLLoaderAssociatedRequest mojo_request, | 57 mojom::URLLoaderAssociatedRequest mojo_request, |
57 mojom::URLLoaderClientAssociatedPtr url_loader_client, | 58 mojom::URLLoaderClientAssociatedPtr url_loader_client, |
58 ResourceType resource_type); | 59 ResourceType resource_type); |
59 ~MojoAsyncResourceHandler() override; | 60 ~MojoAsyncResourceHandler() override; |
60 | 61 |
61 // ResourceHandler implementation: | 62 // ResourceHandler implementation: |
62 bool OnRequestRedirected(const net::RedirectInfo& redirect_info, | 63 void OnRequestRedirected( |
63 ResourceResponse* response, | 64 const net::RedirectInfo& redirect_info, |
64 bool* defer) override; | 65 ResourceResponse* response, |
65 bool OnResponseStarted(ResourceResponse* response, bool* defer) override; | 66 std::unique_ptr<ResourceController> controller) override; |
66 bool OnWillStart(const GURL& url, bool* defer) override; | 67 void OnResponseStarted( |
| 68 ResourceResponse* response, |
| 69 std::unique_ptr<ResourceController> controller) override; |
| 70 void OnWillStart(const GURL& url, |
| 71 std::unique_ptr<ResourceController> controller) override; |
67 bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, | 72 bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, |
68 int* buf_size, | 73 int* buf_size, |
69 int min_size) override; | 74 int min_size) override; |
70 bool OnReadCompleted(int bytes_read, bool* defer) override; | 75 void OnReadCompleted(int bytes_read, |
71 void OnResponseCompleted(const net::URLRequestStatus& status, | 76 std::unique_ptr<ResourceController> controller) override; |
72 bool* defer) override; | 77 void OnResponseCompleted( |
| 78 const net::URLRequestStatus& status, |
| 79 std::unique_ptr<ResourceController> controller) override; |
73 void OnDataDownloaded(int bytes_downloaded) override; | 80 void OnDataDownloaded(int bytes_downloaded) override; |
74 | 81 |
75 // mojom::URLLoader implementation: | 82 // mojom::URLLoader implementation: |
76 void FollowRedirect() override; | 83 void FollowRedirect() override; |
77 | 84 |
78 void OnWritableForTesting(); | 85 void OnWritableForTesting(); |
79 static void SetAllocationSizeForTesting(size_t size); | 86 static void SetAllocationSizeForTesting(size_t size); |
80 static constexpr size_t kDefaultAllocationSize = 512 * 1024; | 87 static constexpr size_t kDefaultAllocationSize = 512 * 1024; |
81 | 88 |
82 protected: | 89 protected: |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 | 146 |
140 std::unique_ptr<UploadProgressTracker> upload_progress_tracker_; | 147 std::unique_ptr<UploadProgressTracker> upload_progress_tracker_; |
141 | 148 |
142 base::WeakPtrFactory<MojoAsyncResourceHandler> weak_factory_; | 149 base::WeakPtrFactory<MojoAsyncResourceHandler> weak_factory_; |
143 DISALLOW_COPY_AND_ASSIGN(MojoAsyncResourceHandler); | 150 DISALLOW_COPY_AND_ASSIGN(MojoAsyncResourceHandler); |
144 }; | 151 }; |
145 | 152 |
146 } // namespace content | 153 } // namespace content |
147 | 154 |
148 #endif // CONTENT_BROWSER_LOADER_MOJO_ASYNC_RESOURCE_HANDLER_H_ | 155 #endif // CONTENT_BROWSER_LOADER_MOJO_ASYNC_RESOURCE_HANDLER_H_ |
OLD | NEW |