| 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 "content/browser/net/sqlite_persistent_cookie_store.h" | 5 #include "content/browser/net/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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 330   ASSERT_EQ(cookies_loaded.find("www.bbb.com") != cookies_loaded.end(), true); | 330   ASSERT_EQ(cookies_loaded.find("www.bbb.com") != cookies_loaded.end(), true); | 
| 331   STLDeleteElements(&cookies_); | 331   STLDeleteElements(&cookies_); | 
| 332 } | 332 } | 
| 333 | 333 | 
| 334 // Test that we can force the database to be written by calling Flush(). | 334 // Test that we can force the database to be written by calling Flush(). | 
| 335 TEST_F(SQLitePersistentCookieStoreTest, TestFlush) { | 335 TEST_F(SQLitePersistentCookieStoreTest, TestFlush) { | 
| 336   InitializeStore(false, false); | 336   InitializeStore(false, false); | 
| 337   // File timestamps don't work well on all platforms, so we'll determine | 337   // File timestamps don't work well on all platforms, so we'll determine | 
| 338   // whether the DB file has been modified by checking its size. | 338   // whether the DB file has been modified by checking its size. | 
| 339   base::FilePath path = temp_dir_.path().Append(kCookieFilename); | 339   base::FilePath path = temp_dir_.path().Append(kCookieFilename); | 
| 340   base::PlatformFileInfo info; | 340   base::File::Info info; | 
| 341   ASSERT_TRUE(base::GetFileInfo(path, &info)); | 341   ASSERT_TRUE(base::GetFileInfo(path, &info)); | 
| 342   int64 base_size = info.size; | 342   int64 base_size = info.size; | 
| 343 | 343 | 
| 344   // Write some large cookies, so the DB will have to expand by several KB. | 344   // Write some large cookies, so the DB will have to expand by several KB. | 
| 345   for (char c = 'a'; c < 'z'; ++c) { | 345   for (char c = 'a'; c < 'z'; ++c) { | 
| 346     // Each cookie needs a unique timestamp for creation_utc (see DB schema). | 346     // Each cookie needs a unique timestamp for creation_utc (see DB schema). | 
| 347     base::Time t = base::Time::Now() + base::TimeDelta::FromMicroseconds(c); | 347     base::Time t = base::Time::Now() + base::TimeDelta::FromMicroseconds(c); | 
| 348     std::string name(1, c); | 348     std::string name(1, c); | 
| 349     std::string value(1000, c); | 349     std::string value(1000, c); | 
| 350     AddCookie(name, value, "foo.bar", "/", t); | 350     AddCookie(name, value, "foo.bar", "/", t); | 
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 598   EXPECT_EQ(2, resultcount); | 598   EXPECT_EQ(2, resultcount); | 
| 599 | 599 | 
| 600   // Verify that "encrypted_value" is NOT visible in the file. | 600   // Verify that "encrypted_value" is NOT visible in the file. | 
| 601   contents = ReadRawDBContents(); | 601   contents = ReadRawDBContents(); | 
| 602   EXPECT_NE(0U, contents.length()); | 602   EXPECT_NE(0U, contents.length()); | 
| 603   EXPECT_EQ(contents.find("encrypted_value123XYZ"), std::string::npos); | 603   EXPECT_EQ(contents.find("encrypted_value123XYZ"), std::string::npos); | 
| 604   EXPECT_EQ(contents.find("something456ABC"), std::string::npos); | 604   EXPECT_EQ(contents.find("something456ABC"), std::string::npos); | 
| 605 } | 605 } | 
| 606 | 606 | 
| 607 }  // namespace content | 607 }  // namespace content | 
| OLD | NEW | 
|---|