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_DEFAULT_CHANNEL_ID_STORE_H_ | 5 #ifndef NET_SSL_DEFAULT_CHANNEL_ID_STORE_H_ |
6 #define NET_SSL_DEFAULT_CHANNEL_ID_STORE_H_ | 6 #define NET_SSL_DEFAULT_CHANNEL_ID_STORE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 } | 86 } |
87 initialized_ = true; | 87 initialized_ = true; |
88 } | 88 } |
89 } | 89 } |
90 | 90 |
91 // Initializes the backing store and reads existing certs from it. | 91 // Initializes the backing store and reads existing certs from it. |
92 // Should only be called by InitIfNecessary(). | 92 // Should only be called by InitIfNecessary(). |
93 void InitStore(); | 93 void InitStore(); |
94 | 94 |
95 // Callback for backing store loading completion. | 95 // Callback for backing store loading completion. |
96 void OnLoaded(scoped_ptr<ScopedVector<ChannelID> > certs); | 96 void OnLoaded(scoped_ptr<std::vector<scoped_ptr<ChannelID>>> certs); |
97 | 97 |
98 // Syncronous methods which do the actual work. Can only be called after | 98 // Syncronous methods which do the actual work. Can only be called after |
99 // initialization is complete. | 99 // initialization is complete. |
100 void SyncSetChannelID(scoped_ptr<ChannelID> channel_id); | 100 void SyncSetChannelID(scoped_ptr<ChannelID> channel_id); |
101 void SyncDeleteChannelID(const std::string& server_identifier); | 101 void SyncDeleteChannelID(const std::string& server_identifier); |
102 void SyncDeleteAllCreatedBetween(base::Time delete_begin, | 102 void SyncDeleteAllCreatedBetween(base::Time delete_begin, |
103 base::Time delete_end); | 103 base::Time delete_end); |
104 void SyncGetAllChannelIDs(ChannelIDList* channel_id_list); | 104 void SyncGetAllChannelIDs(ChannelIDList* channel_id_list); |
105 | 105 |
106 // Add |task| to |waiting_tasks_|. | 106 // Add |task| to |waiting_tasks_|. |
(...skipping 13 matching lines...) Expand all Loading... |
120 | 120 |
121 // Indicates whether the channel id store has been initialized. This happens | 121 // Indicates whether the channel id store has been initialized. This happens |
122 // lazily in InitIfNecessary(). | 122 // lazily in InitIfNecessary(). |
123 bool initialized_; | 123 bool initialized_; |
124 | 124 |
125 // Indicates whether loading from the backend store is completed and | 125 // Indicates whether loading from the backend store is completed and |
126 // calls may be immediately processed. | 126 // calls may be immediately processed. |
127 bool loaded_; | 127 bool loaded_; |
128 | 128 |
129 // Tasks that are waiting to be run once we finish loading. | 129 // Tasks that are waiting to be run once we finish loading. |
130 ScopedVector<Task> waiting_tasks_; | 130 std::vector<scoped_ptr<Task>> waiting_tasks_; |
131 base::TimeTicks waiting_tasks_start_time_; | 131 base::TimeTicks waiting_tasks_start_time_; |
132 | 132 |
133 scoped_refptr<PersistentStore> store_; | 133 scoped_refptr<PersistentStore> store_; |
134 | 134 |
135 ChannelIDMap channel_ids_; | 135 ChannelIDMap channel_ids_; |
136 | 136 |
137 base::WeakPtrFactory<DefaultChannelIDStore> weak_ptr_factory_; | 137 base::WeakPtrFactory<DefaultChannelIDStore> weak_ptr_factory_; |
138 | 138 |
139 DISALLOW_COPY_AND_ASSIGN(DefaultChannelIDStore); | 139 DISALLOW_COPY_AND_ASSIGN(DefaultChannelIDStore); |
140 }; | 140 }; |
141 | 141 |
142 typedef base::RefCountedThreadSafe<DefaultChannelIDStore::PersistentStore> | 142 typedef base::RefCountedThreadSafe<DefaultChannelIDStore::PersistentStore> |
143 RefcountedPersistentStore; | 143 RefcountedPersistentStore; |
144 | 144 |
145 class NET_EXPORT DefaultChannelIDStore::PersistentStore | 145 class NET_EXPORT DefaultChannelIDStore::PersistentStore |
146 : public RefcountedPersistentStore { | 146 : public RefcountedPersistentStore { |
147 public: | 147 public: |
148 typedef base::Callback<void(scoped_ptr<ScopedVector<ChannelID> >)> | 148 typedef base::Callback<void(scoped_ptr<std::vector<scoped_ptr<ChannelID>>>)> |
149 LoadedCallback; | 149 LoadedCallback; |
150 | 150 |
151 // Initializes the store and retrieves the existing channel_ids. This will be | 151 // Initializes the store and retrieves the existing channel_ids. This will be |
152 // called only once at startup. Note that the channel_ids are individually | 152 // called only once at startup. Note that the channel_ids are individually |
153 // allocated and that ownership is transferred to the caller upon return. | 153 // allocated and that ownership is transferred to the caller upon return. |
154 // The |loaded_callback| must not be called synchronously. | 154 // The |loaded_callback| must not be called synchronously. |
155 virtual void Load(const LoadedCallback& loaded_callback) = 0; | 155 virtual void Load(const LoadedCallback& loaded_callback) = 0; |
156 | 156 |
157 virtual void AddChannelID(const ChannelID& channel_id) = 0; | 157 virtual void AddChannelID(const ChannelID& channel_id) = 0; |
158 | 158 |
159 virtual void DeleteChannelID(const ChannelID& channel_id) = 0; | 159 virtual void DeleteChannelID(const ChannelID& channel_id) = 0; |
160 | 160 |
161 // When invoked, instructs the store to keep session related data on | 161 // When invoked, instructs the store to keep session related data on |
162 // destruction. | 162 // destruction. |
163 virtual void SetForceKeepSessionState() = 0; | 163 virtual void SetForceKeepSessionState() = 0; |
164 | 164 |
165 protected: | 165 protected: |
166 friend class base::RefCountedThreadSafe<PersistentStore>; | 166 friend class base::RefCountedThreadSafe<PersistentStore>; |
167 | 167 |
168 PersistentStore(); | 168 PersistentStore(); |
169 virtual ~PersistentStore(); | 169 virtual ~PersistentStore(); |
170 | 170 |
171 private: | 171 private: |
172 DISALLOW_COPY_AND_ASSIGN(PersistentStore); | 172 DISALLOW_COPY_AND_ASSIGN(PersistentStore); |
173 }; | 173 }; |
174 | 174 |
175 } // namespace net | 175 } // namespace net |
176 | 176 |
177 #endif // NET_SSL_DEFAULT_CHANNEL_ID_STORE_H_ | 177 #endif // NET_SSL_DEFAULT_CHANNEL_ID_STORE_H_ |
OLD | NEW |