| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 // of those individual network / cache requests. | 31 // of those individual network / cache requests. |
| 32 class PartialData { | 32 class PartialData { |
| 33 public: | 33 public: |
| 34 PartialData() | 34 PartialData() |
| 35 : range_present_(false), final_range_(false), sparse_entry_(true), | 35 : range_present_(false), final_range_(false), sparse_entry_(true), |
| 36 truncated_(false) {} | 36 truncated_(false) {} |
| 37 ~PartialData() {} | 37 ~PartialData() {} |
| 38 | 38 |
| 39 // Performs initialization of the object by parsing the request |headers| | 39 // Performs initialization of the object by parsing the request |headers| |
| 40 // and verifying that we can process the requested range. Returns true if | 40 // and verifying that we can process the requested range. Returns true if |
| 41 // we can process the requested range, and false otherwise. |new_headers| is | 41 // we can process the requested range, and false otherwise. |
| 42 // a subset of the request extra headers, with byte-range related headers | 42 bool Init(const std::string& headers); |
| 43 // removed so that we can easily add any byte-range that we need. | 43 |
| 44 bool Init(const std::string& headers, const std::string& new_headers); | 44 // Sets the headers that we should use to make byte range requests. This is a |
| 45 // subset of the request extra headers, with byte-range related headers |
| 46 // removed. |
| 47 void SetHeaders(const std::string& headers); |
| 45 | 48 |
| 46 // Restores the byte-range header that was removed during Init(), by appending | 49 // Restores the byte-range header that was removed during Init(), by appending |
| 47 // the data to the provided |headers|. | 50 // the data to the provided |headers|. |
| 48 void RestoreHeaders(std::string* headers) const; | 51 void RestoreHeaders(std::string* headers) const; |
| 49 | 52 |
| 50 // Builds the required |headers| to perform the proper cache validation for | 53 // Builds the required |headers| to perform the proper cache validation for |
| 51 // the next range to be fetched. Returns 0 when there is no need to perform | 54 // the next range to be fetched. Returns 0 when there is no need to perform |
| 52 // more operations because we reached the end of the request (so 0 bytes | 55 // more operations because we reached the end of the request (so 0 bytes |
| 53 // should be actually returned to the user), a positive number to indicate | 56 // should be actually returned to the user), a positive number to indicate |
| 54 // that |headers| should be used to validate the cache, or an appropriate | 57 // that |headers| should be used to validate the cache, or an appropriate |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 bool final_range_; | 117 bool final_range_; |
| 115 bool sparse_entry_; | 118 bool sparse_entry_; |
| 116 bool truncated_; // We have an incomplete 200 stored. | 119 bool truncated_; // We have an incomplete 200 stored. |
| 117 | 120 |
| 118 DISALLOW_COPY_AND_ASSIGN(PartialData); | 121 DISALLOW_COPY_AND_ASSIGN(PartialData); |
| 119 }; | 122 }; |
| 120 | 123 |
| 121 } // namespace net | 124 } // namespace net |
| 122 | 125 |
| 123 #endif // NET_HTTP_PARTIAL_DATA_H_ | 126 #endif // NET_HTTP_PARTIAL_DATA_H_ |
| OLD | NEW |