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

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

Issue 222009: Replace some net::ERR_FAILED generic error codes with more specific codes.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Address wtc's comments Created 11 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « net/http/http_cache.h ('k') | net/http/http_cache_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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.h" 5 #include "net/http/http_cache.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after
1037 DoneWritingToEntry(true); 1037 DoneWritingToEntry(true);
1038 } 1038 }
1039 1039
1040 return BeginNetworkRequest(); 1040 return BeginNetworkRequest();
1041 } 1041 }
1042 1042
1043 int HttpCache::Transaction::BeginNetworkRequest() { 1043 int HttpCache::Transaction::BeginNetworkRequest() {
1044 DCHECK(mode_ & WRITE || mode_ == NONE); 1044 DCHECK(mode_ & WRITE || mode_ == NONE);
1045 DCHECK(!network_trans_.get()); 1045 DCHECK(!network_trans_.get());
1046 1046
1047 network_trans_.reset(cache_->network_layer_->CreateTransaction()); 1047 // Create a network transaction.
1048 if (!network_trans_.get()) 1048 int rv = cache_->network_layer_->CreateTransaction(&network_trans_);
1049 return net::ERR_CACHE_CANNOT_CREATE_NETWORK_TRANSACTION; 1049 if (rv != OK)
1050 return rv;
1050 1051
1051 int rv = network_trans_->Start(request_, &network_info_callback_, load_log_); 1052 rv = network_trans_->Start(request_, &network_info_callback_, load_log_);
1052 if (rv != ERR_IO_PENDING) 1053 if (rv != ERR_IO_PENDING)
1053 OnNetworkInfoAvailable(rv); 1054 OnNetworkInfoAvailable(rv);
1054 return rv; 1055 return rv;
1055 } 1056 }
1056 1057
1057 int HttpCache::Transaction::RestartNetworkRequest() { 1058 int HttpCache::Transaction::RestartNetworkRequest() {
1058 DCHECK(mode_ & WRITE || mode_ == NONE); 1059 DCHECK(mode_ & WRITE || mode_ == NONE);
1059 DCHECK(network_trans_.get()); 1060 DCHECK(network_trans_.get());
1060 1061
1061 int rv = network_trans_->RestartIgnoringLastError(&network_info_callback_); 1062 int rv = network_trans_->RestartIgnoringLastError(&network_info_callback_);
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
1649 entry->readers.clear(); 1650 entry->readers.clear();
1650 entry->writer = NULL; 1651 entry->writer = NULL;
1651 DeactivateEntry(entry); 1652 DeactivateEntry(entry);
1652 } 1653 }
1653 1654
1654 ActiveEntriesSet::iterator it = doomed_entries_.begin(); 1655 ActiveEntriesSet::iterator it = doomed_entries_.begin();
1655 for (; it != doomed_entries_.end(); ++it) 1656 for (; it != doomed_entries_.end(); ++it)
1656 delete *it; 1657 delete *it;
1657 } 1658 }
1658 1659
1659 HttpTransaction* HttpCache::CreateTransaction() { 1660 int HttpCache::CreateTransaction(scoped_ptr<HttpTransaction>* trans) {
1660 // Do lazy initialization of disk cache if needed. 1661 // Do lazy initialization of disk cache if needed.
1661 if (!disk_cache_.get()) { 1662 if (!disk_cache_.get()) {
1662 DCHECK_GE(cache_size_, 0); 1663 DCHECK_GE(cache_size_, 0);
1663 if (in_memory_cache_) { 1664 if (in_memory_cache_) {
1664 // We may end up with no folder name and no cache if the initialization 1665 // We may end up with no folder name and no cache if the initialization
1665 // of the disk cache fails. We want to be sure that what we wanted to have 1666 // of the disk cache fails. We want to be sure that what we wanted to have
1666 // was an in-memory cache. 1667 // was an in-memory cache.
1667 disk_cache_.reset(disk_cache::CreateInMemoryCacheBackend(cache_size_)); 1668 disk_cache_.reset(disk_cache::CreateInMemoryCacheBackend(cache_size_));
1668 } else if (!disk_cache_dir_.empty()) { 1669 } else if (!disk_cache_dir_.empty()) {
1669 disk_cache_.reset(disk_cache::CreateCacheBackend(disk_cache_dir_, true, 1670 disk_cache_.reset(disk_cache::CreateCacheBackend(disk_cache_dir_, true,
1670 cache_size_, type_)); 1671 cache_size_, type_));
1671 disk_cache_dir_.clear(); // Reclaim memory. 1672 disk_cache_dir_.clear(); // Reclaim memory.
1672 } 1673 }
1673 } 1674 }
1674 return new HttpCache::Transaction(this, enable_range_support_); 1675 trans->reset(new HttpCache::Transaction(this, enable_range_support_));
1676 return OK;
1675 } 1677 }
1676 1678
1677 HttpCache* HttpCache::GetCache() { 1679 HttpCache* HttpCache::GetCache() {
1678 return this; 1680 return this;
1679 } 1681 }
1680 1682
1681 void HttpCache::Suspend(bool suspend) { 1683 void HttpCache::Suspend(bool suspend) {
1682 network_layer_->Suspend(suspend); 1684 network_layer_->Suspend(suspend);
1683 } 1685 }
1684 1686
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
2127 static_cast<net::HttpNetworkLayer*>(network_layer_.get()); 2129 static_cast<net::HttpNetworkLayer*>(network_layer_.get());
2128 HttpNetworkSession* session = network->GetSession(); 2130 HttpNetworkSession* session = network->GetSession();
2129 if (session) { 2131 if (session) {
2130 session->tcp_socket_pool()->CloseIdleSockets(); 2132 session->tcp_socket_pool()->CloseIdleSockets();
2131 } 2133 }
2132 } 2134 }
2133 2135
2134 //----------------------------------------------------------------------------- 2136 //-----------------------------------------------------------------------------
2135 2137
2136 } // namespace net 2138 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_cache.h ('k') | net/http/http_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698