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