| 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 // This file declares HttpCache::Transaction, a private class of HttpCache so | 5 // This file declares HttpCache::Transaction, a private class of HttpCache so |
| 6 // it should only be included by http_cache.cc | 6 // it should only be included by http_cache.cc |
| 7 | 7 |
| 8 #ifndef NET_HTTP_HTTP_CACHE_TRANSACTION_H_ | 8 #ifndef NET_HTTP_HTTP_CACHE_TRANSACTION_H_ |
| 9 #define NET_HTTP_HTTP_CACHE_TRANSACTION_H_ | 9 #define NET_HTTP_HTTP_CACHE_TRANSACTION_H_ |
| 10 | 10 |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 | 184 |
| 185 // Returns the estimate of dynamically allocated memory in bytes. | 185 // Returns the estimate of dynamically allocated memory in bytes. |
| 186 size_t EstimateMemoryUsage() const; | 186 size_t EstimateMemoryUsage() const; |
| 187 | 187 |
| 188 // Sets fail state such that a future Read fails with |error_code|. | 188 // Sets fail state such that a future Read fails with |error_code|. |
| 189 void SetSharedWritingFailState(int error_code); | 189 void SetSharedWritingFailState(int error_code); |
| 190 | 190 |
| 191 RequestPriority priority() const { return priority_; } | 191 RequestPriority priority() const { return priority_; } |
| 192 PartialData* partial() { return partial_.get(); } | 192 PartialData* partial() { return partial_.get(); } |
| 193 | 193 |
| 194 // Returns true if the resource info MemoryEntryDataHints bit flags in |
| 195 // |in_memory_info| and the current request & load flags suggest that |
| 196 // the cache entry in question is not actually usable for HTTP |
| 197 // (i.e. already expired, and nothing is forcing us to disregard that). |
| 198 bool MaybeRejectBasedOnEntryInMemoryData(uint8_t in_memory_info); |
| 199 |
| 194 private: | 200 private: |
| 195 static const size_t kNumValidationHeaders = 2; | 201 static const size_t kNumValidationHeaders = 2; |
| 196 // Helper struct to pair a header name with its value, for | 202 // Helper struct to pair a header name with its value, for |
| 197 // headers used to validate cache entries. | 203 // headers used to validate cache entries. |
| 198 struct ValidationHeaders { | 204 struct ValidationHeaders { |
| 199 ValidationHeaders() : initialized(false) {} | 205 ValidationHeaders() : initialized(false) {} |
| 200 | 206 |
| 201 std::string values[kNumValidationHeaders]; | 207 std::string values[kNumValidationHeaders]; |
| 202 void Reset() { | 208 void Reset() { |
| 203 initialized = false; | 209 initialized = false; |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 // Returns network error code. | 385 // Returns network error code. |
| 380 int RestartNetworkRequestWithAuth(const AuthCredentials& credentials); | 386 int RestartNetworkRequestWithAuth(const AuthCredentials& credentials); |
| 381 | 387 |
| 382 // Called to determine if we need to validate the cache entry before using it. | 388 // Called to determine if we need to validate the cache entry before using it. |
| 383 bool RequiresValidation(); | 389 bool RequiresValidation(); |
| 384 | 390 |
| 385 // Called to make the request conditional (to ask the server if the cached | 391 // Called to make the request conditional (to ask the server if the cached |
| 386 // copy is valid). Returns true if able to make the request conditional. | 392 // copy is valid). Returns true if able to make the request conditional. |
| 387 bool ConditionalizeRequest(); | 393 bool ConditionalizeRequest(); |
| 388 | 394 |
| 395 // Determines if saved response permits conditionalization, and extracts |
| 396 // etag/last-modified values. Only depends on response_.headers. |
| 397 bool ResponseConditionalizable(std::string* etag_value, |
| 398 std::string* last_modified_value); |
| 399 |
| 389 // Makes sure that a 206 response is expected. Returns true on success. | 400 // Makes sure that a 206 response is expected. Returns true on success. |
| 390 // On success, handling_206_ will be set to true if we are processing a | 401 // On success, handling_206_ will be set to true if we are processing a |
| 391 // partial entry. | 402 // partial entry. |
| 392 bool ValidatePartialResponse(); | 403 bool ValidatePartialResponse(); |
| 393 | 404 |
| 394 // Handles a response validation error by bypassing the cache. | 405 // Handles a response validation error by bypassing the cache. |
| 395 void IgnoreRangeRequest(); | 406 void IgnoreRangeRequest(); |
| 396 | 407 |
| 397 // Fixes the response headers to match expectations for a HEAD request. | 408 // Fixes the response headers to match expectations for a HEAD request. |
| 398 void FixHeadersForHead(); | 409 void FixHeadersForHead(); |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 bool in_do_loop_; | 587 bool in_do_loop_; |
| 577 | 588 |
| 578 base::WeakPtrFactory<Transaction> weak_factory_; | 589 base::WeakPtrFactory<Transaction> weak_factory_; |
| 579 | 590 |
| 580 DISALLOW_COPY_AND_ASSIGN(Transaction); | 591 DISALLOW_COPY_AND_ASSIGN(Transaction); |
| 581 }; | 592 }; |
| 582 | 593 |
| 583 } // namespace net | 594 } // namespace net |
| 584 | 595 |
| 585 #endif // NET_HTTP_HTTP_CACHE_TRANSACTION_H_ | 596 #endif // NET_HTTP_HTTP_CACHE_TRANSACTION_H_ |
| OLD | NEW |