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

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

Issue 6831025: Adds support for the DHCP portion of the WPAD (proxy auto-discovery) protocol. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Isolate worker thread to separate object. Refcount context. Fix mandatory PAC. Created 9 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_PROXY_PROXY_SERVICE_H_ 5 #ifndef NET_PROXY_PROXY_SERVICE_H_
6 #define NET_PROXY_PROXY_SERVICE_H_ 6 #define NET_PROXY_PROXY_SERVICE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/gtest_prod_util.h" 11 #include "base/gtest_prod_util.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/synchronization/waitable_event.h" 14 #include "base/synchronization/waitable_event.h"
15 #include "base/threading/non_thread_safe.h" 15 #include "base/threading/non_thread_safe.h"
16 #include "net/base/completion_callback.h" 16 #include "net/base/completion_callback.h"
17 #include "net/base/net_log.h" 17 #include "net/base/net_log.h"
18 #include "net/base/network_change_notifier.h" 18 #include "net/base/network_change_notifier.h"
19 #include "net/proxy/proxy_config_service.h" 19 #include "net/proxy/proxy_config_service.h"
20 #include "net/proxy/proxy_info.h" 20 #include "net/proxy/proxy_info.h"
21 #include "net/proxy/proxy_server.h" 21 #include "net/proxy/proxy_server.h"
22 22
23 class GURL; 23 class GURL;
24 class MessageLoop; 24 class MessageLoop;
25 25
26 namespace net { 26 namespace net {
27 27
28 class DhcpProxyScriptFetcher;
28 class HostResolver; 29 class HostResolver;
29 class InitProxyResolver; 30 class InitProxyResolver;
30 class NetworkDelegate; 31 class NetworkDelegate;
31 class ProxyResolver; 32 class ProxyResolver;
32 class ProxyScriptFetcher; 33 class ProxyScriptFetcher;
33 class URLRequestContext; 34 class URLRequestContext;
34 35
35 // This class can be used to resolve the proxy server to use when loading a 36 // This class can be used to resolve the proxy server to use when loading a
36 // HTTP(S) URL. It uses the given ProxyResolver to handle the actual proxy 37 // HTTP(S) URL. It uses the given ProxyResolver to handle the actual proxy
37 // resolution. See ProxyResolverV8 for example. 38 // resolution. See ProxyResolverV8 for example.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 // Profiling information for the request is saved to |net_log| if non-NULL. 92 // Profiling information for the request is saved to |net_log| if non-NULL.
92 int ReconsiderProxyAfterError(const GURL& url, 93 int ReconsiderProxyAfterError(const GURL& url,
93 ProxyInfo* results, 94 ProxyInfo* results,
94 CompletionCallback* callback, 95 CompletionCallback* callback,
95 PacRequest** pac_request, 96 PacRequest** pac_request,
96 const BoundNetLog& net_log); 97 const BoundNetLog& net_log);
97 98
98 // Call this method with a non-null |pac_request| to cancel the PAC request. 99 // Call this method with a non-null |pac_request| to cancel the PAC request.
99 void CancelPacRequest(PacRequest* pac_request); 100 void CancelPacRequest(PacRequest* pac_request);
100 101
101 // Sets the ProxyScriptFetcher dependency. This is needed if the ProxyResolver 102 // Sets the ProxyScriptFetcher and DhcpProxyScriptFetcher dependencies. This
102 // is of type ProxyResolverWithoutFetch. ProxyService takes ownership of 103 // is needed if the ProxyResolver is of type ProxyResolverWithoutFetch.
103 // |proxy_script_fetcher|. 104 // ProxyService takes ownership of both objects.
104 void SetProxyScriptFetcher(ProxyScriptFetcher* proxy_script_fetcher); 105 void SetProxyScriptFetchers(
106 ProxyScriptFetcher* proxy_script_fetcher,
107 DhcpProxyScriptFetcher* dhcp_proxy_script_fetcher);
105 ProxyScriptFetcher* GetProxyScriptFetcher() const; 108 ProxyScriptFetcher* GetProxyScriptFetcher() const;
109 DhcpProxyScriptFetcher* GetDhcpProxyScriptFetcher() const;
106 110
107 // Tells this ProxyService to start using a new ProxyConfigService to 111 // Tells this ProxyService to start using a new ProxyConfigService to
108 // retrieve its ProxyConfig from. The new ProxyConfigService will immediately 112 // retrieve its ProxyConfig from. The new ProxyConfigService will immediately
109 // be queried for new config info which will be used for all subsequent 113 // be queried for new config info which will be used for all subsequent
110 // ResolveProxy calls. ProxyService takes ownership of 114 // ResolveProxy calls. ProxyService takes ownership of
111 // |new_proxy_config_service|. 115 // |new_proxy_config_service|.
112 void ResetConfigService(ProxyConfigService* new_proxy_config_service); 116 void ResetConfigService(ProxyConfigService* new_proxy_config_service);
113 117
114 // Tells the resolver to purge any memory it does not need. 118 // Tells the resolver to purge any memory it does not need.
115 void PurgeMemory(); 119 void PurgeMemory();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 // 158 //
155 // However, the disadvantages of using more than 1 thread are: 159 // However, the disadvantages of using more than 1 thread are:
156 // (a) can cause compatibility issues for scripts that rely on side effects 160 // (a) can cause compatibility issues for scripts that rely on side effects
157 // between runs (such scripts should not be common though). 161 // between runs (such scripts should not be common though).
158 // (b) increases the memory used by proxy resolving, as each thread will 162 // (b) increases the memory used by proxy resolving, as each thread will
159 // duplicate its own script context. 163 // duplicate its own script context.
160 164
161 // |proxy_script_fetcher| specifies the dependency to use for downloading 165 // |proxy_script_fetcher| specifies the dependency to use for downloading
162 // any PAC scripts. The resulting ProxyService will take ownership of it. 166 // any PAC scripts. The resulting ProxyService will take ownership of it.
163 // 167 //
168 // |dhcp_proxy_script_fetcher| specifies the dependency to use for attempting
169 // to retrieve the most appropriate PAC script configured in DHCP. The
170 // resulting ProxyService will take ownership of it.
171 //
164 // |host_resolver| points to the host resolving dependency the PAC script 172 // |host_resolver| points to the host resolving dependency the PAC script
165 // should use for any DNS queries. It must remain valid throughout the 173 // should use for any DNS queries. It must remain valid throughout the
166 // lifetime of the ProxyService. 174 // lifetime of the ProxyService.
167 // 175 //
168 // ########################################################################## 176 // ##########################################################################
169 // # See the warnings in net/proxy/proxy_resolver_v8.h describing the 177 // # See the warnings in net/proxy/proxy_resolver_v8.h describing the
170 // # multi-threading model. In order for this to be safe to use, *ALL* the 178 // # multi-threading model. In order for this to be safe to use, *ALL* the
171 // # other V8's running in the process must use v8::Locker. 179 // # other V8's running in the process must use v8::Locker.
172 // ########################################################################## 180 // ##########################################################################
173 static ProxyService* CreateUsingV8ProxyResolver( 181 static ProxyService* CreateUsingV8ProxyResolver(
174 ProxyConfigService* proxy_config_service, 182 ProxyConfigService* proxy_config_service,
175 size_t num_pac_threads, 183 size_t num_pac_threads,
176 ProxyScriptFetcher* proxy_script_fetcher, 184 ProxyScriptFetcher* proxy_script_fetcher,
185 DhcpProxyScriptFetcher* dhcp_proxy_script_fetcher,
177 HostResolver* host_resolver, 186 HostResolver* host_resolver,
178 NetLog* net_log, 187 NetLog* net_log,
179 NetworkDelegate* network_delegate); 188 NetworkDelegate* network_delegate);
180 189
181 // Same as CreateUsingV8ProxyResolver, except it uses system libraries 190 // Same as CreateUsingV8ProxyResolver, except it uses system libraries
182 // for evaluating the PAC script if available, otherwise skips 191 // for evaluating the PAC script if available, otherwise skips
183 // proxy autoconfig. 192 // proxy autoconfig.
184 static ProxyService* CreateUsingSystemProxyResolver( 193 static ProxyService* CreateUsingSystemProxyResolver(
185 ProxyConfigService* proxy_config_service, 194 ProxyConfigService* proxy_config_service,
186 size_t num_pac_threads, 195 size_t num_pac_threads,
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 ProxyRetryInfoMap proxy_retry_info_; 321 ProxyRetryInfoMap proxy_retry_info_;
313 322
314 // Set of pending/inprogress requests. 323 // Set of pending/inprogress requests.
315 PendingRequests pending_requests_; 324 PendingRequests pending_requests_;
316 325
317 // The fetcher to use when downloading PAC scripts for the ProxyResolver. 326 // The fetcher to use when downloading PAC scripts for the ProxyResolver.
318 // This dependency can be NULL if our ProxyResolver has no need for 327 // This dependency can be NULL if our ProxyResolver has no need for
319 // external PAC script fetching. 328 // external PAC script fetching.
320 scoped_ptr<ProxyScriptFetcher> proxy_script_fetcher_; 329 scoped_ptr<ProxyScriptFetcher> proxy_script_fetcher_;
321 330
331 // The fetcher to use when attempting to download the most appropriate PAC
332 // script configured in DHCP, if any. Can be NULL if the ProxyResolver has
333 // no need for DHCP PAC script fetching.
334 scoped_ptr<DhcpProxyScriptFetcher> dhcp_proxy_script_fetcher_;
335
322 // Callback for when |init_proxy_resolver_| is done. 336 // Callback for when |init_proxy_resolver_| is done.
323 CompletionCallbackImpl<ProxyService> init_proxy_resolver_callback_; 337 CompletionCallbackImpl<ProxyService> init_proxy_resolver_callback_;
324 338
325 // Helper to download the PAC script (wpad + custom) and apply fallback rules. 339 // Helper to download the PAC script (wpad + custom) and apply fallback rules.
326 // 340 //
327 // Note that the declaration is important here: |proxy_script_fetcher_| and 341 // Note that the declaration is important here: |proxy_script_fetcher_| and
328 // |proxy_resolver_| must outlive |init_proxy_resolver_|. 342 // |proxy_resolver_| must outlive |init_proxy_resolver_|.
329 scoped_ptr<InitProxyResolver> init_proxy_resolver_; 343 scoped_ptr<InitProxyResolver> init_proxy_resolver_;
330 344
331 State current_state_; 345 State current_state_;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 391
378 base::WaitableEvent event_; 392 base::WaitableEvent event_;
379 CompletionCallbackImpl<SyncProxyServiceHelper> callback_; 393 CompletionCallbackImpl<SyncProxyServiceHelper> callback_;
380 ProxyInfo proxy_info_; 394 ProxyInfo proxy_info_;
381 int result_; 395 int result_;
382 }; 396 };
383 397
384 } // namespace net 398 } // namespace net
385 399
386 #endif // NET_PROXY_PROXY_SERVICE_H_ 400 #endif // NET_PROXY_PROXY_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698