OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 NET_HTTP_PARTIAL_DATA_H_ | 5 #ifndef NET_HTTP_PARTIAL_DATA_H_ |
6 #define NET_HTTP_PARTIAL_DATA_H_ | 6 #define NET_HTTP_PARTIAL_DATA_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "net/base/completion_callback.h" | 10 #include "net/base/completion_callback.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
71 | 71 |
72 // Extracts info from headers already stored in the cache. Returns false if | 72 // Extracts info from headers already stored in the cache. Returns false if |
73 // there is any problem with the headers. |truncated| should be true if we | 73 // there is any problem with the headers. |truncated| should be true if we |
74 // have an incomplete 200 entry. | 74 // have an incomplete 200 entry. |
75 bool UpdateFromStoredHeaders(const HttpResponseHeaders* headers, | 75 bool UpdateFromStoredHeaders(const HttpResponseHeaders* headers, |
76 disk_cache::Entry* entry, bool truncated); | 76 disk_cache::Entry* entry, bool truncated); |
77 | 77 |
78 // Sets the byte current range to start again at zero (for a truncated entry). | 78 // Sets the byte current range to start again at zero (for a truncated entry). |
79 void SetRangeToStartDownload(); | 79 void SetRangeToStartDownload(); |
80 | 80 |
81 // Switch to network reads for the remainder of the request. | |
rvargas (doing something else)
2015/08/19 23:46:39
Document what is the return value (the caller is a
asanka
2015/09/04 19:09:04
Done.
| |
82 bool SkipCacheForRemainder(); | |
83 | |
81 // Returns true if the requested range is valid given the stored data. | 84 // Returns true if the requested range is valid given the stored data. |
82 bool IsRequestedRangeOK(); | 85 bool IsRequestedRangeOK(); |
83 | 86 |
84 // Returns true if the response headers match what we expect, false otherwise. | 87 // Returns true if the response headers match what we expect, false otherwise. |
85 bool ResponseHeadersOK(const HttpResponseHeaders* headers); | 88 bool ResponseHeadersOK(const HttpResponseHeaders* headers); |
86 | 89 |
87 // Fixes the response headers to include the right content length and range. | 90 // Fixes the response headers to include the right content length and range. |
88 // |success| is the result of the whole request so if it's false, we'll change | 91 // |success| is the result of the whole request so if it's false, we'll change |
89 // the result code to be 416. | 92 // the result code to be 416. |
90 void FixResponseHeaders(HttpResponseHeaders* headers, bool success); | 93 void FixResponseHeaders(HttpResponseHeaders* headers, bool success); |
(...skipping 23 matching lines...) Expand all Loading... | |
114 void OnCacheReadCompleted(int result); | 117 void OnCacheReadCompleted(int result); |
115 | 118 |
116 // This method should be called after receiving data from the network, to | 119 // This method should be called after receiving data from the network, to |
117 // update the internal state about the current range. | 120 // update the internal state about the current range. |
118 void OnNetworkReadCompleted(int result); | 121 void OnNetworkReadCompleted(int result); |
119 | 122 |
120 bool initial_validation() const { return initial_validation_; } | 123 bool initial_validation() const { return initial_validation_; } |
121 | 124 |
122 private: | 125 private: |
123 // Returns the length to use when scanning the cache. | 126 // Returns the length to use when scanning the cache. |
124 int GetNextRangeLen(); | 127 int64 GetNextRangeLen(); |
125 | 128 |
126 // Completion routine for our callback. | 129 // Completion routine for our callback. |
127 void GetAvailableRangeCompleted(int64* start, int result); | 130 void GetAvailableRangeCompleted(int64* start, int result); |
128 | 131 |
129 int64 current_range_start_; | 132 int64 current_range_start_; |
130 int64 current_range_end_; | 133 int64 current_range_end_; |
131 int64 cached_start_; | 134 int64 cached_start_; |
132 int64 resource_size_; | 135 int64 resource_size_; |
133 int cached_min_len_; | 136 int64 cached_min_len_; |
134 HttpByteRange byte_range_; // The range requested by the user. | 137 HttpByteRange byte_range_; // The range requested by the user. |
135 // The clean set of extra headers (no ranges). | 138 // The clean set of extra headers (no ranges). |
136 HttpRequestHeaders extra_headers_; | 139 HttpRequestHeaders extra_headers_; |
137 bool range_present_; // True if next range entry is already stored. | 140 bool range_present_; // True if next range entry is already stored. |
138 bool final_range_; | 141 bool final_range_; |
139 bool sparse_entry_; | 142 bool sparse_entry_; |
140 bool truncated_; // We have an incomplete 200 stored. | 143 bool truncated_; // We have an incomplete 200 stored. |
141 bool initial_validation_; // Only used for truncated entries. | 144 bool initial_validation_; // Only used for truncated entries. |
142 CompletionCallback callback_; | 145 CompletionCallback callback_; |
143 base::WeakPtrFactory<PartialData> weak_factory_; | 146 base::WeakPtrFactory<PartialData> weak_factory_; |
144 | 147 |
145 DISALLOW_COPY_AND_ASSIGN(PartialData); | 148 DISALLOW_COPY_AND_ASSIGN(PartialData); |
146 }; | 149 }; |
147 | 150 |
148 } // namespace net | 151 } // namespace net |
149 | 152 |
150 #endif // NET_HTTP_PARTIAL_DATA_H_ | 153 #endif // NET_HTTP_PARTIAL_DATA_H_ |
OLD | NEW |