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_ASYNC_RESOURCE_HANDLER_H_ | 5 #ifndef CONTENT_BROWSER_LOADER_ASYNC_RESOURCE_HANDLER_H_ |
6 #define CONTENT_BROWSER_LOADER_ASYNC_RESOURCE_HANDLER_H_ | 6 #define CONTENT_BROWSER_LOADER_ASYNC_RESOURCE_HANDLER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 int min_size) OVERRIDE; | 55 int min_size) OVERRIDE; |
56 virtual bool OnReadCompleted(int request_id, | 56 virtual bool OnReadCompleted(int request_id, |
57 int bytes_read, | 57 int bytes_read, |
58 bool* defer) OVERRIDE; | 58 bool* defer) OVERRIDE; |
59 virtual bool OnResponseCompleted(int request_id, | 59 virtual bool OnResponseCompleted(int request_id, |
60 const net::URLRequestStatus& status, | 60 const net::URLRequestStatus& status, |
61 const std::string& security_info) OVERRIDE; | 61 const std::string& security_info) OVERRIDE; |
62 virtual void OnDataDownloaded(int request_id, | 62 virtual void OnDataDownloaded(int request_id, |
63 int bytes_downloaded) OVERRIDE; | 63 int bytes_downloaded) OVERRIDE; |
64 | 64 |
| 65 // Once detached, no more data is sent to the renderer process. Only |
| 66 // completion and error notification. This is useful for prefetches where the |
| 67 // render process does not need the data and the download may persist longer |
| 68 // than the render process. Can only be set from false to true, not from true |
| 69 // to false. |
| 70 void SetDetachedReads(bool detached_reads); |
| 71 |
65 private: | 72 private: |
66 // IPC message handlers: | 73 // IPC message handlers: |
67 void OnFollowRedirect(int request_id, | 74 void OnFollowRedirect(int request_id, |
68 bool has_new_first_party_for_cookies, | 75 bool has_new_first_party_for_cookies, |
69 const GURL& new_first_party_for_cookies); | 76 const GURL& new_first_party_for_cookies); |
70 void OnDataReceivedACK(int request_id); | 77 void OnDataReceivedACK(int request_id); |
71 | 78 |
72 bool EnsureResourceBufferIsInitialized(); | 79 bool EnsureResourceBufferIsInitialized(); |
73 void ResumeIfDeferred(); | 80 void ResumeIfDeferred(); |
74 | 81 |
75 scoped_refptr<ResourceBuffer> buffer_; | 82 scoped_refptr<ResourceBuffer> buffer_; |
76 net::URLRequest* request_; | 83 net::URLRequest* request_; |
77 ResourceDispatcherHostImpl* rdh_; | 84 ResourceDispatcherHostImpl* rdh_; |
78 | 85 |
79 // Number of messages we've sent to the renderer that we haven't gotten an | 86 // Number of messages we've sent to the renderer that we haven't gotten an |
80 // ACK for. This allows us to avoid having too many messages in flight. | 87 // ACK for. This allows us to avoid having too many messages in flight. |
81 int pending_data_count_; | 88 int pending_data_count_; |
82 | 89 |
83 int allocation_size_; | 90 int allocation_size_; |
84 | 91 |
85 bool did_defer_; | 92 bool did_defer_; |
86 | 93 |
87 bool has_checked_for_sufficient_resources_; | 94 bool has_checked_for_sufficient_resources_; |
88 bool sent_received_response_msg_; | 95 bool sent_received_response_msg_; |
89 bool sent_first_data_msg_; | 96 bool sent_first_data_msg_; |
| 97 bool detached_reads_; |
90 | 98 |
91 DISALLOW_COPY_AND_ASSIGN(AsyncResourceHandler); | 99 DISALLOW_COPY_AND_ASSIGN(AsyncResourceHandler); |
92 }; | 100 }; |
93 | 101 |
94 } // namespace content | 102 } // namespace content |
95 | 103 |
96 #endif // CONTENT_BROWSER_LOADER_ASYNC_RESOURCE_HANDLER_H_ | 104 #endif // CONTENT_BROWSER_LOADER_ASYNC_RESOURCE_HANDLER_H_ |
OLD | NEW |