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

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

Issue 1122483004: Remove NetLog::GetCaptureMode() and NetLogCaptureMode::None() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mmenke_refactor
Patch Set: second attempt at fixing int --> bool warning on windows Created 5 years, 7 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
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" 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 1571 matching lines...) Expand 10 before | Expand all | Expand 10 after
1582 target_state_ = STATE_TRUNCATE_CACHED_DATA; 1582 target_state_ = STATE_TRUNCATE_CACHED_DATA;
1583 next_state_ = truncated_ ? STATE_CACHE_WRITE_TRUNCATED_RESPONSE : 1583 next_state_ = truncated_ ? STATE_CACHE_WRITE_TRUNCATED_RESPONSE :
1584 STATE_CACHE_WRITE_RESPONSE; 1584 STATE_CACHE_WRITE_RESPONSE;
1585 return OK; 1585 return OK;
1586 } 1586 }
1587 1587
1588 int HttpCache::Transaction::DoTruncateCachedData() { 1588 int HttpCache::Transaction::DoTruncateCachedData() {
1589 next_state_ = STATE_TRUNCATE_CACHED_DATA_COMPLETE; 1589 next_state_ = STATE_TRUNCATE_CACHED_DATA_COMPLETE;
1590 if (!entry_) 1590 if (!entry_)
1591 return OK; 1591 return OK;
1592 if (net_log_.GetCaptureMode().enabled()) 1592 if (net_log_.IsCapturing())
1593 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WRITE_DATA); 1593 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WRITE_DATA);
1594 // Truncate the stream. 1594 // Truncate the stream.
1595 return WriteToEntry(kResponseContentIndex, 0, NULL, 0, io_callback_); 1595 return WriteToEntry(kResponseContentIndex, 0, NULL, 0, io_callback_);
1596 } 1596 }
1597 1597
1598 int HttpCache::Transaction::DoTruncateCachedDataComplete(int result) { 1598 int HttpCache::Transaction::DoTruncateCachedDataComplete(int result) {
1599 if (entry_) { 1599 if (entry_) {
1600 if (net_log_.GetCaptureMode().enabled()) { 1600 if (net_log_.IsCapturing()) {
1601 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_WRITE_DATA, 1601 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_WRITE_DATA,
1602 result); 1602 result);
1603 } 1603 }
1604 } 1604 }
1605 1605
1606 next_state_ = STATE_TRUNCATE_CACHED_METADATA; 1606 next_state_ = STATE_TRUNCATE_CACHED_METADATA;
1607 return OK; 1607 return OK;
1608 } 1608 }
1609 1609
1610 int HttpCache::Transaction::DoTruncateCachedMetadata() { 1610 int HttpCache::Transaction::DoTruncateCachedMetadata() {
1611 next_state_ = STATE_TRUNCATE_CACHED_METADATA_COMPLETE; 1611 next_state_ = STATE_TRUNCATE_CACHED_METADATA_COMPLETE;
1612 if (!entry_) 1612 if (!entry_)
1613 return OK; 1613 return OK;
1614 1614
1615 if (net_log_.GetCaptureMode().enabled()) 1615 if (net_log_.IsCapturing())
1616 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WRITE_INFO); 1616 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WRITE_INFO);
1617 return WriteToEntry(kMetadataIndex, 0, NULL, 0, io_callback_); 1617 return WriteToEntry(kMetadataIndex, 0, NULL, 0, io_callback_);
1618 } 1618 }
1619 1619
1620 int HttpCache::Transaction::DoTruncateCachedMetadataComplete(int result) { 1620 int HttpCache::Transaction::DoTruncateCachedMetadataComplete(int result) {
1621 if (entry_) { 1621 if (entry_) {
1622 if (net_log_.GetCaptureMode().enabled()) { 1622 if (net_log_.IsCapturing()) {
1623 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_WRITE_INFO, 1623 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_WRITE_INFO,
1624 result); 1624 result);
1625 } 1625 }
1626 } 1626 }
1627 1627
1628 next_state_ = STATE_PARTIAL_HEADERS_RECEIVED; 1628 next_state_ = STATE_PARTIAL_HEADERS_RECEIVED;
1629 return OK; 1629 return OK;
1630 } 1630 }
1631 1631
1632 int HttpCache::Transaction::DoPartialHeadersReceived() { 1632 int HttpCache::Transaction::DoPartialHeadersReceived() {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1749 return OK; 1749 return OK;
1750 } 1750 }
1751 1751
1752 int HttpCache::Transaction::DoCacheWriteResponse() { 1752 int HttpCache::Transaction::DoCacheWriteResponse() {
1753 // TODO(rtenneti): Remove ScopedTracker below once crbug.com/422516 is fixed. 1753 // TODO(rtenneti): Remove ScopedTracker below once crbug.com/422516 is fixed.
1754 tracked_objects::ScopedTracker tracking_profile( 1754 tracked_objects::ScopedTracker tracking_profile(
1755 FROM_HERE_WITH_EXPLICIT_FUNCTION( 1755 FROM_HERE_WITH_EXPLICIT_FUNCTION(
1756 "422516 HttpCache::Transaction::DoCacheWriteResponse")); 1756 "422516 HttpCache::Transaction::DoCacheWriteResponse"));
1757 1757
1758 if (entry_) { 1758 if (entry_) {
1759 if (net_log_.GetCaptureMode().enabled()) 1759 if (net_log_.IsCapturing())
1760 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WRITE_INFO); 1760 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WRITE_INFO);
1761 } 1761 }
1762 return WriteResponseInfoToEntry(false); 1762 return WriteResponseInfoToEntry(false);
1763 } 1763 }
1764 1764
1765 int HttpCache::Transaction::DoCacheWriteTruncatedResponse() { 1765 int HttpCache::Transaction::DoCacheWriteTruncatedResponse() {
1766 if (entry_) { 1766 if (entry_) {
1767 if (net_log_.GetCaptureMode().enabled()) 1767 if (net_log_.IsCapturing())
1768 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WRITE_INFO); 1768 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WRITE_INFO);
1769 } 1769 }
1770 return WriteResponseInfoToEntry(true); 1770 return WriteResponseInfoToEntry(true);
1771 } 1771 }
1772 1772
1773 int HttpCache::Transaction::DoCacheWriteResponseComplete(int result) { 1773 int HttpCache::Transaction::DoCacheWriteResponseComplete(int result) {
1774 next_state_ = target_state_; 1774 next_state_ = target_state_;
1775 target_state_ = STATE_NONE; 1775 target_state_ = STATE_NONE;
1776 if (!entry_) 1776 if (!entry_)
1777 return OK; 1777 return OK;
1778 if (net_log_.GetCaptureMode().enabled()) { 1778 if (net_log_.IsCapturing()) {
1779 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_WRITE_INFO, 1779 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_WRITE_INFO,
1780 result); 1780 result);
1781 } 1781 }
1782 1782
1783 // Balance the AddRef from WriteResponseInfoToEntry. 1783 // Balance the AddRef from WriteResponseInfoToEntry.
1784 if (result != io_buf_len_) { 1784 if (result != io_buf_len_) {
1785 DLOG(ERROR) << "failed to write response info to cache"; 1785 DLOG(ERROR) << "failed to write response info to cache";
1786 DoneWritingToEntry(false); 1786 DoneWritingToEntry(false);
1787 } 1787 }
1788 return OK; 1788 return OK;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1820 if (!cache_.get()) 1820 if (!cache_.get())
1821 return ERR_UNEXPECTED; 1821 return ERR_UNEXPECTED;
1822 1822
1823 return ValidateEntryHeadersAndContinue(); 1823 return ValidateEntryHeadersAndContinue();
1824 } 1824 }
1825 1825
1826 int HttpCache::Transaction::DoCacheReadData() { 1826 int HttpCache::Transaction::DoCacheReadData() {
1827 DCHECK(entry_); 1827 DCHECK(entry_);
1828 next_state_ = STATE_CACHE_READ_DATA_COMPLETE; 1828 next_state_ = STATE_CACHE_READ_DATA_COMPLETE;
1829 1829
1830 if (net_log_.GetCaptureMode().enabled()) 1830 if (net_log_.IsCapturing())
1831 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_READ_DATA); 1831 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_READ_DATA);
1832 if (partial_.get()) { 1832 if (partial_.get()) {
1833 return partial_->CacheRead(entry_->disk_entry, read_buf_.get(), io_buf_len_, 1833 return partial_->CacheRead(entry_->disk_entry, read_buf_.get(), io_buf_len_,
1834 io_callback_); 1834 io_callback_);
1835 } 1835 }
1836 1836
1837 return entry_->disk_entry->ReadData(kResponseContentIndex, read_offset_, 1837 return entry_->disk_entry->ReadData(kResponseContentIndex, read_offset_,
1838 read_buf_.get(), io_buf_len_, 1838 read_buf_.get(), io_buf_len_,
1839 io_callback_); 1839 io_callback_);
1840 } 1840 }
1841 1841
1842 int HttpCache::Transaction::DoCacheReadDataComplete(int result) { 1842 int HttpCache::Transaction::DoCacheReadDataComplete(int result) {
1843 if (net_log_.GetCaptureMode().enabled()) { 1843 if (net_log_.IsCapturing()) {
1844 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_READ_DATA, 1844 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_READ_DATA,
1845 result); 1845 result);
1846 } 1846 }
1847 1847
1848 if (!cache_.get()) 1848 if (!cache_.get())
1849 return ERR_UNEXPECTED; 1849 return ERR_UNEXPECTED;
1850 1850
1851 if (partial_.get()) { 1851 if (partial_.get()) {
1852 // Partial requests are confusing to report in histograms because they may 1852 // Partial requests are confusing to report in histograms because they may
1853 // have multiple underlying requests. 1853 // have multiple underlying requests.
(...skipping 10 matching lines...) Expand all
1864 } else { 1864 } else {
1865 return OnCacheReadError(result, false); 1865 return OnCacheReadError(result, false);
1866 } 1866 }
1867 return result; 1867 return result;
1868 } 1868 }
1869 1869
1870 int HttpCache::Transaction::DoCacheWriteData(int num_bytes) { 1870 int HttpCache::Transaction::DoCacheWriteData(int num_bytes) {
1871 next_state_ = STATE_CACHE_WRITE_DATA_COMPLETE; 1871 next_state_ = STATE_CACHE_WRITE_DATA_COMPLETE;
1872 write_len_ = num_bytes; 1872 write_len_ = num_bytes;
1873 if (entry_) { 1873 if (entry_) {
1874 if (net_log_.GetCaptureMode().enabled()) 1874 if (net_log_.IsCapturing())
1875 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WRITE_DATA); 1875 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WRITE_DATA);
1876 } 1876 }
1877 1877
1878 return AppendResponseDataToEntry(read_buf_.get(), num_bytes, io_callback_); 1878 return AppendResponseDataToEntry(read_buf_.get(), num_bytes, io_callback_);
1879 } 1879 }
1880 1880
1881 int HttpCache::Transaction::DoCacheWriteDataComplete(int result) { 1881 int HttpCache::Transaction::DoCacheWriteDataComplete(int result) {
1882 if (entry_) { 1882 if (entry_) {
1883 if (net_log_.GetCaptureMode().enabled()) { 1883 if (net_log_.IsCapturing()) {
1884 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_WRITE_DATA, 1884 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_WRITE_DATA,
1885 result); 1885 result);
1886 } 1886 }
1887 } 1887 }
1888 // Balance the AddRef from DoCacheWriteData. 1888 // Balance the AddRef from DoCacheWriteData.
1889 if (!cache_.get()) 1889 if (!cache_.get())
1890 return ERR_UNEXPECTED; 1890 return ERR_UNEXPECTED;
1891 1891
1892 if (result != write_len_) { 1892 if (result != write_len_) {
1893 DLOG(ERROR) << "failed to write response data to cache"; 1893 DLOG(ERROR) << "failed to write response data to cache";
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after
2694 // resource from the cache. When we load a page over HTTPS with a cert error 2694 // resource from the cache. When we load a page over HTTPS with a cert error
2695 // we show an SSL blocking page. If the user clicks proceed we reload the 2695 // we show an SSL blocking page. If the user clicks proceed we reload the
2696 // resource ignoring the errors. The loaded resource is then cached. If that 2696 // resource ignoring the errors. The loaded resource is then cached. If that
2697 // resource is subsequently loaded from the cache, no net error is reported 2697 // resource is subsequently loaded from the cache, no net error is reported
2698 // (even though the cert status contains the actual errors) and no SSL 2698 // (even though the cert status contains the actual errors) and no SSL
2699 // blocking page is shown. An alternative would be to reverse-map the cert 2699 // blocking page is shown. An alternative would be to reverse-map the cert
2700 // status to a net error and replay the net error. 2700 // status to a net error and replay the net error.
2701 if ((response_.headers->HasHeaderValue("cache-control", "no-store")) || 2701 if ((response_.headers->HasHeaderValue("cache-control", "no-store")) ||
2702 IsCertStatusError(response_.ssl_info.cert_status)) { 2702 IsCertStatusError(response_.ssl_info.cert_status)) {
2703 DoneWritingToEntry(false); 2703 DoneWritingToEntry(false);
2704 if (net_log_.GetCaptureMode().enabled()) 2704 if (net_log_.IsCapturing())
2705 net_log_.EndEvent(NetLog::TYPE_HTTP_CACHE_WRITE_INFO); 2705 net_log_.EndEvent(NetLog::TYPE_HTTP_CACHE_WRITE_INFO);
2706 return OK; 2706 return OK;
2707 } 2707 }
2708 2708
2709 // cert_cache() will be null if the CertCacheTrial field trial is disabled. 2709 // cert_cache() will be null if the CertCacheTrial field trial is disabled.
2710 if (cache_->cert_cache() && response_.ssl_info.is_valid()) 2710 if (cache_->cert_cache() && response_.ssl_info.is_valid())
2711 WriteCertChain(); 2711 WriteCertChain();
2712 2712
2713 if (truncated) 2713 if (truncated)
2714 DCHECK_EQ(200, response_.headers->response_code()); 2714 DCHECK_EQ(200, response_.headers->response_code());
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
2979 default: 2979 default:
2980 NOTREACHED(); 2980 NOTREACHED();
2981 } 2981 }
2982 } 2982 }
2983 2983
2984 void HttpCache::Transaction::OnIOComplete(int result) { 2984 void HttpCache::Transaction::OnIOComplete(int result) {
2985 DoLoop(result); 2985 DoLoop(result);
2986 } 2986 }
2987 2987
2988 } // namespace net 2988 } // namespace net
OLDNEW
« no previous file with comments | « net/disk_cache/simple/simple_entry_impl.cc ('k') | net/http/http_network_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698