OLD | NEW |
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_HTTP_HTTP_AUTH_CACHE_H_ | 5 #ifndef NET_HTTP_HTTP_AUTH_CACHE_H_ |
6 #define NET_HTTP_HTTP_AUTH_CACHE_H_ | 6 #define NET_HTTP_HTTP_AUTH_CACHE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <list> | 9 #include <list> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/string16.h" | 14 #include "base/string16.h" |
15 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
16 #include "net/base/net_api.h" | 16 #include "net/base/net_export.h" |
17 #include "net/http/http_auth.h" | 17 #include "net/http/http_auth.h" |
18 | 18 |
19 namespace net { | 19 namespace net { |
20 | 20 |
21 // HttpAuthCache stores HTTP authentication identities and challenge info. | 21 // HttpAuthCache stores HTTP authentication identities and challenge info. |
22 // For each (origin, realm, scheme) triple the cache stores a | 22 // For each (origin, realm, scheme) triple the cache stores a |
23 // HttpAuthCache::Entry, which holds: | 23 // HttpAuthCache::Entry, which holds: |
24 // - the origin server {protocol scheme, host, port} | 24 // - the origin server {protocol scheme, host, port} |
25 // - the last identity used (username/password) | 25 // - the last identity used (username/password) |
26 // - the last auth handler used (contains realm and authentication scheme) | 26 // - the last auth handler used (contains realm and authentication scheme) |
27 // - the list of paths which used this realm | 27 // - the list of paths which used this realm |
28 // Entries can be looked up by either (origin, realm, scheme) or (origin, path). | 28 // Entries can be looked up by either (origin, realm, scheme) or (origin, path). |
29 class NET_TEST HttpAuthCache { | 29 class NET_EXPORT_PRIVATE HttpAuthCache { |
30 public: | 30 public: |
31 class Entry; | 31 class Entry; |
32 | 32 |
33 // Prevent unbounded memory growth. These are safeguards for abuse; it is | 33 // Prevent unbounded memory growth. These are safeguards for abuse; it is |
34 // not expected that the limits will be reached in ordinary usage. | 34 // not expected that the limits will be reached in ordinary usage. |
35 // This also defines the worst-case lookup times (which grow linearly | 35 // This also defines the worst-case lookup times (which grow linearly |
36 // with number of elements in the cache). | 36 // with number of elements in the cache). |
37 enum { kMaxNumPathsPerRealmEntry = 10 }; | 37 enum { kMaxNumPathsPerRealmEntry = 10 }; |
38 enum { kMaxNumRealmEntries = 10 }; | 38 enum { kMaxNumRealmEntries = 10 }; |
39 | 39 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 const std::string& realm, | 102 const std::string& realm, |
103 HttpAuth::Scheme scheme, | 103 HttpAuth::Scheme scheme, |
104 const std::string& auth_challenge); | 104 const std::string& auth_challenge); |
105 | 105 |
106 private: | 106 private: |
107 typedef std::list<Entry> EntryList; | 107 typedef std::list<Entry> EntryList; |
108 EntryList entries_; | 108 EntryList entries_; |
109 }; | 109 }; |
110 | 110 |
111 // An authentication realm entry. | 111 // An authentication realm entry. |
112 class NET_TEST HttpAuthCache::Entry { | 112 class NET_EXPORT_PRIVATE HttpAuthCache::Entry { |
113 public: | 113 public: |
114 ~Entry(); | 114 ~Entry(); |
115 | 115 |
116 const GURL& origin() const { | 116 const GURL& origin() const { |
117 return origin_; | 117 return origin_; |
118 } | 118 } |
119 | 119 |
120 // The case-sensitive realm string of the challenge. | 120 // The case-sensitive realm string of the challenge. |
121 const std::string realm() const { | 121 const std::string realm() const { |
122 return realm_; | 122 return realm_; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 | 183 |
184 int nonce_count_; | 184 int nonce_count_; |
185 | 185 |
186 // List of paths that define the realm's protection space. | 186 // List of paths that define the realm's protection space. |
187 PathList paths_; | 187 PathList paths_; |
188 }; | 188 }; |
189 | 189 |
190 } // namespace net | 190 } // namespace net |
191 | 191 |
192 #endif // NET_HTTP_HTTP_AUTH_CACHE_H_ | 192 #endif // NET_HTTP_HTTP_AUTH_CACHE_H_ |
OLD | NEW |