| 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_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> |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 // HttpAuthCache::Entry, which holds: | 21 // HttpAuthCache::Entry, which holds: |
| 22 // - the origin server {protocol scheme, host, port} | 22 // - the origin server {protocol scheme, host, port} |
| 23 // - the last identity used (username/password) | 23 // - the last identity used (username/password) |
| 24 // - the last auth handler used (contains realm and authentication scheme) | 24 // - the last auth handler used (contains realm and authentication scheme) |
| 25 // - the list of paths which used this realm | 25 // - the list of paths which used this realm |
| 26 // Entries can be looked up by either (origin, realm, scheme) or (origin, path). | 26 // Entries can be looked up by either (origin, realm, scheme) or (origin, path). |
| 27 class HttpAuthCache { | 27 class HttpAuthCache { |
| 28 public: | 28 public: |
| 29 class Entry; | 29 class Entry; |
| 30 | 30 |
| 31 HttpAuthCache(); |
| 32 ~HttpAuthCache(); |
| 33 |
| 31 // Find the realm entry on server |origin| for realm |realm| and | 34 // Find the realm entry on server |origin| for realm |realm| and |
| 32 // scheme |scheme|. | 35 // scheme |scheme|. |
| 33 // |origin| - the {scheme, host, port} of the server. | 36 // |origin| - the {scheme, host, port} of the server. |
| 34 // |realm| - case sensitive realm string. | 37 // |realm| - case sensitive realm string. |
| 35 // |scheme| - case sensitive authentication scheme, should be lower-case. | 38 // |scheme| - case sensitive authentication scheme, should be lower-case. |
| 36 // returns - the matched entry or NULL. | 39 // returns - the matched entry or NULL. |
| 37 Entry* Lookup(const GURL& origin, const std::string& realm, | 40 Entry* Lookup(const GURL& origin, const std::string& realm, |
| 38 const std::string& scheme); | 41 const std::string& scheme); |
| 39 | 42 |
| 40 // Find the entry on server |origin| whose protection space includes | 43 // Find the entry on server |origin| whose protection space includes |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 const string16 password() const { | 136 const string16 password() const { |
| 134 return password_; | 137 return password_; |
| 135 } | 138 } |
| 136 | 139 |
| 137 int IncrementNonceCount() { | 140 int IncrementNonceCount() { |
| 138 return ++nonce_count_; | 141 return ++nonce_count_; |
| 139 } | 142 } |
| 140 | 143 |
| 141 void UpdateStaleChallenge(const std::string& auth_challenge); | 144 void UpdateStaleChallenge(const std::string& auth_challenge); |
| 142 | 145 |
| 146 ~Entry(); |
| 147 |
| 143 private: | 148 private: |
| 144 friend class HttpAuthCache; | 149 friend class HttpAuthCache; |
| 145 FRIEND_TEST_ALL_PREFIXES(HttpAuthCacheTest, AddPath); | 150 FRIEND_TEST_ALL_PREFIXES(HttpAuthCacheTest, AddPath); |
| 146 FRIEND_TEST_ALL_PREFIXES(HttpAuthCacheTest, AddToExistingEntry); | 151 FRIEND_TEST_ALL_PREFIXES(HttpAuthCacheTest, AddToExistingEntry); |
| 147 | 152 |
| 148 Entry(); | 153 Entry(); |
| 149 | 154 |
| 150 // Adds a path defining the realm's protection space. If the path is | 155 // Adds a path defining the realm's protection space. If the path is |
| 151 // already contained in the protection space, is a no-op. | 156 // already contained in the protection space, is a no-op. |
| 152 void AddPath(const std::string& path); | 157 void AddPath(const std::string& path); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 167 int nonce_count_; | 172 int nonce_count_; |
| 168 | 173 |
| 169 // List of paths that define the realm's protection space. | 174 // List of paths that define the realm's protection space. |
| 170 typedef std::list<std::string> PathList; | 175 typedef std::list<std::string> PathList; |
| 171 PathList paths_; | 176 PathList paths_; |
| 172 }; | 177 }; |
| 173 | 178 |
| 174 } // namespace net | 179 } // namespace net |
| 175 | 180 |
| 176 #endif // NET_HTTP_HTTP_AUTH_CACHE_H_ | 181 #endif // NET_HTTP_HTTP_AUTH_CACHE_H_ |
| OLD | NEW |