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_SSL_HOST_INFO_H | 5 #ifndef NET_BASE_SSL_HOST_INFO_H |
6 #define NET_BASE_SSL_HOST_INFO_H | 6 #define NET_BASE_SSL_HOST_INFO_H |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include "base/ref_counted.h" | 9 #include "base/ref_counted.h" |
10 #include "net/base/completion_callback.h" | 10 #include "net/base/completion_callback.h" |
11 | 11 |
12 namespace net { | 12 namespace net { |
13 | 13 |
14 // SSLHostInfo is an interface for fetching information about an SSL server. | 14 // SSLHostInfo is an interface for fetching information about an SSL server. |
15 // This information may be stored on disk so does not include keys or session | 15 // This information may be stored on disk so does not include keys or session |
16 // information etc. Primarily it's intended for caching the server's | 16 // information etc. Primarily it's intended for caching the server's |
17 // certificates. | 17 // certificates. |
18 class SSLHostInfo { | 18 class SSLHostInfo : |
| 19 public base::RefCountedThreadSafe<SSLHostInfo> { |
19 public: | 20 public: |
20 virtual ~SSLHostInfo(); | |
21 | |
22 // Start will commence the lookup. This must be called before any other | 21 // Start will commence the lookup. This must be called before any other |
23 // methods. By opportunistically calling this early, it may be possible to | 22 // methods. By opportunistically calling this early, it may be possible to |
24 // overlap this object's lookup and reduce latency. | 23 // overlap this object's lookup and reduce latency. |
25 virtual void Start() = 0; | 24 virtual void Start() = 0; |
26 | 25 |
27 // WaitForDataReady returns OK if the fetch of the requested data has | 26 // WaitForDataReady returns OK if the fetch of the requested data has |
28 // completed. Otherwise it returns ERR_IO_PENDING and will call |callback| on | 27 // completed. Otherwise it returns ERR_IO_PENDING and will call |callback| on |
29 // the current thread when ready. | 28 // the current thread when ready. |
30 // | 29 // |
31 // Only a single callback can be outstanding at a given time and, in the | 30 // Only a single callback can be outstanding at a given time and, in the |
32 // event that WaitForDataReady returns OK, it's the caller's responsibility | 31 // event that WaitForDataReady returns OK, it's the caller's responsibility |
33 // to delete |callback|. | 32 // to delete |callback|. |
34 // | 33 // |
35 // |callback| may be NULL, in which case ERR_IO_PENDING may still be returned | 34 // |callback| may be NULL, in which case ERR_IO_PENDING may still be returned |
36 // but, obviously, a callback will never be made. | 35 // but, obviously, a callback will never be made. |
37 virtual int WaitForDataReady(CompletionCallback* callback) = 0; | 36 virtual int WaitForDataReady(CompletionCallback* callback) = 0; |
38 | 37 |
39 // data returns any host information once WaitForDataReady has indicated that | 38 // data returns any host information once WaitForDataReady has indicated that |
40 // the fetch has completed. In the event of an error, |data| returns an empty | 39 // the fetch has completed. In the event of an error, |data| returns an empty |
41 // string. | 40 // string. |
42 virtual const std::string& data() const = 0; | 41 virtual const std::string& data() const = 0; |
43 | 42 |
44 // Set allows for the host information to be updated for future users. This | 43 // Set allows for the host information to be updated for future users. This |
45 // is a fire and forget operation: the caller may drop its reference from | 44 // is a fire and forget operation: the caller may drop its reference from |
46 // this object and the store operation will still complete. This can only be | 45 // this object and the store operation will still complete. This can only be |
47 // called once WaitForDataReady has returned OK or called its callback. | 46 // called once WaitForDataReady has returned OK or called its callback. |
48 virtual void Set(const std::string& new_data) = 0; | 47 virtual void Set(const std::string& new_data) = 0; |
49 }; | |
50 | 48 |
51 class SSLHostInfoFactory { | 49 protected: |
52 public: | 50 friend class base::RefCountedThreadSafe<SSLHostInfo>; |
53 virtual ~SSLHostInfoFactory(); | 51 virtual ~SSLHostInfo() { } |
54 | |
55 // GetForHost returns a fresh, allocated SSLHostInfo for the given hostname | |
56 // or NULL on failure. | |
57 virtual SSLHostInfo* GetForHost(const std::string& hostname) = 0; | |
58 }; | 52 }; |
59 | 53 |
60 } // namespace net | 54 } // namespace net |
61 | 55 |
62 #endif // NET_BASE_SSL_HOST_INFO_H | 56 #endif // NET_BASE_SSL_HOST_INFO_H |
OLD | NEW |