| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_SYNC_RESOURCE_HANDLER_H_ | 5 #ifndef CONTENT_BROWSER_LOADER_SYNC_RESOURCE_HANDLER_H_ |
| 6 #define CONTENT_BROWSER_LOADER_SYNC_RESOURCE_HANDLER_H_ | 6 #define CONTENT_BROWSER_LOADER_SYNC_RESOURCE_HANDLER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 12 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
| 13 #include "content/browser/loader/resource_handler.h" | 13 #include "content/browser/loader/resource_handler.h" |
| 14 #include "content/public/common/resource_response.h" | 14 #include "content/public/common/resource_response.h" |
| 15 | 15 |
| 16 namespace net { | 16 namespace net { |
| 17 class IOBuffer; | 17 class IOBuffer; |
| 18 class URLRequest; | 18 class URLRequest; |
| 19 } | 19 } |
| 20 | 20 |
| 21 namespace content { | 21 namespace content { |
| 22 class ResourceController; |
| 22 | 23 |
| 23 // Used to complete a synchronous resource request in response to resource load | 24 // Used to complete a synchronous resource request in response to resource load |
| 24 // events from the resource dispatcher host. | 25 // events from the resource dispatcher host. |
| 25 class SyncResourceHandler : public ResourceHandler { | 26 class SyncResourceHandler : public ResourceHandler { |
| 26 public: | 27 public: |
| 27 using SyncLoadResultCallback = | 28 using SyncLoadResultCallback = |
| 28 ResourceDispatcherHostImpl::SyncLoadResultCallback; | 29 ResourceDispatcherHostImpl::SyncLoadResultCallback; |
| 29 | 30 |
| 30 SyncResourceHandler(net::URLRequest* request, | 31 SyncResourceHandler(net::URLRequest* request, |
| 31 const SyncLoadResultCallback& sync_result_handler, | 32 const SyncLoadResultCallback& sync_result_handler, |
| 32 ResourceDispatcherHostImpl* resource_dispatcher_host); | 33 ResourceDispatcherHostImpl* resource_dispatcher_host); |
| 33 ~SyncResourceHandler() override; | 34 ~SyncResourceHandler() override; |
| 34 | 35 |
| 35 bool OnRequestRedirected(const net::RedirectInfo& redirect_info, | 36 void OnRequestRedirected( |
| 36 ResourceResponse* response, | 37 const net::RedirectInfo& redirect_info, |
| 37 bool* defer) override; | 38 ResourceResponse* response, |
| 38 bool OnResponseStarted(ResourceResponse* response, bool* defer) override; | 39 std::unique_ptr<ResourceController> controller) override; |
| 39 bool OnWillStart(const GURL& url, bool* defer) override; | 40 void OnResponseStarted( |
| 41 ResourceResponse* response, |
| 42 std::unique_ptr<ResourceController> controller) override; |
| 43 void OnWillStart(const GURL& url, |
| 44 std::unique_ptr<ResourceController> controller) override; |
| 40 bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, | 45 bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, |
| 41 int* buf_size, | 46 int* buf_size, |
| 42 int min_size) override; | 47 int min_size) override; |
| 43 bool OnReadCompleted(int bytes_read, bool* defer) override; | 48 void OnReadCompleted(int bytes_read, |
| 44 void OnResponseCompleted(const net::URLRequestStatus& status, | 49 std::unique_ptr<ResourceController> controller) override; |
| 45 bool* defer) override; | 50 void OnResponseCompleted( |
| 51 const net::URLRequestStatus& status, |
| 52 std::unique_ptr<ResourceController> controller) override; |
| 46 void OnDataDownloaded(int bytes_downloaded) override; | 53 void OnDataDownloaded(int bytes_downloaded) override; |
| 47 | 54 |
| 48 private: | 55 private: |
| 49 enum { kReadBufSize = 3840 }; | 56 enum { kReadBufSize = 3840 }; |
| 50 | 57 |
| 51 scoped_refptr<net::IOBuffer> read_buffer_; | 58 scoped_refptr<net::IOBuffer> read_buffer_; |
| 52 | 59 |
| 53 SyncLoadResult result_; | 60 SyncLoadResult result_; |
| 54 SyncLoadResultCallback result_handler_; | 61 SyncLoadResultCallback result_handler_; |
| 55 ResourceDispatcherHostImpl* rdh_; | 62 ResourceDispatcherHostImpl* rdh_; |
| 56 int64_t total_transfer_size_; | 63 int64_t total_transfer_size_; |
| 57 }; | 64 }; |
| 58 | 65 |
| 59 } // namespace content | 66 } // namespace content |
| 60 | 67 |
| 61 #endif // CONTENT_BROWSER_LOADER_SYNC_RESOURCE_HANDLER_H_ | 68 #endif // CONTENT_BROWSER_LOADER_SYNC_RESOURCE_HANDLER_H_ |
| OLD | NEW |