Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(682)

Side by Side Diff: net/ssl/ssl_client_session_cache_openssl.h

Issue 1893083002: Change scoped_ptr to std::unique_ptr in //net. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptr-net-all: iwyu Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/ssl/openssl_ssl_util.cc ('k') | net/ssl/ssl_client_session_cache_openssl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_SSL_SSL_CLIENT_SESSION_CACHE_OPENSSL_H 5 #ifndef NET_SSL_SSL_CLIENT_SESSION_CACHE_OPENSSL_H
6 #define NET_SSL_SSL_CLIENT_SESSION_CACHE_OPENSSL_H 6 #define NET_SSL_SSL_CLIENT_SESSION_CACHE_OPENSSL_H
7 7
8 #include <openssl/ssl.h> 8 #include <openssl/ssl.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 10
11 #include <memory>
11 #include <string> 12 #include <string>
12 13
13 #include "base/containers/mru_cache.h" 14 #include "base/containers/mru_cache.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/synchronization/lock.h" 16 #include "base/synchronization/lock.h"
17 #include "base/threading/thread_checker.h" 17 #include "base/threading/thread_checker.h"
18 #include "base/time/time.h" 18 #include "base/time/time.h"
19 #include "net/base/net_export.h" 19 #include "net/base/net_export.h"
20 #include "net/ssl/scoped_openssl_types.h" 20 #include "net/ssl/scoped_openssl_types.h"
21 21
22 namespace base { 22 namespace base {
23 class Clock; 23 class Clock;
24 } 24 }
25 25
(...skipping 20 matching lines...) Expand all
46 ScopedSSL_SESSION Lookup(const std::string& cache_key); 46 ScopedSSL_SESSION Lookup(const std::string& cache_key);
47 47
48 // Inserts |session| into the cache at |cache_key|. If there is an existing 48 // Inserts |session| into the cache at |cache_key|. If there is an existing
49 // one, it is released. Every |expiration_check_count| calls, the cache is 49 // one, it is released. Every |expiration_check_count| calls, the cache is
50 // checked for stale entries. 50 // checked for stale entries.
51 void Insert(const std::string& cache_key, SSL_SESSION* session); 51 void Insert(const std::string& cache_key, SSL_SESSION* session);
52 52
53 // Removes all entries from the cache. 53 // Removes all entries from the cache.
54 void Flush(); 54 void Flush();
55 55
56 void SetClockForTesting(scoped_ptr<base::Clock> clock); 56 void SetClockForTesting(std::unique_ptr<base::Clock> clock);
57 57
58 private: 58 private:
59 struct CacheEntry { 59 struct CacheEntry {
60 CacheEntry(); 60 CacheEntry();
61 ~CacheEntry(); 61 ~CacheEntry();
62 62
63 ScopedSSL_SESSION session; 63 ScopedSSL_SESSION session;
64 // The time at which this entry was created. 64 // The time at which this entry was created.
65 base::Time creation_time; 65 base::Time creation_time;
66 }; 66 };
67 67
68 using CacheEntryMap = 68 using CacheEntryMap =
69 base::HashingMRUCache<std::string, scoped_ptr<CacheEntry>>; 69 base::HashingMRUCache<std::string, std::unique_ptr<CacheEntry>>;
70 70
71 // Returns true if |entry| is expired as of |now|. 71 // Returns true if |entry| is expired as of |now|.
72 bool IsExpired(CacheEntry* entry, const base::Time& now); 72 bool IsExpired(CacheEntry* entry, const base::Time& now);
73 73
74 // Removes all expired sessions from the cache. 74 // Removes all expired sessions from the cache.
75 void FlushExpiredSessions(); 75 void FlushExpiredSessions();
76 76
77 scoped_ptr<base::Clock> clock_; 77 std::unique_ptr<base::Clock> clock_;
78 Config config_; 78 Config config_;
79 CacheEntryMap cache_; 79 CacheEntryMap cache_;
80 size_t lookups_since_flush_; 80 size_t lookups_since_flush_;
81 81
82 // TODO(davidben): After https://crbug.com/458365 is fixed, replace this with 82 // TODO(davidben): After https://crbug.com/458365 is fixed, replace this with
83 // a ThreadChecker. The session cache should be single-threaded like other 83 // a ThreadChecker. The session cache should be single-threaded like other
84 // classes in net. 84 // classes in net.
85 base::Lock lock_; 85 base::Lock lock_;
86 86
87 DISALLOW_COPY_AND_ASSIGN(SSLClientSessionCacheOpenSSL); 87 DISALLOW_COPY_AND_ASSIGN(SSLClientSessionCacheOpenSSL);
88 }; 88 };
89 89
90 } // namespace net 90 } // namespace net
91 91
92 #endif // NET_SSL_SSL_CLIENT_SESSION_CACHE_OPENSSL_H 92 #endif // NET_SSL_SSL_CLIENT_SESSION_CACHE_OPENSSL_H
OLDNEW
« no previous file with comments | « net/ssl/openssl_ssl_util.cc ('k') | net/ssl/ssl_client_session_cache_openssl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698