| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extras/sqlite/sqlite_persistent_cookie_store.h" | 5 #include "net/extras/sqlite/sqlite_persistent_cookie_store.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 CookieCryptor(); | 41 CookieCryptor(); |
| 42 bool ShouldEncrypt() override; | 42 bool ShouldEncrypt() override; |
| 43 bool EncryptString(const std::string& plaintext, | 43 bool EncryptString(const std::string& plaintext, |
| 44 std::string* ciphertext) override; | 44 std::string* ciphertext) override; |
| 45 bool DecryptString(const std::string& ciphertext, | 45 bool DecryptString(const std::string& ciphertext, |
| 46 std::string* plaintext) override; | 46 std::string* plaintext) override; |
| 47 | 47 |
| 48 bool should_encrypt_; | 48 bool should_encrypt_; |
| 49 | 49 |
| 50 private: | 50 private: |
| 51 scoped_ptr<crypto::SymmetricKey> key_; | 51 std::unique_ptr<crypto::SymmetricKey> key_; |
| 52 crypto::Encryptor encryptor_; | 52 crypto::Encryptor encryptor_; |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 CookieCryptor::CookieCryptor() | 55 CookieCryptor::CookieCryptor() |
| 56 : should_encrypt_(true), | 56 : should_encrypt_(true), |
| 57 key_( | 57 key_( |
| 58 crypto::SymmetricKey::DeriveKeyFromPassword(crypto::SymmetricKey::AES, | 58 crypto::SymmetricKey::DeriveKeyFromPassword(crypto::SymmetricKey::AES, |
| 59 "password", | 59 "password", |
| 60 "saltiest", | 60 "saltiest", |
| 61 1000, | 61 1000, |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 return contents; | 192 return contents; |
| 193 } | 193 } |
| 194 | 194 |
| 195 void SetUp() override { ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); } | 195 void SetUp() override { ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); } |
| 196 | 196 |
| 197 void TearDown() override { | 197 void TearDown() override { |
| 198 DestroyStore(); | 198 DestroyStore(); |
| 199 } | 199 } |
| 200 | 200 |
| 201 protected: | 201 protected: |
| 202 scoped_ptr<base::SequencedWorkerPoolOwner> pool_owner_; | 202 std::unique_ptr<base::SequencedWorkerPoolOwner> pool_owner_; |
| 203 base::WaitableEvent loaded_event_; | 203 base::WaitableEvent loaded_event_; |
| 204 base::WaitableEvent key_loaded_event_; | 204 base::WaitableEvent key_loaded_event_; |
| 205 base::WaitableEvent db_thread_event_; | 205 base::WaitableEvent db_thread_event_; |
| 206 CanonicalCookieVector cookies_; | 206 CanonicalCookieVector cookies_; |
| 207 base::ScopedTempDir temp_dir_; | 207 base::ScopedTempDir temp_dir_; |
| 208 scoped_refptr<SQLitePersistentCookieStore> store_; | 208 scoped_refptr<SQLitePersistentCookieStore> store_; |
| 209 scoped_ptr<CookieCryptor> cookie_crypto_delegate_; | 209 std::unique_ptr<CookieCryptor> cookie_crypto_delegate_; |
| 210 }; | 210 }; |
| 211 | 211 |
| 212 TEST_F(SQLitePersistentCookieStoreTest, TestInvalidMetaTableRecovery) { | 212 TEST_F(SQLitePersistentCookieStoreTest, TestInvalidMetaTableRecovery) { |
| 213 InitializeStore(false, false); | 213 InitializeStore(false, false); |
| 214 AddCookie("A", "B", "foo.bar", "/", base::Time::Now()); | 214 AddCookie("A", "B", "foo.bar", "/", base::Time::Now()); |
| 215 DestroyStore(); | 215 DestroyStore(); |
| 216 | 216 |
| 217 // Load up the store and verify that it has good data in it. | 217 // Load up the store and verify that it has good data in it. |
| 218 CanonicalCookieVector cookies; | 218 CanonicalCookieVector cookies; |
| 219 CreateAndLoad(false, false, &cookies); | 219 CreateAndLoad(false, false, &cookies); |
| (...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 804 EXPECT_TRUE(was_called_with_no_cookies); | 804 EXPECT_TRUE(was_called_with_no_cookies); |
| 805 | 805 |
| 806 // Same with trying to load a specific cookie. | 806 // Same with trying to load a specific cookie. |
| 807 was_called_with_no_cookies = false; | 807 was_called_with_no_cookies = false; |
| 808 store_->LoadCookiesForKey("foo.bar", base::Bind(WasCalledWithNoCookies, | 808 store_->LoadCookiesForKey("foo.bar", base::Bind(WasCalledWithNoCookies, |
| 809 &was_called_with_no_cookies)); | 809 &was_called_with_no_cookies)); |
| 810 EXPECT_TRUE(was_called_with_no_cookies); | 810 EXPECT_TRUE(was_called_with_no_cookies); |
| 811 } | 811 } |
| 812 | 812 |
| 813 } // namespace net | 813 } // namespace net |
| OLD | NEW |