| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "net/socket/ssl_session_cache_openssl.h" | 5 #include "net/socket/ssl_session_cache_openssl.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include <openssl/rand.h> | 10 #include <openssl/rand.h> |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 unsigned id_len; | 80 unsigned id_len; |
| 81 size_t hash; | 81 size_t hash; |
| 82 | 82 |
| 83 private: | 83 private: |
| 84 // Session ID are random strings of bytes. This happens to compute the same | 84 // Session ID are random strings of bytes. This happens to compute the same |
| 85 // value as std::hash<std::string> without the extra string copy. See | 85 // value as std::hash<std::string> without the extra string copy. See |
| 86 // base/containers/hash_tables.h. Other hashing computations are possible, | 86 // base/containers/hash_tables.h. Other hashing computations are possible, |
| 87 // this one is just simple enough to do the job. | 87 // this one is just simple enough to do the job. |
| 88 size_t ComputeHash(const unsigned char* id, unsigned id_len) { | 88 size_t ComputeHash(const unsigned char* id, unsigned id_len) { |
| 89 size_t result = 0; | 89 size_t result = 0; |
| 90 for (unsigned n = 0; n < id_len; ++n) | 90 for (unsigned n = 0; n < id_len; ++n) { |
| 91 result += 131 * id[n]; | 91 result = (result * 131) + id[n]; |
| 92 } |
| 92 return result; | 93 return result; |
| 93 } | 94 } |
| 94 }; | 95 }; |
| 95 | 96 |
| 96 } // namespace | 97 } // namespace |
| 97 | 98 |
| 98 } // namespace net | 99 } // namespace net |
| 99 | 100 |
| 100 namespace BASE_HASH_NAMESPACE { | 101 namespace BASE_HASH_NAMESPACE { |
| 101 | 102 |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 return impl_->SSLSessionIsInCache(cache_key); | 521 return impl_->SSLSessionIsInCache(cache_key); |
| 521 } | 522 } |
| 522 | 523 |
| 523 void SSLSessionCacheOpenSSL::MarkSSLSessionAsGood(SSL* ssl) { | 524 void SSLSessionCacheOpenSSL::MarkSSLSessionAsGood(SSL* ssl) { |
| 524 return impl_->MarkSSLSessionAsGood(ssl); | 525 return impl_->MarkSSLSessionAsGood(ssl); |
| 525 } | 526 } |
| 526 | 527 |
| 527 void SSLSessionCacheOpenSSL::Flush() { impl_->Flush(); } | 528 void SSLSessionCacheOpenSSL::Flush() { impl_->Flush(); } |
| 528 | 529 |
| 529 } // namespace net | 530 } // namespace net |
| OLD | NEW |