OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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_BASE_HTTPS_PROBER_H_ | 5 #ifndef NET_BASE_HTTPS_PROBER_H_ |
6 #define NET_BASE_HTTPS_PROBER_H_ | 6 #define NET_BASE_HTTPS_PROBER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/singleton.h" | 12 #include "base/singleton.h" |
13 #include "base/task.h" | 13 #include "base/task.h" |
14 #include "net/url_request/url_request.h" | 14 #include "net/url_request/url_request.h" |
15 | 15 |
16 class URLRequestContext; | 16 class URLRequestContext; |
17 | 17 |
18 namespace net { | 18 namespace net { |
19 | 19 |
20 // This should be scoped inside HTTPSProber, but VC cannot compile | 20 // This should be scoped inside HTTPSProber, but VC cannot compile |
21 // HTTPProber::Delegate when HTTPSProber also inherits from | 21 // HTTPProber::Delegate when HTTPSProber also inherits from |
22 // URLRequest::Delegate. | 22 // URLRequest::Delegate. |
23 class HTTPSProberDelegate { | 23 class HTTPSProberDelegate { |
24 public: | 24 public: |
25 virtual void ProbeComplete(bool result) = 0; | 25 virtual void ProbeComplete(bool result) = 0; |
| 26 protected: |
| 27 virtual ~HTTPSProberDelegate() {} |
26 }; | 28 }; |
27 | 29 |
28 // HTTPSProber is a singleton object that manages HTTPS probes. A HTTPS probe | 30 // HTTPSProber is a singleton object that manages HTTPS probes. A HTTPS probe |
29 // determines if we can connect to a given host over HTTPS. It's used when | 31 // determines if we can connect to a given host over HTTPS. It's used when |
30 // transparently upgrading from HTTP to HTTPS (for example, for SPDY). | 32 // transparently upgrading from HTTP to HTTPS (for example, for SPDY). |
31 class HTTPSProber : public URLRequest::Delegate { | 33 class HTTPSProber : public URLRequest::Delegate { |
32 public: | 34 public: |
33 HTTPSProber() { } | 35 HTTPSProber() {} |
34 | 36 |
35 // HaveProbed returns true if the given host is known to have been probed | 37 // HaveProbed returns true if the given host is known to have been probed |
36 // since the browser was last started. | 38 // since the browser was last started. |
37 bool HaveProbed(const std::string& host) const; | 39 bool HaveProbed(const std::string& host) const; |
38 | 40 |
39 // InFlight returns true iff a probe for the given host is currently active. | 41 // InFlight returns true iff a probe for the given host is currently active. |
40 bool InFlight(const std::string& host) const; | 42 bool InFlight(const std::string& host) const; |
41 | 43 |
42 // ProbeHost starts a new probe for the given host. If the host is known to | 44 // ProbeHost starts a new probe for the given host. If the host is known to |
43 // have been probed since the browser was started, false is returned and no | 45 // have been probed since the browser was started, false is returned and no |
(...skipping 20 matching lines...) Expand all Loading... |
64 | 66 |
65 std::map<std::string, HTTPSProberDelegate*> inflight_probes_; | 67 std::map<std::string, HTTPSProberDelegate*> inflight_probes_; |
66 std::set<std::string> probed_; | 68 std::set<std::string> probed_; |
67 | 69 |
68 friend struct DefaultSingletonTraits<HTTPSProber>; | 70 friend struct DefaultSingletonTraits<HTTPSProber>; |
69 DISALLOW_COPY_AND_ASSIGN(HTTPSProber); | 71 DISALLOW_COPY_AND_ASSIGN(HTTPSProber); |
70 }; | 72 }; |
71 | 73 |
72 } // namespace net | 74 } // namespace net |
73 #endif | 75 #endif |
OLD | NEW |