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

Side by Side Diff: net/proxy/mock_proxy_resolver.h

Issue 992733002: Remove //net (except for Android test stuff) and sdch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « net/proxy/dhcpcsvc_init_win.cc ('k') | net/proxy/mock_proxy_resolver.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef NET_PROXY_MOCK_PROXY_RESOLVER_H_
6 #define NET_PROXY_MOCK_PROXY_RESOLVER_H_
7
8 #include <vector>
9
10 #include "base/memory/scoped_ptr.h"
11 #include "net/base/net_errors.h"
12 #include "net/proxy/proxy_resolver.h"
13 #include "url/gurl.h"
14
15 namespace base {
16 class MessageLoop;
17 }
18
19 namespace net {
20
21 // Asynchronous mock proxy resolver. All requests complete asynchronously,
22 // user must call Request::CompleteNow() on a pending request to signal it.
23 class MockAsyncProxyResolverBase : public ProxyResolver {
24 public:
25 class Request : public base::RefCounted<Request> {
26 public:
27 Request(MockAsyncProxyResolverBase* resolver,
28 const GURL& url,
29 ProxyInfo* results,
30 const net::CompletionCallback& callback);
31
32 const GURL& url() const { return url_; }
33 ProxyInfo* results() const { return results_; }
34 const net::CompletionCallback& callback() const { return callback_; }
35
36 void CompleteNow(int rv);
37
38 private:
39 friend class base::RefCounted<Request>;
40
41 virtual ~Request();
42
43 MockAsyncProxyResolverBase* resolver_;
44 const GURL url_;
45 ProxyInfo* results_;
46 net::CompletionCallback callback_;
47 base::MessageLoop* origin_loop_;
48 };
49
50 class SetPacScriptRequest {
51 public:
52 SetPacScriptRequest(
53 MockAsyncProxyResolverBase* resolver,
54 const scoped_refptr<ProxyResolverScriptData>& script_data,
55 const net::CompletionCallback& callback);
56 ~SetPacScriptRequest();
57
58 const ProxyResolverScriptData* script_data() const {
59 return script_data_.get();
60 }
61
62 void CompleteNow(int rv);
63
64 private:
65 MockAsyncProxyResolverBase* resolver_;
66 const scoped_refptr<ProxyResolverScriptData> script_data_;
67 net::CompletionCallback callback_;
68 base::MessageLoop* origin_loop_;
69 };
70
71 typedef std::vector<scoped_refptr<Request> > RequestsList;
72
73 ~MockAsyncProxyResolverBase() override;
74
75 // ProxyResolver implementation.
76 int GetProxyForURL(const GURL& url,
77 ProxyInfo* results,
78 const net::CompletionCallback& callback,
79 RequestHandle* request_handle,
80 const BoundNetLog& /*net_log*/) override;
81 void CancelRequest(RequestHandle request_handle) override;
82 LoadState GetLoadState(RequestHandle request_handle) const override;
83 int SetPacScript(const scoped_refptr<ProxyResolverScriptData>& script_data,
84 const net::CompletionCallback& callback) override;
85 void CancelSetPacScript() override;
86
87 const RequestsList& pending_requests() const {
88 return pending_requests_;
89 }
90
91 const RequestsList& cancelled_requests() const {
92 return cancelled_requests_;
93 }
94
95 SetPacScriptRequest* pending_set_pac_script_request() const;
96
97 bool has_pending_set_pac_script_request() const {
98 return pending_set_pac_script_request_.get() != NULL;
99 }
100
101 void RemovePendingRequest(Request* request);
102
103 void RemovePendingSetPacScriptRequest(SetPacScriptRequest* request);
104
105 protected:
106 explicit MockAsyncProxyResolverBase(bool expects_pac_bytes);
107
108 private:
109 RequestsList pending_requests_;
110 RequestsList cancelled_requests_;
111 scoped_ptr<SetPacScriptRequest> pending_set_pac_script_request_;
112 };
113
114 class MockAsyncProxyResolver : public MockAsyncProxyResolverBase {
115 public:
116 MockAsyncProxyResolver()
117 : MockAsyncProxyResolverBase(false /*expects_pac_bytes*/) {}
118 };
119
120 class MockAsyncProxyResolverExpectsBytes : public MockAsyncProxyResolverBase {
121 public:
122 MockAsyncProxyResolverExpectsBytes()
123 : MockAsyncProxyResolverBase(true /*expects_pac_bytes*/) {}
124 };
125
126 } // namespace net
127
128 #endif // NET_PROXY_MOCK_PROXY_RESOLVER_H_
OLDNEW
« no previous file with comments | « net/proxy/dhcpcsvc_init_win.cc ('k') | net/proxy/mock_proxy_resolver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698