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" | 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 1808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1819 | 1819 |
1820 void HttpCache::Transaction::ReadCertChain() { | 1820 void HttpCache::Transaction::ReadCertChain() { |
1821 std::string key = | 1821 std::string key = |
1822 GetCacheKeyForCert(response_.ssl_info.cert->os_cert_handle()); | 1822 GetCacheKeyForCert(response_.ssl_info.cert->os_cert_handle()); |
1823 const X509Certificate::OSCertHandles& intermediates = | 1823 const X509Certificate::OSCertHandles& intermediates = |
1824 response_.ssl_info.cert->GetIntermediateCertificates(); | 1824 response_.ssl_info.cert->GetIntermediateCertificates(); |
1825 int dist_from_root = intermediates.size(); | 1825 int dist_from_root = intermediates.size(); |
1826 | 1826 |
1827 scoped_refptr<SharedChainData> shared_chain_data( | 1827 scoped_refptr<SharedChainData> shared_chain_data( |
1828 new SharedChainData(intermediates.size() + 1, TimeTicks::Now())); | 1828 new SharedChainData(intermediates.size() + 1, TimeTicks::Now())); |
1829 cache_->cert_cache()->Get(key, | 1829 cache_->cert_cache()->GetCertificate(key, |
1830 base::Bind(&OnCertReadIOComplete, | 1830 base::Bind(&OnCertReadIOComplete, |
1831 dist_from_root, | 1831 dist_from_root, |
1832 true /* is leaf */, | 1832 true /* is leaf */, |
1833 shared_chain_data)); | 1833 shared_chain_data)); |
1834 | 1834 |
1835 for (X509Certificate::OSCertHandles::const_iterator it = | 1835 for (X509Certificate::OSCertHandles::const_iterator it = |
1836 intermediates.begin(); | 1836 intermediates.begin(); |
1837 it != intermediates.end(); | 1837 it != intermediates.end(); |
1838 ++it) { | 1838 ++it) { |
1839 --dist_from_root; | 1839 --dist_from_root; |
1840 key = GetCacheKeyForCert(*it); | 1840 key = GetCacheKeyForCert(*it); |
1841 cache_->cert_cache()->Get(key, | 1841 cache_->cert_cache()->GetCertificate(key, |
1842 base::Bind(&OnCertReadIOComplete, | 1842 base::Bind(&OnCertReadIOComplete, |
1843 dist_from_root, | 1843 dist_from_root, |
1844 false /* is not leaf */, | 1844 false /* is not leaf */, |
1845 shared_chain_data)); | 1845 shared_chain_data)); |
1846 } | 1846 } |
1847 DCHECK_EQ(0, dist_from_root); | 1847 DCHECK_EQ(0, dist_from_root); |
1848 } | 1848 } |
1849 | 1849 |
1850 void HttpCache::Transaction::WriteCertChain() { | 1850 void HttpCache::Transaction::WriteCertChain() { |
1851 const X509Certificate::OSCertHandles& intermediates = | 1851 const X509Certificate::OSCertHandles& intermediates = |
1852 response_.ssl_info.cert->GetIntermediateCertificates(); | 1852 response_.ssl_info.cert->GetIntermediateCertificates(); |
1853 int dist_from_root = intermediates.size(); | 1853 int dist_from_root = intermediates.size(); |
1854 | 1854 |
1855 scoped_refptr<SharedChainData> shared_chain_data( | 1855 scoped_refptr<SharedChainData> shared_chain_data( |
1856 new SharedChainData(intermediates.size() + 1, TimeTicks::Now())); | 1856 new SharedChainData(intermediates.size() + 1, TimeTicks::Now())); |
1857 cache_->cert_cache()->Set(response_.ssl_info.cert->os_cert_handle(), | 1857 cache_->cert_cache()->SetCertificate( |
1858 base::Bind(&OnCertWriteIOComplete, | 1858 response_.ssl_info.cert->os_cert_handle(), |
1859 dist_from_root, | 1859 base::Bind(&OnCertWriteIOComplete, |
1860 true /* is leaf */, | 1860 dist_from_root, |
1861 shared_chain_data)); | 1861 true /* is leaf */, |
| 1862 shared_chain_data)); |
1862 for (X509Certificate::OSCertHandles::const_iterator it = | 1863 for (X509Certificate::OSCertHandles::const_iterator it = |
1863 intermediates.begin(); | 1864 intermediates.begin(); |
1864 it != intermediates.end(); | 1865 it != intermediates.end(); |
1865 ++it) { | 1866 ++it) { |
1866 --dist_from_root; | 1867 --dist_from_root; |
1867 cache_->cert_cache()->Set(*it, | 1868 cache_->cert_cache()->SetCertificate(*it, |
1868 base::Bind(&OnCertWriteIOComplete, | 1869 base::Bind(&OnCertWriteIOComplete, |
1869 dist_from_root, | 1870 dist_from_root, |
1870 false /* is not leaf */, | 1871 false /* is not leaf */, |
1871 shared_chain_data)); | 1872 shared_chain_data)); |
1872 } | 1873 } |
1873 DCHECK_EQ(0, dist_from_root); | 1874 DCHECK_EQ(0, dist_from_root); |
1874 } | 1875 } |
1875 | 1876 |
1876 void HttpCache::Transaction::SetRequest(const BoundNetLog& net_log, | 1877 void HttpCache::Transaction::SetRequest(const BoundNetLog& net_log, |
1877 const HttpRequestInfo* request) { | 1878 const HttpRequestInfo* request) { |
1878 net_log_ = net_log; | 1879 net_log_ = net_log; |
1879 request_ = request; | 1880 request_ = request; |
1880 effective_load_flags_ = request_->load_flags; | 1881 effective_load_flags_ = request_->load_flags; |
1881 | 1882 |
1882 switch (cache_->mode()) { | 1883 switch (cache_->mode()) { |
1883 case NORMAL: | 1884 case NORMAL: |
1884 break; | 1885 break; |
1885 case RECORD: | 1886 case RECORD: |
1886 // When in record mode, we want to NEVER load from the cache. | 1887 // When in record mode, we want to NEVER load from the cache. |
1887 // The reason for this is beacuse we save the Set-Cookie headers | 1888 // The reason for this is because we save the Set-Cookie headers |
1888 // (intentionally). If we read from the cache, we replay them | 1889 // (intentionally). If we read from the cache, we replay them |
1889 // prematurely. | 1890 // prematurely. |
1890 effective_load_flags_ |= LOAD_BYPASS_CACHE; | 1891 effective_load_flags_ |= LOAD_BYPASS_CACHE; |
1891 break; | 1892 break; |
1892 case PLAYBACK: | 1893 case PLAYBACK: |
1893 // When in playback mode, we want to load exclusively from the cache. | 1894 // When in playback mode, we want to load exclusively from the cache. |
1894 effective_load_flags_ |= LOAD_ONLY_FROM_CACHE; | 1895 effective_load_flags_ |= LOAD_ONLY_FROM_CACHE; |
1895 break; | 1896 break; |
1896 case DISABLE: | 1897 case DISABLE: |
1897 effective_load_flags_ |= LOAD_DISABLE_CACHE; | 1898 effective_load_flags_ |= LOAD_DISABLE_CACHE; |
(...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2746 default: | 2747 default: |
2747 NOTREACHED(); | 2748 NOTREACHED(); |
2748 } | 2749 } |
2749 } | 2750 } |
2750 | 2751 |
2751 void HttpCache::Transaction::OnIOComplete(int result) { | 2752 void HttpCache::Transaction::OnIOComplete(int result) { |
2752 DoLoop(result); | 2753 DoLoop(result); |
2753 } | 2754 } |
2754 | 2755 |
2755 } // namespace net | 2756 } // namespace net |
OLD | NEW |