| 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 IPC { | 16 namespace IPC { |
| 17 class Message; | 17 class Message; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace net { | 20 namespace net { |
| 21 class IOBuffer; | 21 class IOBuffer; |
| 22 class URLRequest; | 22 class URLRequest; |
| 23 } | 23 } |
| 24 | 24 |
| 25 namespace content { | 25 namespace content { |
| 26 class ResourceController; |
| 26 | 27 |
| 27 // Used to complete a synchronous resource request in response to resource load | 28 // Used to complete a synchronous resource request in response to resource load |
| 28 // events from the resource dispatcher host. | 29 // events from the resource dispatcher host. |
| 29 class SyncResourceHandler : public ResourceHandler { | 30 class SyncResourceHandler : public ResourceHandler { |
| 30 public: | 31 public: |
| 31 using SyncLoadResultCallback = | 32 using SyncLoadResultCallback = |
| 32 ResourceDispatcherHostImpl::SyncLoadResultCallback; | 33 ResourceDispatcherHostImpl::SyncLoadResultCallback; |
| 33 | 34 |
| 34 SyncResourceHandler(net::URLRequest* request, | 35 SyncResourceHandler(net::URLRequest* request, |
| 35 const SyncLoadResultCallback& sync_result_handler, | 36 const SyncLoadResultCallback& sync_result_handler, |
| 36 ResourceDispatcherHostImpl* resource_dispatcher_host); | 37 ResourceDispatcherHostImpl* resource_dispatcher_host); |
| 37 ~SyncResourceHandler() override; | 38 ~SyncResourceHandler() override; |
| 38 | 39 |
| 39 bool OnRequestRedirected(const net::RedirectInfo& redirect_info, | 40 void OnRequestRedirected( |
| 40 ResourceResponse* response, | 41 const net::RedirectInfo& redirect_info, |
| 41 bool* defer) override; | 42 ResourceResponse* response, |
| 42 bool OnResponseStarted(ResourceResponse* response, bool* defer) override; | 43 std::unique_ptr<ResourceController> controller) override; |
| 43 bool OnWillStart(const GURL& url, bool* defer) override; | 44 void OnResponseStarted( |
| 45 ResourceResponse* response, |
| 46 std::unique_ptr<ResourceController> controller) override; |
| 47 void OnWillStart(const GURL& url, |
| 48 std::unique_ptr<ResourceController> controller) override; |
| 44 bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, | 49 bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, |
| 45 int* buf_size, | 50 int* buf_size, |
| 46 int min_size) override; | 51 int min_size) override; |
| 47 bool OnReadCompleted(int bytes_read, bool* defer) override; | 52 void OnReadCompleted(int bytes_read, |
| 48 void OnResponseCompleted(const net::URLRequestStatus& status, | 53 std::unique_ptr<ResourceController> controller) override; |
| 49 bool* defer) override; | 54 void OnResponseCompleted( |
| 55 const net::URLRequestStatus& status, |
| 56 std::unique_ptr<ResourceController> controller) override; |
| 50 void OnDataDownloaded(int bytes_downloaded) override; | 57 void OnDataDownloaded(int bytes_downloaded) override; |
| 51 | 58 |
| 52 private: | 59 private: |
| 53 enum { kReadBufSize = 3840 }; | 60 enum { kReadBufSize = 3840 }; |
| 54 | 61 |
| 55 scoped_refptr<net::IOBuffer> read_buffer_; | 62 scoped_refptr<net::IOBuffer> read_buffer_; |
| 56 | 63 |
| 57 SyncLoadResult result_; | 64 SyncLoadResult result_; |
| 58 SyncLoadResultCallback result_handler_; | 65 SyncLoadResultCallback result_handler_; |
| 59 ResourceDispatcherHostImpl* rdh_; | 66 ResourceDispatcherHostImpl* rdh_; |
| 60 int64_t total_transfer_size_; | 67 int64_t total_transfer_size_; |
| 61 }; | 68 }; |
| 62 | 69 |
| 63 } // namespace content | 70 } // namespace content |
| 64 | 71 |
| 65 #endif // CONTENT_BROWSER_LOADER_SYNC_RESOURCE_HANDLER_H_ | 72 #endif // CONTENT_BROWSER_LOADER_SYNC_RESOURCE_HANDLER_H_ |
| OLD | NEW |