1// Copyright (c) 2010 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_PROXY_RESOLVER_WINHTTP_H_
6#define NET_PROXY_PROXY_RESOLVER_WINHTTP_H_
7#pragma once
8
9#include "googleurl/src/gurl.h"
10#include "net/proxy/proxy_resolver.h"
11
12typedef void* HINTERNET;  // From winhttp.h
13
14namespace net {
15
16// An implementation of ProxyResolver that uses WinHTTP and the system
17// proxy settings.
18class ProxyResolverWinHttp : public ProxyResolver {
19 public:
20  ProxyResolverWinHttp();
21  virtual ~ProxyResolverWinHttp();
22
23  // ProxyResolver implementation:
24  virtual int GetProxyForURL(const GURL& url,
25                             ProxyInfo* results,
26                             CompletionCallback* /*callback*/,
27                             RequestHandle* /*request*/,
28                             const BoundNetLog& /*net_log*/);
29  virtual void CancelRequest(RequestHandle request);
30
31  virtual void CancelSetPacScript();
32
33  virtual int SetPacScript(
34      const scoped_refptr<ProxyResolverScriptData>& script_data,
35      CompletionCallback* /*callback*/);
36
37 private:
38  bool OpenWinHttpSession();
39  void CloseWinHttpSession();
40
41  // Proxy configuration is cached on the session handle.
42  HINTERNET session_handle_;
43
44  GURL pac_url_;
45
46  DISALLOW_COPY_AND_ASSIGN(ProxyResolverWinHttp);
47};
48
49}  // namespace net
50
51#endif  // NET_PROXY_PROXY_RESOLVER_WINHTTP_H_
52