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

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

Issue 7222027: Add checks for entry_. From coverity CID=8237 (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Add null and return checks Created 9 years, 6 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
« no previous file with comments | « no previous file | remoting/base/decompressor_zlib.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) 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 #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 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 if (mode_ == UPDATE) { 1023 if (mode_ == UPDATE) {
1024 DCHECK(!server_responded_206_); 1024 DCHECK(!server_responded_206_);
1025 // We got a "not modified" response and already updated the corresponding 1025 // We got a "not modified" response and already updated the corresponding
1026 // cache entry above. 1026 // cache entry above.
1027 // 1027 //
1028 // By closing the cached entry now, we make sure that the 304 rather than 1028 // By closing the cached entry now, we make sure that the 304 rather than
1029 // the cached 200 response, is what will be returned to the user. 1029 // the cached 200 response, is what will be returned to the user.
1030 DoneWritingToEntry(true); 1030 DoneWritingToEntry(true);
1031 } else if (entry_ && !server_responded_206_) { 1031 } else if (entry_ && !server_responded_206_) {
1032 DCHECK_EQ(READ_WRITE, mode_); 1032 DCHECK_EQ(READ_WRITE, mode_);
1033 if (!partial_.get() || partial_->IsLastRange()) { 1033 if (entry_ && !partial_.get() || partial_->IsLastRange()) {
rvargas (doing something else) 2011/06/23 19:00:27 entry_ is already considered at line 1031
Greg Billock 2011/06/23 20:13:25 Done.
1034 cache_->ConvertWriterToReader(entry_); 1034 cache_->ConvertWriterToReader(entry_);
1035 mode_ = READ; 1035 mode_ = READ;
1036 } 1036 }
1037 // We no longer need the network transaction, so destroy it. 1037 // We no longer need the network transaction, so destroy it.
1038 final_upload_progress_ = network_trans_->GetUploadProgress(); 1038 final_upload_progress_ = network_trans_->GetUploadProgress();
1039 network_trans_.reset(); 1039 network_trans_.reset();
1040 } else if (entry_ && server_responded_206_ && truncated_ && 1040 } else if (entry_ && server_responded_206_ && truncated_ &&
1041 partial_->initial_validation()) { 1041 partial_->initial_validation()) {
1042 // We just finished the validation of a truncated entry, and the server 1042 // We just finished the validation of a truncated entry, and the server
1043 // is willing to resume the operation. Now we go back and start serving 1043 // is willing to resume the operation. Now we go back and start serving
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
1506 if ((partial_.get() && !partial_->IsCurrentRangeCached()) || invalid_range_) 1506 if ((partial_.get() && !partial_->IsCurrentRangeCached()) || invalid_range_)
1507 skip_validation = false; 1507 skip_validation = false;
1508 1508
1509 if (skip_validation) { 1509 if (skip_validation) {
1510 if (partial_.get()) { 1510 if (partial_.get()) {
1511 // We are going to return the saved response headers to the caller, so 1511 // We are going to return the saved response headers to the caller, so
1512 // we may need to adjust them first. 1512 // we may need to adjust them first.
1513 next_state_ = STATE_PARTIAL_HEADERS_RECEIVED; 1513 next_state_ = STATE_PARTIAL_HEADERS_RECEIVED;
1514 return OK; 1514 return OK;
1515 } 1515 }
1516 cache_->ConvertWriterToReader(entry_); 1516 if (entry_) {
rvargas (doing something else) 2011/06/23 19:00:27 The state machine guarantees that there should be
Greg Billock 2011/06/23 20:13:25 Done. I'll mark this intentional in coverity.
1517 mode_ = READ; 1517 cache_->ConvertWriterToReader(entry_);
1518 mode_ = READ;
1519 }
1518 1520
1519 if (entry_ && entry_->disk_entry->GetDataSize(kMetadataIndex)) 1521 if (entry_ && entry_->disk_entry->GetDataSize(kMetadataIndex))
1520 next_state_ = STATE_CACHE_READ_METADATA; 1522 next_state_ = STATE_CACHE_READ_METADATA;
1521 } else { 1523 } else {
1522 // Make the network request conditional, to see if we may reuse our cached 1524 // Make the network request conditional, to see if we may reuse our cached
1523 // response. If we cannot do so, then we just resort to a normal fetch. 1525 // response. If we cannot do so, then we just resort to a normal fetch.
1524 // Our mode remains READ_WRITE for a conditional request. We'll switch to 1526 // Our mode remains READ_WRITE for a conditional request. We'll switch to
1525 // either READ or WRITE mode once we hear back from the server. 1527 // either READ or WRITE mode once we hear back from the server.
1526 if (!ConditionalizeRequest()) { 1528 if (!ConditionalizeRequest()) {
1527 DCHECK(!partial_.get()); 1529 DCHECK(!partial_.get());
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
2016 return false; 2018 return false;
2017 2019
2018 return true; 2020 return true;
2019 } 2021 }
2020 2022
2021 void HttpCache::Transaction::OnIOComplete(int result) { 2023 void HttpCache::Transaction::OnIOComplete(int result) {
2022 DoLoop(result); 2024 DoLoop(result);
2023 } 2025 }
2024 2026
2025 } // namespace net 2027 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | remoting/base/decompressor_zlib.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698