| OLD | NEW |
| 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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 vary_mismatch_(false), | 267 vary_mismatch_(false), |
| 268 couldnt_conditionalize_request_(false), | 268 couldnt_conditionalize_request_(false), |
| 269 bypass_lock_for_test_(false), | 269 bypass_lock_for_test_(false), |
| 270 fail_conditionalization_for_test_(false), | 270 fail_conditionalization_for_test_(false), |
| 271 io_buf_len_(0), | 271 io_buf_len_(0), |
| 272 read_offset_(0), | 272 read_offset_(0), |
| 273 effective_load_flags_(0), | 273 effective_load_flags_(0), |
| 274 write_len_(0), | 274 write_len_(0), |
| 275 transaction_pattern_(PATTERN_UNDEFINED), | 275 transaction_pattern_(PATTERN_UNDEFINED), |
| 276 total_received_bytes_(0), | 276 total_received_bytes_(0), |
| 277 total_sent_bytes_(0), |
| 277 websocket_handshake_stream_base_create_helper_(NULL), | 278 websocket_handshake_stream_base_create_helper_(NULL), |
| 278 weak_factory_(this) { | 279 weak_factory_(this) { |
| 279 static_assert(HttpCache::Transaction::kNumValidationHeaders == | 280 static_assert(HttpCache::Transaction::kNumValidationHeaders == |
| 280 arraysize(kValidationHeaders), | 281 arraysize(kValidationHeaders), |
| 281 "invalid number of validation headers"); | 282 "invalid number of validation headers"); |
| 282 | 283 |
| 283 io_callback_ = base::Bind(&Transaction::OnIOComplete, | 284 io_callback_ = base::Bind(&Transaction::OnIOComplete, |
| 284 weak_factory_.GetWeakPtr()); | 285 weak_factory_.GetWeakPtr()); |
| 285 } | 286 } |
| 286 | 287 |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 return false; | 522 return false; |
| 522 } | 523 } |
| 523 | 524 |
| 524 int64 HttpCache::Transaction::GetTotalReceivedBytes() const { | 525 int64 HttpCache::Transaction::GetTotalReceivedBytes() const { |
| 525 int64 total_received_bytes = total_received_bytes_; | 526 int64 total_received_bytes = total_received_bytes_; |
| 526 if (network_trans_) | 527 if (network_trans_) |
| 527 total_received_bytes += network_trans_->GetTotalReceivedBytes(); | 528 total_received_bytes += network_trans_->GetTotalReceivedBytes(); |
| 528 return total_received_bytes; | 529 return total_received_bytes; |
| 529 } | 530 } |
| 530 | 531 |
| 532 int64_t HttpCache::Transaction::GetTotalSentBytes() const { |
| 533 int64_t total_sent_bytes = total_sent_bytes_; |
| 534 if (network_trans_) |
| 535 total_sent_bytes += network_trans_->GetTotalSentBytes(); |
| 536 return total_sent_bytes; |
| 537 } |
| 538 |
| 531 void HttpCache::Transaction::DoneReading() { | 539 void HttpCache::Transaction::DoneReading() { |
| 532 if (cache_.get() && entry_) { | 540 if (cache_.get() && entry_) { |
| 533 DCHECK_NE(mode_, UPDATE); | 541 DCHECK_NE(mode_, UPDATE); |
| 534 if (mode_ & WRITE) { | 542 if (mode_ & WRITE) { |
| 535 DoneWritingToEntry(true); | 543 DoneWritingToEntry(true); |
| 536 } else if (mode_ & READ) { | 544 } else if (mode_ & READ) { |
| 537 // It is necessary to check mode_ & READ because it is possible | 545 // It is necessary to check mode_ & READ because it is possible |
| 538 // for mode_ to be NONE and entry_ non-NULL with a write entry | 546 // for mode_ to be NONE and entry_ non-NULL with a write entry |
| 539 // if StopCaching was called. | 547 // if StopCaching was called. |
| 540 cache_->DoneReadingFromEntry(entry_, this); | 548 cache_->DoneReadingFromEntry(entry_, this); |
| (...skipping 2253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2794 } | 2802 } |
| 2795 } | 2803 } |
| 2796 | 2804 |
| 2797 void HttpCache::Transaction::ResetNetworkTransaction() { | 2805 void HttpCache::Transaction::ResetNetworkTransaction() { |
| 2798 DCHECK(!old_network_trans_load_timing_); | 2806 DCHECK(!old_network_trans_load_timing_); |
| 2799 DCHECK(network_trans_); | 2807 DCHECK(network_trans_); |
| 2800 LoadTimingInfo load_timing; | 2808 LoadTimingInfo load_timing; |
| 2801 if (network_trans_->GetLoadTimingInfo(&load_timing)) | 2809 if (network_trans_->GetLoadTimingInfo(&load_timing)) |
| 2802 old_network_trans_load_timing_.reset(new LoadTimingInfo(load_timing)); | 2810 old_network_trans_load_timing_.reset(new LoadTimingInfo(load_timing)); |
| 2803 total_received_bytes_ += network_trans_->GetTotalReceivedBytes(); | 2811 total_received_bytes_ += network_trans_->GetTotalReceivedBytes(); |
| 2812 total_sent_bytes_ += network_trans_->GetTotalSentBytes(); |
| 2804 ConnectionAttempts attempts; | 2813 ConnectionAttempts attempts; |
| 2805 network_trans_->GetConnectionAttempts(&attempts); | 2814 network_trans_->GetConnectionAttempts(&attempts); |
| 2806 for (const auto& attempt : attempts) | 2815 for (const auto& attempt : attempts) |
| 2807 old_connection_attempts_.push_back(attempt); | 2816 old_connection_attempts_.push_back(attempt); |
| 2808 network_trans_.reset(); | 2817 network_trans_.reset(); |
| 2809 } | 2818 } |
| 2810 | 2819 |
| 2811 // Histogram data from the end of 2010 show the following distribution of | 2820 // Histogram data from the end of 2010 show the following distribution of |
| 2812 // response headers: | 2821 // response headers: |
| 2813 // | 2822 // |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2925 default: | 2934 default: |
| 2926 NOTREACHED(); | 2935 NOTREACHED(); |
| 2927 } | 2936 } |
| 2928 } | 2937 } |
| 2929 | 2938 |
| 2930 void HttpCache::Transaction::OnIOComplete(int result) { | 2939 void HttpCache::Transaction::OnIOComplete(int result) { |
| 2931 DoLoop(result); | 2940 DoLoop(result); |
| 2932 } | 2941 } |
| 2933 | 2942 |
| 2934 } // namespace net | 2943 } // namespace net |
| OLD | NEW |