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

Unified Diff: net/base/mock_host_resolver.h

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/host_resolver_impl_unittest.cc ('k') | net/base/mock_host_resolver.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/mock_host_resolver.h
diff --git a/net/base/mock_host_resolver.h b/net/base/mock_host_resolver.h
index 033cf147527769bbd3a9cd7eae464a7a7b306037..5542a64cf9da942cce34bfb39936a5f7edd40985 100644
--- a/net/base/mock_host_resolver.h
+++ b/net/base/mock_host_resolver.h
@@ -65,6 +65,14 @@ class MockHostResolverBase : public HostResolver,
synchronous_mode_ = is_synchronous;
}
+ // Asynchronous requests are automatically resolved by default.
+ // If set_ondemand_mode() is set then Resolve() returns IO_PENDING and
+ // ResolveAllPending() must be explicitly invoked to resolve all requests
+ // that are pending.
+ void set_ondemand_mode(bool is_ondemand) {
+ ondemand_mode_ = is_ondemand;
+ }
+
// HostResolver methods:
virtual int Resolve(const RequestInfo& info,
AddressList* addresses,
@@ -77,6 +85,15 @@ class MockHostResolverBase : public HostResolver,
virtual void CancelRequest(RequestHandle req) OVERRIDE;
virtual HostCache* GetHostCache() OVERRIDE;
+ // Resolves all pending requests. It is only valid to invoke this if
+ // set_ondemand_mode was set before. The requests are resolved asynchronously,
+ // after this call returns.
+ void ResolveAllPending();
+
+ // Returns true if there are pending requests that can be resolved by invoking
+ // ResolveAllPending().
+ bool has_pending_requests() const { return !requests_.empty(); }
+
protected:
explicit MockHostResolverBase(bool use_caching);
@@ -94,6 +111,7 @@ class MockHostResolverBase : public HostResolver,
void ResolveNow(size_t id);
bool synchronous_mode_;
+ bool ondemand_mode_;
scoped_refptr<RuleBasedHostResolverProc> rules_;
scoped_ptr<HostCache> cache_;
RequestMap requests_;
« no previous file with comments | « net/base/host_resolver_impl_unittest.cc ('k') | net/base/mock_host_resolver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698