Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(191)

Side by Side Diff: net/http/http_cache_transaction.cc

Issue 12886022: Implement offline mode behind a flag (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added tests. Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "net/http/http_cache_transaction.h" 5 #include "net/http/http_cache_transaction.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #if defined(OS_POSIX) 9 #if defined(OS_POSIX)
10 #include <unistd.h> 10 #include <unistd.h>
(...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 // If we have an authentication response, we are exposed to weird things 877 // If we have an authentication response, we are exposed to weird things
878 // hapenning if the user cancels the authentication before we receive 878 // hapenning if the user cancels the authentication before we receive
879 // the new response. 879 // the new response.
880 UpdateTransactionPattern(PATTERN_NOT_COVERED); 880 UpdateTransactionPattern(PATTERN_NOT_COVERED);
881 response_ = HttpResponseInfo(); 881 response_ = HttpResponseInfo();
882 network_trans_.reset(); 882 network_trans_.reset();
883 new_response_ = NULL; 883 new_response_ = NULL;
884 next_state_ = STATE_SEND_REQUEST; 884 next_state_ = STATE_SEND_REQUEST;
885 return OK; 885 return OK;
886 } 886 }
887
887 if (handling_206_ && mode_ == READ_WRITE && !truncated_ && !is_sparse_) { 888 if (handling_206_ && mode_ == READ_WRITE && !truncated_ && !is_sparse_) {
888 // We have stored the full entry, but it changed and the server is 889 // We have stored the full entry, but it changed and the server is
889 // sending a range. We have to delete the old entry. 890 // sending a range. We have to delete the old entry.
890 UpdateTransactionPattern(PATTERN_NOT_COVERED); 891 UpdateTransactionPattern(PATTERN_NOT_COVERED);
891 DoneWritingToEntry(false); 892 DoneWritingToEntry(false);
892 } 893 }
893 if (new_response_->headers->response_code() == 416 && 894 if (new_response_->headers->response_code() == 416 &&
894 (request_->method == "GET" || request_->method == "POST")) { 895 (request_->method == "GET" || request_->method == "POST")) {
895 DCHECK_EQ(NONE, mode_); 896 DCHECK_EQ(NONE, mode_);
896 response_ = *new_response_; 897 response_ = *new_response_;
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
1205 1206
1206 // We received 304 or 206 and we want to update the cached response headers. 1207 // We received 304 or 206 and we want to update the cached response headers.
1207 int HttpCache::Transaction::DoUpdateCachedResponse() { 1208 int HttpCache::Transaction::DoUpdateCachedResponse() {
1208 next_state_ = STATE_UPDATE_CACHED_RESPONSE_COMPLETE; 1209 next_state_ = STATE_UPDATE_CACHED_RESPONSE_COMPLETE;
1209 int rv = OK; 1210 int rv = OK;
1210 // Update cached response based on headers in new_response. 1211 // Update cached response based on headers in new_response.
1211 // TODO(wtc): should we update cached certificate (response_.ssl_info), too? 1212 // TODO(wtc): should we update cached certificate (response_.ssl_info), too?
1212 response_.headers->Update(*new_response_->headers); 1213 response_.headers->Update(*new_response_->headers);
1213 response_.response_time = new_response_->response_time; 1214 response_.response_time = new_response_->response_time;
1214 response_.request_time = new_response_->request_time; 1215 response_.request_time = new_response_->request_time;
1216 response_.network_accessed = new_response_->network_accessed;
1215 1217
1216 if (response_.headers->HasHeaderValue("cache-control", "no-store")) { 1218 if (response_.headers->HasHeaderValue("cache-control", "no-store")) {
1217 if (!entry_->doomed) { 1219 if (!entry_->doomed) {
1218 int ret = cache_->DoomEntry(cache_key_, NULL); 1220 int ret = cache_->DoomEntry(cache_key_, NULL);
1219 DCHECK_EQ(OK, ret); 1221 DCHECK_EQ(OK, ret);
1220 } 1222 }
1221 } else { 1223 } else {
1222 // If we are already reading, we already updated the headers for this 1224 // If we are already reading, we already updated the headers for this
1223 // request; doing it again will change Content-Length. 1225 // request; doing it again will change Content-Length.
1224 if (!reading_) { 1226 if (!reading_) {
(...skipping 1321 matching lines...) Expand 10 before | Expand all | Expand 10 after
2546 } 2548 }
2547 2549
2548 int HttpCache::Transaction::ResetCacheIOStart(int return_value) { 2550 int HttpCache::Transaction::ResetCacheIOStart(int return_value) {
2549 DCHECK(cache_io_start_.is_null()); 2551 DCHECK(cache_io_start_.is_null());
2550 if (return_value == ERR_IO_PENDING) 2552 if (return_value == ERR_IO_PENDING)
2551 cache_io_start_ = base::TimeTicks::Now(); 2553 cache_io_start_ = base::TimeTicks::Now();
2552 return return_value; 2554 return return_value;
2553 } 2555 }
2554 2556
2555 } // namespace net 2557 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698