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

Unified Diff: net/base/mock_host_resolver.cc

Issue 11464028: Introduce ERR_NETWORK_CHANGED and allow URLFetcher to automatically retry on that error. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed nits Created 8 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/mock_host_resolver.h ('k') | net/base/net_error_list.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/mock_host_resolver.cc
diff --git a/net/base/mock_host_resolver.cc b/net/base/mock_host_resolver.cc
index d86e20924c538c1bb1ce40c16840b07e9c4dcef4..a0835b88126f34eb64f1678a0ca3fc2707efde14 100644
--- a/net/base/mock_host_resolver.cc
+++ b/net/base/mock_host_resolver.cc
@@ -84,10 +84,13 @@ int MockHostResolverBase::Resolve(const RequestInfo& info,
requests_[id] = req;
if (handle)
*handle = reinterpret_cast<RequestHandle>(id);
- MessageLoop::current()->PostTask(FROM_HERE,
- base::Bind(&MockHostResolverBase::ResolveNow,
- AsWeakPtr(),
- id));
+
+ if (!ondemand_mode_) {
+ MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(&MockHostResolverBase::ResolveNow, AsWeakPtr(), id));
+ }
+
return ERR_IO_PENDING;
}
@@ -117,9 +120,21 @@ HostCache* MockHostResolverBase::GetHostCache() {
return cache_.get();
}
+void MockHostResolverBase::ResolveAllPending() {
+ DCHECK(CalledOnValidThread());
+ DCHECK(ondemand_mode_);
+ for (RequestMap::iterator i = requests_.begin(); i != requests_.end(); ++i) {
+ MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(&MockHostResolverBase::ResolveNow, AsWeakPtr(), i->first));
+ }
+}
+
// start id from 1 to distinguish from NULL RequestHandle
MockHostResolverBase::MockHostResolverBase(bool use_caching)
- : synchronous_mode_(false), next_request_id_(1) {
+ : synchronous_mode_(false),
+ ondemand_mode_(false),
+ next_request_id_(1) {
rules_ = CreateCatchAllHostResolverProc();
if (use_caching) {
« no previous file with comments | « net/base/mock_host_resolver.h ('k') | net/base/net_error_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698