| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_CHANNEL_ID_STORE_H_ | 5 #ifndef NET_SSL_CHANNEL_ID_STORE_H_ |
| 6 #define NET_SSL_CHANNEL_ID_STORE_H_ | 6 #define NET_SSL_CHANNEL_ID_STORE_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/threading/non_thread_safe.h" | 13 #include "base/sequence_checker.h" |
| 14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 15 #include "crypto/ec_private_key.h" | 15 #include "crypto/ec_private_key.h" |
| 16 #include "net/base/net_export.h" | 16 #include "net/base/net_export.h" |
| 17 | 17 |
| 18 namespace net { | 18 namespace net { |
| 19 | 19 |
| 20 // An interface for storing and retrieving channel ID keypairs. | 20 // An interface for storing and retrieving channel ID keypairs. |
| 21 // See https://tools.ietf.org/html/draft-balfanz-tls-channelid-01 | 21 // See https://tools.ietf.org/html/draft-balfanz-tls-channelid-01 |
| 22 | 22 |
| 23 // Owned only by a single ChannelIDService object, which is responsible | 23 // Owned only by a single ChannelIDService object, which is responsible |
| 24 // for deleting it. | 24 // for deleting it. |
| 25 class NET_EXPORT ChannelIDStore | 25 class NET_EXPORT ChannelIDStore { |
| 26 : NON_EXPORTED_BASE(public base::NonThreadSafe) { | |
| 27 public: | 26 public: |
| 28 // The ChannelID class contains a keypair, along with the corresponding | 27 // The ChannelID class contains a keypair, along with the corresponding |
| 29 // hostname (server identifier) and creation time. | 28 // hostname (server identifier) and creation time. |
| 30 class NET_EXPORT ChannelID { | 29 class NET_EXPORT ChannelID { |
| 31 public: | 30 public: |
| 32 ChannelID(); | 31 ChannelID(); |
| 33 ChannelID(const std::string& server_identifier, | 32 ChannelID(const std::string& server_identifier, |
| 34 base::Time creation_time, | 33 base::Time creation_time, |
| 35 std::unique_ptr<crypto::ECPrivateKey> key); | 34 std::unique_ptr<crypto::ECPrivateKey> key); |
| 36 ChannelID(const ChannelID& other); | 35 ChannelID(const ChannelID& other); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 52 std::unique_ptr<crypto::ECPrivateKey> key_; | 51 std::unique_ptr<crypto::ECPrivateKey> key_; |
| 53 }; | 52 }; |
| 54 | 53 |
| 55 typedef std::list<ChannelID> ChannelIDList; | 54 typedef std::list<ChannelID> ChannelIDList; |
| 56 | 55 |
| 57 typedef base::Callback< | 56 typedef base::Callback< |
| 58 void(int, const std::string&, std::unique_ptr<crypto::ECPrivateKey>)> | 57 void(int, const std::string&, std::unique_ptr<crypto::ECPrivateKey>)> |
| 59 GetChannelIDCallback; | 58 GetChannelIDCallback; |
| 60 typedef base::Callback<void(const ChannelIDList&)> GetChannelIDListCallback; | 59 typedef base::Callback<void(const ChannelIDList&)> GetChannelIDListCallback; |
| 61 | 60 |
| 62 virtual ~ChannelIDStore() {} | 61 virtual ~ChannelIDStore(); |
| 63 | 62 |
| 64 // GetChannelID may return the result synchronously through the | 63 // GetChannelID may return the result synchronously through the |
| 65 // output parameters, in which case it will return either OK if a keypair is | 64 // output parameters, in which case it will return either OK if a keypair is |
| 66 // found in the store, or ERR_FILE_NOT_FOUND if none is found. If the | 65 // found in the store, or ERR_FILE_NOT_FOUND if none is found. If the |
| 67 // result cannot be returned synchronously, GetChannelID will | 66 // result cannot be returned synchronously, GetChannelID will |
| 68 // return ERR_IO_PENDING and the callback will be called with the result | 67 // return ERR_IO_PENDING and the callback will be called with the result |
| 69 // asynchronously. | 68 // asynchronously. |
| 70 virtual int GetChannelID(const std::string& server_identifier, | 69 virtual int GetChannelID(const std::string& server_identifier, |
| 71 std::unique_ptr<crypto::ECPrivateKey>* key_result, | 70 std::unique_ptr<crypto::ECPrivateKey>* key_result, |
| 72 const GetChannelIDCallback& callback) = 0; | 71 const GetChannelIDCallback& callback) = 0; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 // Public only for unit testing. | 105 // Public only for unit testing. |
| 107 virtual int GetChannelIDCount() = 0; | 106 virtual int GetChannelIDCount() = 0; |
| 108 | 107 |
| 109 // When invoked, instructs the store to keep session related data on | 108 // When invoked, instructs the store to keep session related data on |
| 110 // destruction. | 109 // destruction. |
| 111 virtual void SetForceKeepSessionState() = 0; | 110 virtual void SetForceKeepSessionState() = 0; |
| 112 | 111 |
| 113 // Returns true if this ChannelIDStore is ephemeral, and false if it is | 112 // Returns true if this ChannelIDStore is ephemeral, and false if it is |
| 114 // persistent. | 113 // persistent. |
| 115 virtual bool IsEphemeral() = 0; | 114 virtual bool IsEphemeral() = 0; |
| 115 |
| 116 protected: |
| 117 SEQUENCE_CHECKER(sequence_checker_); |
| 116 }; | 118 }; |
| 117 | 119 |
| 118 } // namespace net | 120 } // namespace net |
| 119 | 121 |
| 120 #endif // NET_SSL_CHANNEL_ID_STORE_H_ | 122 #endif // NET_SSL_CHANNEL_ID_STORE_H_ |
| OLD | NEW |