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

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: Rebased, post first try if online, more tests 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
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..a2c82c7bff0da8ca51eeacba3d7b9eb9d1d57936 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 when this is set to true,
szym 2012/12/10 18:36:31 Just as |set_asynchronous_mode| makes an exception
Joao da Silva 2012/12/11 13:36:43 Done.
+ // which is the default. When set to false, Resolve() returns IO_PENDING and
+ // ResolveAllPending() must be explicitly invoked to resolve all requests that
+ // are pending.
+ void set_resolve_automatically(bool resolve_automatically) {
+ resolve_automatically_ = resolve_automatically;
+ }
+
// 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 invoked this if
szym 2012/12/10 18:36:31 nit: invoke
Joao da Silva 2012/12/11 13:36:43 Done.
+ // set_resolve_automatically(false) 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 resolve_automatically_;
scoped_refptr<RuleBasedHostResolverProc> rules_;
scoped_ptr<HostCache> cache_;
RequestMap requests_;

Powered by Google App Engine
This is Rietveld 408576698