| 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 "content/browser/net/quota_policy_cookie_store.h" | 5 #include "content/browser/net/quota_policy_cookie_store.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
| 8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 store_ = new QuotaPolicyCookieStore(sqlite_store.get(), storage_policy); | 89 store_ = new QuotaPolicyCookieStore(sqlite_store.get(), storage_policy); |
| 90 Load(cookies); | 90 Load(cookies); |
| 91 } | 91 } |
| 92 | 92 |
| 93 // Adds a persistent cookie to store_. | 93 // Adds a persistent cookie to store_. |
| 94 void AddCookie(const std::string& name, | 94 void AddCookie(const std::string& name, |
| 95 const std::string& value, | 95 const std::string& value, |
| 96 const std::string& domain, | 96 const std::string& domain, |
| 97 const std::string& path, | 97 const std::string& path, |
| 98 const base::Time& creation) { | 98 const base::Time& creation) { |
| 99 store_->AddCookie(*net::CanonicalCookie::Create( | 99 store_->AddCookie(net::CanonicalCookie(name, value, domain, path, creation, |
| 100 name, value, domain, path, creation, creation, base::Time(), false, | 100 creation, base::Time(), false, false, |
| 101 false, net::CookieSameSite::DEFAULT_MODE, | 101 net::CookieSameSite::DEFAULT_MODE, |
| 102 net::COOKIE_PRIORITY_DEFAULT)); | 102 net::COOKIE_PRIORITY_DEFAULT)); |
| 103 } | 103 } |
| 104 | 104 |
| 105 void DestroyStore() { | 105 void DestroyStore() { |
| 106 store_ = nullptr; | 106 store_ = nullptr; |
| 107 // Ensure that |store_|'s destructor has run by shutting down the pool and | 107 // Ensure that |store_|'s destructor has run by shutting down the pool and |
| 108 // then forcing the pool to be destructed. This will ensure that all the | 108 // then forcing the pool to be destructed. This will ensure that all the |
| 109 // tasks that block pool shutdown (e.g. |store_|'s cleanup) have run before | 109 // tasks that block pool shutdown (e.g. |store_|'s cleanup) have run before |
| 110 // yielding control. | 110 // yielding control. |
| 111 pool_owner_->pool()->FlushForTesting(); | 111 pool_owner_->pool()->FlushForTesting(); |
| 112 pool_owner_.reset(new base::SequencedWorkerPoolOwner(3, "Background Pool")); | 112 pool_owner_.reset(new base::SequencedWorkerPoolOwner(3, "Background Pool")); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 // Reload and test for persistence. | 280 // Reload and test for persistence. |
| 281 cookies.clear(); | 281 cookies.clear(); |
| 282 CreateAndLoad(storage_policy.get(), &cookies); | 282 CreateAndLoad(storage_policy.get(), &cookies); |
| 283 EXPECT_EQ(0U, cookies.size()); | 283 EXPECT_EQ(0U, cookies.size()); |
| 284 | 284 |
| 285 cookies.clear(); | 285 cookies.clear(); |
| 286 } | 286 } |
| 287 | 287 |
| 288 } // namespace | 288 } // namespace |
| 289 } // namespace content | 289 } // namespace content |
| OLD | NEW |