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

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

Issue 2886483002: Adds a new class HttpCache::Writers for multiple cache transactions reading from the network. (Closed)
Patch Set: Comment changed. Created 3 years, 5 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
« no previous file with comments | « net/http/http_cache_transaction.h ('k') | net/http/http_cache_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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" // For OS_POSIX 7 #include "build/build_config.h" // For OS_POSIX
8 8
9 #if defined(OS_POSIX) 9 #if defined(OS_POSIX)
10 #include <unistd.h> 10 #include <unistd.h>
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 573
574 next_state_ = STATE_HEADERS_PHASE_CANNOT_PROCEED; 574 next_state_ = STATE_HEADERS_PHASE_CANNOT_PROCEED;
575 entry_ = nullptr; 575 entry_ = nullptr;
576 } 576 }
577 577
578 size_t HttpCache::Transaction::EstimateMemoryUsage() const { 578 size_t HttpCache::Transaction::EstimateMemoryUsage() const {
579 // TODO(xunjieli): Consider improving the coverage. crbug.com/669108. 579 // TODO(xunjieli): Consider improving the coverage. crbug.com/669108.
580 return 0; 580 return 0;
581 } 581 }
582 582
583 void HttpCache::Transaction::SetSharedWritingFailState(int result) {
584 // TODO(shivanisha): Implement when integrating with HttpCache::Writers.
585 NOTIMPLEMENTED();
586 }
587
583 //----------------------------------------------------------------------------- 588 //-----------------------------------------------------------------------------
584 589
585 // A few common patterns: (Foo* means Foo -> FooComplete) 590 // A few common patterns: (Foo* means Foo -> FooComplete)
586 // 591 //
587 // 1. Not-cached entry: 592 // 1. Not-cached entry:
588 // Start(): 593 // Start():
589 // GetBackend* -> InitEntry -> OpenEntry* -> CreateEntry* -> AddToEntry* -> 594 // GetBackend* -> InitEntry -> OpenEntry* -> CreateEntry* -> AddToEntry* ->
590 // SendRequest* -> SuccessfulSendRequest -> OverwriteCachedResponse -> 595 // SendRequest* -> SuccessfulSendRequest -> OverwriteCachedResponse ->
591 // CacheWriteResponse* -> TruncateCachedData* -> TruncateCachedMetadata* -> 596 // CacheWriteResponse* -> TruncateCachedData* -> TruncateCachedMetadata* ->
592 // PartialHeadersReceived -> FinishHeaders* 597 // PartialHeadersReceived -> FinishHeaders*
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
1148 TRACE_EVENT0("io", "HttpCacheTransaction::DoAddToEntry"); 1153 TRACE_EVENT0("io", "HttpCacheTransaction::DoAddToEntry");
1149 DCHECK(new_entry_); 1154 DCHECK(new_entry_);
1150 cache_pending_ = true; 1155 cache_pending_ = true;
1151 net_log_.BeginEvent(NetLogEventType::HTTP_CACHE_ADD_TO_ENTRY); 1156 net_log_.BeginEvent(NetLogEventType::HTTP_CACHE_ADD_TO_ENTRY);
1152 DCHECK(entry_lock_waiting_since_.is_null()); 1157 DCHECK(entry_lock_waiting_since_.is_null());
1153 int rv = cache_->AddTransactionToEntry(new_entry_, this); 1158 int rv = cache_->AddTransactionToEntry(new_entry_, this);
1154 DCHECK_EQ(rv, ERR_IO_PENDING); 1159 DCHECK_EQ(rv, ERR_IO_PENDING);
1155 1160
1156 // If headers phase is already done then we are here because of validation not 1161 // If headers phase is already done then we are here because of validation not
1157 // matching and creating a new entry. This transaction should be the 1162 // matching and creating a new entry. This transaction should be the
1158 // first transaction of that new entry and thus it should not be subject 1163 // first transaction of that new entry and thus it will not have cache lock
1159 // to any cache lock delays, thus returning early from here. 1164 // delays, thus returning early from here.
1160 if (done_headers_create_new_entry_) { 1165 if (done_headers_create_new_entry_) {
1161 DCHECK_EQ(mode_, WRITE); 1166 DCHECK_EQ(mode_, WRITE);
1162 TransitionToState(STATE_DONE_HEADERS_ADD_TO_ENTRY_COMPLETE); 1167 TransitionToState(STATE_DONE_HEADERS_ADD_TO_ENTRY_COMPLETE);
1163 return rv; 1168 return rv;
1164 } 1169 }
1165 1170
1166 TransitionToState(STATE_ADD_TO_ENTRY_COMPLETE); 1171 TransitionToState(STATE_ADD_TO_ENTRY_COMPLETE);
1167 1172
1168 entry_lock_waiting_since_ = TimeTicks::Now(); 1173 entry_lock_waiting_since_ = TimeTicks::Now();
1169 AddCacheLockTimeoutHandler(new_entry_); 1174 AddCacheLockTimeoutHandler(new_entry_);
(...skipping 2049 matching lines...) Expand 10 before | Expand all | Expand 10 after
3219 } 3224 }
3220 3225
3221 void HttpCache::Transaction::TransitionToState(State state) { 3226 void HttpCache::Transaction::TransitionToState(State state) {
3222 // Ensure that the state is only set once per Do* state. 3227 // Ensure that the state is only set once per Do* state.
3223 DCHECK(in_do_loop_); 3228 DCHECK(in_do_loop_);
3224 DCHECK_EQ(STATE_UNSET, next_state_) << "Next state is " << state; 3229 DCHECK_EQ(STATE_UNSET, next_state_) << "Next state is " << state;
3225 next_state_ = state; 3230 next_state_ = state;
3226 } 3231 }
3227 3232
3228 } // namespace net 3233 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_cache_transaction.h ('k') | net/http/http_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698