| 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 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 } | 412 } |
| 413 | 413 |
| 414 // Test that we can force the database to be written by calling Flush(). | 414 // Test that we can force the database to be written by calling Flush(). |
| 415 TEST_F(SQLitePersistentCookieStoreTest, TestFlush) { | 415 TEST_F(SQLitePersistentCookieStoreTest, TestFlush) { |
| 416 InitializeStore(false, false); | 416 InitializeStore(false, false); |
| 417 // File timestamps don't work well on all platforms, so we'll determine | 417 // File timestamps don't work well on all platforms, so we'll determine |
| 418 // whether the DB file has been modified by checking its size. | 418 // whether the DB file has been modified by checking its size. |
| 419 base::FilePath path = temp_dir_.path().Append(kCookieFilename); | 419 base::FilePath path = temp_dir_.path().Append(kCookieFilename); |
| 420 base::File::Info info; | 420 base::File::Info info; |
| 421 ASSERT_TRUE(base::GetFileInfo(path, &info)); | 421 ASSERT_TRUE(base::GetFileInfo(path, &info)); |
| 422 int64 base_size = info.size; | 422 int64_t base_size = info.size; |
| 423 | 423 |
| 424 // Write some large cookies, so the DB will have to expand by several KB. | 424 // Write some large cookies, so the DB will have to expand by several KB. |
| 425 for (char c = 'a'; c < 'z'; ++c) { | 425 for (char c = 'a'; c < 'z'; ++c) { |
| 426 // Each cookie needs a unique timestamp for creation_utc (see DB schema). | 426 // Each cookie needs a unique timestamp for creation_utc (see DB schema). |
| 427 base::Time t = base::Time::Now() + base::TimeDelta::FromMicroseconds(c); | 427 base::Time t = base::Time::Now() + base::TimeDelta::FromMicroseconds(c); |
| 428 std::string name(1, c); | 428 std::string name(1, c); |
| 429 std::string value(1000, c); | 429 std::string value(1000, c); |
| 430 AddCookie(name, value, "foo.bar", "/", t); | 430 AddCookie(name, value, "foo.bar", "/", t); |
| 431 } | 431 } |
| 432 | 432 |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 EXPECT_TRUE(was_called_with_no_cookies); | 746 EXPECT_TRUE(was_called_with_no_cookies); |
| 747 | 747 |
| 748 // Same with trying to load a specific cookie. | 748 // Same with trying to load a specific cookie. |
| 749 was_called_with_no_cookies = false; | 749 was_called_with_no_cookies = false; |
| 750 store_->LoadCookiesForKey("foo.bar", base::Bind(WasCalledWithNoCookies, | 750 store_->LoadCookiesForKey("foo.bar", base::Bind(WasCalledWithNoCookies, |
| 751 &was_called_with_no_cookies)); | 751 &was_called_with_no_cookies)); |
| 752 EXPECT_TRUE(was_called_with_no_cookies); | 752 EXPECT_TRUE(was_called_with_no_cookies); |
| 753 } | 753 } |
| 754 | 754 |
| 755 } // namespace net | 755 } // namespace net |
| OLD | NEW |