| 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_;
|
|
|