diff options
Diffstat (limited to 'net/http/http_cache_transaction.cc')
-rw-r--r-- | net/http/http_cache_transaction.cc | 68 |
1 files changed, 36 insertions, 32 deletions
diff --git a/net/http/http_cache_transaction.cc b/net/http/http_cache_transaction.cc index 82b3078..3a23682 100644 --- a/net/http/http_cache_transaction.cc +++ b/net/http/http_cache_transaction.cc @@ -360,7 +360,7 @@ int HttpCache::Transaction::RestartWithCertificate( int HttpCache::Transaction::RestartWithAuth( const AuthCredentials& credentials, const CompletionCallback& callback) { - DCHECK(auth_response_.headers); + DCHECK(auth_response_.headers.get()); DCHECK(!callback.is_null()); // Ensure that we only have one asynchronous call at a time. @@ -400,7 +400,7 @@ int HttpCache::Transaction::Read(IOBuffer* buf, int buf_len, // If we have an intermediate auth response at this point, then it means the // user wishes to read the network response (the error page). If there is a // previous response in the cache then we should leave it intact. - if (auth_response_.headers && mode_ != NONE) { + if (auth_response_.headers.get() && mode_ != NONE) { UpdateTransactionPattern(PATTERN_NOT_COVERED); DCHECK(mode_ & WRITE); DoneWritingToEntry(mode_ == READ_WRITE); @@ -464,10 +464,12 @@ void HttpCache::Transaction::DoneReading() { const HttpResponseInfo* HttpCache::Transaction::GetResponseInfo() const { // Null headers means we encountered an error or haven't a response yet - if (auth_response_.headers) + if (auth_response_.headers.get()) return &auth_response_; - return (response_.headers || response_.ssl_info.cert || - response_.cert_request_info) ? &response_ : NULL; + return (response_.headers.get() || response_.ssl_info.cert.get() || + response_.cert_request_info.get()) + ? &response_ + : NULL; } LoadState HttpCache::Transaction::GetLoadState() const { @@ -918,7 +920,7 @@ int HttpCache::Transaction::DoSuccessfulSendRequest() { } new_response_ = new_response; - if (!ValidatePartialResponse() && !auth_response_.headers) { + if (!ValidatePartialResponse() && !auth_response_.headers.get()) { // Something went wrong with this request and we have to restart it. // If we have an authentication response, we are exposed to weird things // hapenning if the user cancels the authentication before we receive @@ -982,7 +984,7 @@ int HttpCache::Transaction::DoSuccessfulSendRequest() { int HttpCache::Transaction::DoNetworkRead() { ReportNetworkActionStart(); next_state_ = STATE_NETWORK_READ_COMPLETE; - return network_trans_->Read(read_buf_, io_buf_len_, io_callback_); + return network_trans_->Read(read_buf_.get(), io_buf_len_, io_callback_); } int HttpCache::Transaction::DoNetworkReadComplete(int result) { @@ -1238,7 +1240,7 @@ int HttpCache::Transaction::DoUpdateCachedResponse() { int rv = OK; // Update cached response based on headers in new_response. // TODO(wtc): should we update cached certificate (response_.ssl_info), too? - response_.headers->Update(*new_response_->headers); + response_.headers->Update(*new_response_->headers.get()); response_.response_time = new_response_->response_time; response_.request_time = new_response_->request_time; response_.network_accessed = new_response_->network_accessed; @@ -1301,7 +1303,7 @@ int HttpCache::Transaction::DoOverwriteCachedResponse() { // We change the value of Content-Length for partial content. if (handling_206_ && partial_.get()) - partial_->FixContentLength(new_response_->headers); + partial_->FixContentLength(new_response_->headers.get()); response_ = *new_response_; @@ -1309,7 +1311,7 @@ int HttpCache::Transaction::DoOverwriteCachedResponse() { // There is no point in storing this resource because it will never be used. DoneWritingToEntry(false); if (partial_.get()) - partial_->FixResponseHeaders(response_.headers, true); + partial_->FixResponseHeaders(response_.headers.get(), true); next_state_ = STATE_PARTIAL_HEADERS_RECEIVED; return OK; } @@ -1392,7 +1394,7 @@ int HttpCache::Transaction::DoPartialHeadersReceived() { } else if (mode_ != NONE) { // We are about to return the headers for a byte-range request to the user, // so let's fix them. - partial_->FixResponseHeaders(response_.headers, true); + partial_->FixResponseHeaders(response_.headers.get(), true); } return OK; } @@ -1406,9 +1408,8 @@ int HttpCache::Transaction::DoCacheReadResponse() { net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_READ_INFO); ReportCacheActionStart(); - return ResetCacheIOStart( - entry_->disk_entry->ReadData(kResponseInfoIndex, 0, read_buf_, - io_buf_len_, io_callback_)); + return ResetCacheIOStart(entry_->disk_entry->ReadData( + kResponseInfoIndex, 0, read_buf_.get(), io_buf_len_, io_callback_)); } int HttpCache::Transaction::DoCacheReadResponseComplete(int result) { @@ -1496,7 +1497,7 @@ int HttpCache::Transaction::DoCacheWriteResponseComplete(int result) { int HttpCache::Transaction::DoCacheReadMetadata() { DCHECK(entry_); - DCHECK(!response_.metadata); + DCHECK(!response_.metadata.get()); next_state_ = STATE_CACHE_READ_METADATA_COMPLETE; response_.metadata = @@ -1505,7 +1506,9 @@ int HttpCache::Transaction::DoCacheReadMetadata() { net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_READ_INFO); ReportCacheActionStart(); return ResetCacheIOStart( - entry_->disk_entry->ReadData(kMetadataIndex, 0, response_.metadata, + entry_->disk_entry->ReadData(kMetadataIndex, + 0, + response_.metadata.get(), response_.metadata->size(), io_callback_)); } @@ -1542,14 +1545,15 @@ int HttpCache::Transaction::DoCacheReadData() { net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_READ_DATA); ReportCacheActionStart(); if (partial_.get()) { - return ResetCacheIOStart( - partial_->CacheRead(entry_->disk_entry, read_buf_, io_buf_len_, - io_callback_)); + return ResetCacheIOStart(partial_->CacheRead( + entry_->disk_entry, read_buf_.get(), io_buf_len_, io_callback_)); } - return ResetCacheIOStart( - entry_->disk_entry->ReadData(kResponseContentIndex, read_offset_, - read_buf_, io_buf_len_, io_callback_)); + return ResetCacheIOStart(entry_->disk_entry->ReadData(kResponseContentIndex, + read_offset_, + read_buf_.get(), + io_buf_len_, + io_callback_)); } int HttpCache::Transaction::DoCacheReadDataComplete(int result) { @@ -1591,7 +1595,7 @@ int HttpCache::Transaction::DoCacheWriteData(int num_bytes) { } return ResetCacheIOStart( - AppendResponseDataToEntry(read_buf_, num_bytes, io_callback_)); + AppendResponseDataToEntry(read_buf_.get(), num_bytes, io_callback_)); } int HttpCache::Transaction::DoCacheWriteDataComplete(int result) { @@ -1867,8 +1871,8 @@ int HttpCache::Transaction::BeginPartialCacheValidation() { int HttpCache::Transaction::ValidateEntryHeadersAndContinue() { DCHECK(mode_ == READ_WRITE); - if (!partial_->UpdateFromStoredHeaders(response_.headers, entry_->disk_entry, - truncated_)) { + if (!partial_->UpdateFromStoredHeaders( + response_.headers.get(), entry_->disk_entry, truncated_)) { return DoRestartPartialRequest(); } @@ -1962,7 +1966,8 @@ bool HttpCache::Transaction::RequiresValidation() { return false; if (response_.vary_data.is_valid() && - !response_.vary_data.MatchesRequest(*request_, *response_.headers)) { + !response_.vary_data.MatchesRequest(*request_, + *response_.headers.get())) { vary_mismatch_ = true; return true; } @@ -1985,7 +1990,7 @@ bool HttpCache::Transaction::RequiresValidation() { } bool HttpCache::Transaction::ConditionalizeRequest() { - DCHECK(response_.headers); + DCHECK(response_.headers.get()); if (request_->method == "PUT" || request_->method == "DELETE") return false; @@ -2074,7 +2079,7 @@ bool HttpCache::Transaction::ConditionalizeRequest() { // time it is called it will return true so that we don't keep retrying the // request. bool HttpCache::Transaction::ValidatePartialResponse() { - const HttpResponseHeaders* headers = new_response_->headers; + const HttpResponseHeaders* headers = new_response_->headers.get(); int response_code = headers->response_code(); bool partial_response = (response_code == 206); handling_206_ = false; @@ -2184,7 +2189,7 @@ void HttpCache::Transaction::IgnoreRangeRequest() { void HttpCache::Transaction::FailRangeRequest() { response_ = *new_response_; - partial_->FixResponseHeaders(response_.headers, false); + partial_->FixResponseHeaders(response_.headers.get(), false); } int HttpCache::Transaction::SetupEntryForRead() { @@ -2275,9 +2280,8 @@ int HttpCache::Transaction::WriteResponseInfoToEntry(bool truncated) { data->Done(); io_buf_len_ = data->pickle()->size(); - return ResetCacheIOStart( - entry_->disk_entry->WriteData(kResponseInfoIndex, 0, data, - io_buf_len_, io_callback_, true)); + return ResetCacheIOStart(entry_->disk_entry->WriteData( + kResponseInfoIndex, 0, data.get(), io_buf_len_, io_callback_, true)); } int HttpCache::Transaction::AppendResponseDataToEntry( |