| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
| 7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 // making sure it loads successfully. This ensures that all pending commits | 148 // making sure it loads successfully. This ensures that all pending commits |
| 149 // are made to the store before allowing it to be closed. | 149 // are made to the store before allowing it to be closed. |
| 150 DestroyStore(); | 150 DestroyStore(); |
| 151 | 151 |
| 152 // Reload and test for persistence. | 152 // Reload and test for persistence. |
| 153 STLDeleteElements(&cookies); | 153 STLDeleteElements(&cookies); |
| 154 CreateAndLoad(nullptr, &cookies); | 154 CreateAndLoad(nullptr, &cookies); |
| 155 EXPECT_EQ(2U, cookies.size()); | 155 EXPECT_EQ(2U, cookies.size()); |
| 156 bool found_foo_cookie = false; | 156 bool found_foo_cookie = false; |
| 157 bool found_persistent_cookie = false; | 157 bool found_persistent_cookie = false; |
| 158 for (const auto& cookie : cookies) { | 158 for (auto* cookie : cookies) { |
| 159 if (cookie->Domain() == "foo.com") | 159 if (cookie->Domain() == "foo.com") |
| 160 found_foo_cookie = true; | 160 found_foo_cookie = true; |
| 161 else if (cookie->Domain() == "persistent.com") | 161 else if (cookie->Domain() == "persistent.com") |
| 162 found_persistent_cookie = true; | 162 found_persistent_cookie = true; |
| 163 } | 163 } |
| 164 EXPECT_TRUE(found_foo_cookie); | 164 EXPECT_TRUE(found_foo_cookie); |
| 165 EXPECT_TRUE(found_persistent_cookie); | 165 EXPECT_TRUE(found_persistent_cookie); |
| 166 | 166 |
| 167 // Now delete the cookies and check persistence again. | 167 // Now delete the cookies and check persistence again. |
| 168 store_->DeleteCookie(*cookies[0]); | 168 store_->DeleteCookie(*cookies[0]); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 AddCookie(GURL("http://nonpersistent.com"), "A", "B", std::string(), | 209 AddCookie(GURL("http://nonpersistent.com"), "A", "B", std::string(), |
| 210 "/second", t); | 210 "/second", t); |
| 211 | 211 |
| 212 // Now close the store, and "nonpersistent.com" should be deleted according to | 212 // Now close the store, and "nonpersistent.com" should be deleted according to |
| 213 // policy. | 213 // policy. |
| 214 DestroyStore(); | 214 DestroyStore(); |
| 215 STLDeleteElements(&cookies); | 215 STLDeleteElements(&cookies); |
| 216 CreateAndLoad(nullptr, &cookies); | 216 CreateAndLoad(nullptr, &cookies); |
| 217 | 217 |
| 218 EXPECT_EQ(2U, cookies.size()); | 218 EXPECT_EQ(2U, cookies.size()); |
| 219 for (const auto& cookie : cookies) { | 219 for (auto* cookie : cookies) { |
| 220 EXPECT_NE("nonpersistent.com", cookie->Domain()); | 220 EXPECT_NE("nonpersistent.com", cookie->Domain()); |
| 221 } | 221 } |
| 222 STLDeleteElements(&cookies); | 222 STLDeleteElements(&cookies); |
| 223 } | 223 } |
| 224 | 224 |
| 225 TEST_F(QuotaPolicyCookieStoreTest, ForceKeepSessionState) { | 225 TEST_F(QuotaPolicyCookieStoreTest, ForceKeepSessionState) { |
| 226 CanonicalCookieVector cookies; | 226 CanonicalCookieVector cookies; |
| 227 CreateAndLoad(nullptr, &cookies); | 227 CreateAndLoad(nullptr, &cookies); |
| 228 ASSERT_EQ(0U, cookies.size()); | 228 ASSERT_EQ(0U, cookies.size()); |
| 229 | 229 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 // Reload and test for persistence. | 284 // Reload and test for persistence. |
| 285 STLDeleteElements(&cookies); | 285 STLDeleteElements(&cookies); |
| 286 CreateAndLoad(storage_policy.get(), &cookies); | 286 CreateAndLoad(storage_policy.get(), &cookies); |
| 287 EXPECT_EQ(0U, cookies.size()); | 287 EXPECT_EQ(0U, cookies.size()); |
| 288 | 288 |
| 289 STLDeleteElements(&cookies); | 289 STLDeleteElements(&cookies); |
| 290 } | 290 } |
| 291 | 291 |
| 292 } // namespace | 292 } // namespace |
| 293 } // namespace content | 293 } // namespace content |
| OLD | NEW |