| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 | 8 |
| 9 #if defined(OS_POSIX) | 9 #if defined(OS_POSIX) |
| 10 #include <unistd.h> | 10 #include <unistd.h> |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 | 307 |
| 308 const HttpResponseInfo* HttpCache::Transaction::GetResponseInfo() const { | 308 const HttpResponseInfo* HttpCache::Transaction::GetResponseInfo() const { |
| 309 // Null headers means we encountered an error or haven't a response yet | 309 // Null headers means we encountered an error or haven't a response yet |
| 310 if (auth_response_.headers) | 310 if (auth_response_.headers) |
| 311 return &auth_response_; | 311 return &auth_response_; |
| 312 return (response_.headers || response_.ssl_info.cert || | 312 return (response_.headers || response_.ssl_info.cert || |
| 313 response_.cert_request_info) ? &response_ : NULL; | 313 response_.cert_request_info) ? &response_ : NULL; |
| 314 } | 314 } |
| 315 | 315 |
| 316 LoadState HttpCache::Transaction::GetLoadState() const { | 316 LoadState HttpCache::Transaction::GetLoadState() const { |
| 317 LoadState state = GetWriterLoadState(); | 317 if (network_trans_.get()) |
| 318 if (state != LOAD_STATE_WAITING_FOR_CACHE) | 318 return network_trans_->GetLoadState(); |
| 319 return state; | 319 if (entry_ || !request_) |
| 320 | 320 return LOAD_STATE_IDLE; |
| 321 if (cache_) | 321 return LOAD_STATE_WAITING_FOR_CACHE; |
| 322 return cache_->GetLoadStateForPendingTransaction(this); | |
| 323 | |
| 324 return LOAD_STATE_IDLE; | |
| 325 } | 322 } |
| 326 | 323 |
| 327 uint64 HttpCache::Transaction::GetUploadProgress() const { | 324 uint64 HttpCache::Transaction::GetUploadProgress() const { |
| 328 if (network_trans_.get()) | 325 if (network_trans_.get()) |
| 329 return network_trans_->GetUploadProgress(); | 326 return network_trans_->GetUploadProgress(); |
| 330 return final_upload_progress_; | 327 return final_upload_progress_; |
| 331 } | 328 } |
| 332 | 329 |
| 333 int HttpCache::Transaction::WriteMetadata(IOBuffer* buf, int buf_len, | 330 int HttpCache::Transaction::WriteMetadata(IOBuffer* buf, int buf_len, |
| 334 CompletionCallback* callback) { | 331 CompletionCallback* callback) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 362 !response_.headers->HasStrongValidators()) | 359 !response_.headers->HasStrongValidators()) |
| 363 return false; | 360 return false; |
| 364 | 361 |
| 365 truncated_ = true; | 362 truncated_ = true; |
| 366 target_state_ = STATE_NONE; | 363 target_state_ = STATE_NONE; |
| 367 next_state_ = STATE_CACHE_WRITE_TRUNCATED_RESPONSE; | 364 next_state_ = STATE_CACHE_WRITE_TRUNCATED_RESPONSE; |
| 368 DoLoop(OK); | 365 DoLoop(OK); |
| 369 return true; | 366 return true; |
| 370 } | 367 } |
| 371 | 368 |
| 372 LoadState HttpCache::Transaction::GetWriterLoadState() const { | |
| 373 if (network_trans_.get()) | |
| 374 return network_trans_->GetLoadState(); | |
| 375 if (entry_ || !request_) | |
| 376 return LOAD_STATE_IDLE; | |
| 377 return LOAD_STATE_WAITING_FOR_CACHE; | |
| 378 } | |
| 379 | |
| 380 //----------------------------------------------------------------------------- | 369 //----------------------------------------------------------------------------- |
| 381 | 370 |
| 382 void HttpCache::Transaction::DoCallback(int rv) { | 371 void HttpCache::Transaction::DoCallback(int rv) { |
| 383 DCHECK(rv != ERR_IO_PENDING); | 372 DCHECK(rv != ERR_IO_PENDING); |
| 384 DCHECK(callback_); | 373 DCHECK(callback_); |
| 385 | 374 |
| 386 // Since Run may result in Read being called, clear callback_ up front. | 375 // Since Run may result in Read being called, clear callback_ up front. |
| 387 CompletionCallback* c = callback_; | 376 CompletionCallback* c = callback_; |
| 388 callback_ = NULL; | 377 callback_ = NULL; |
| 389 c->Run(rv); | 378 c->Run(rv); |
| (...skipping 1480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1870 // |value| goes from 0 to 63. Actually, the max value should be 47 (0x2f) | 1859 // |value| goes from 0 to 63. Actually, the max value should be 47 (0x2f) |
| 1871 // but we'll see. | 1860 // but we'll see. |
| 1872 UMA_HISTOGRAM_ENUMERATION("HttpCache.ResponseHeaders", value, 65); | 1861 UMA_HISTOGRAM_ENUMERATION("HttpCache.ResponseHeaders", value, 65); |
| 1873 } | 1862 } |
| 1874 | 1863 |
| 1875 void HttpCache::Transaction::OnIOComplete(int result) { | 1864 void HttpCache::Transaction::OnIOComplete(int result) { |
| 1876 DoLoop(result); | 1865 DoLoop(result); |
| 1877 } | 1866 } |
| 1878 | 1867 |
| 1879 } // namespace net | 1868 } // namespace net |
| OLD | NEW |