| 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/cookies/cookie_monster_store_test.h" | 5 #include "net/cookies/cookie_monster_store_test.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 EXPECT_FALSE(pc.HasMaxAge()); | 126 EXPECT_FALSE(pc.HasMaxAge()); |
| 127 EXPECT_TRUE(pc.HasPath()); | 127 EXPECT_TRUE(pc.HasPath()); |
| 128 base::Time cookie_expires = | 128 base::Time cookie_expires = |
| 129 pc.HasExpires() ? cookie_util::ParseCookieExpirationTime(pc.Expires()) | 129 pc.HasExpires() ? cookie_util::ParseCookieExpirationTime(pc.Expires()) |
| 130 : base::Time(); | 130 : base::Time(); |
| 131 std::string cookie_path = pc.Path(); | 131 std::string cookie_path = pc.Path(); |
| 132 | 132 |
| 133 return CanonicalCookie::Create(url, pc.Name(), pc.Value(), url.host(), | 133 return CanonicalCookie::Create(url, pc.Name(), pc.Value(), url.host(), |
| 134 cookie_path, creation_time, cookie_expires, | 134 cookie_path, creation_time, cookie_expires, |
| 135 pc.IsSecure(), pc.IsHttpOnly(), pc.SameSite(), | 135 pc.IsSecure(), pc.IsHttpOnly(), pc.SameSite(), |
| 136 false, pc.Priority()); | 136 pc.Priority()); |
| 137 } | 137 } |
| 138 | 138 |
| 139 void AddCookieToList(const GURL& url, | 139 void AddCookieToList(const GURL& url, |
| 140 const std::string& cookie_line, | 140 const std::string& cookie_line, |
| 141 const base::Time& creation_time, | 141 const base::Time& creation_time, |
| 142 std::vector<std::unique_ptr<CanonicalCookie>>* out_list) { | 142 std::vector<std::unique_ptr<CanonicalCookie>>* out_list) { |
| 143 std::unique_ptr<CanonicalCookie> cookie( | 143 std::unique_ptr<CanonicalCookie> cookie( |
| 144 BuildCanonicalCookie(url, cookie_line, creation_time)); | 144 BuildCanonicalCookie(url, cookie_line, creation_time)); |
| 145 | 145 |
| 146 out_list->push_back(std::move(cookie)); | 146 out_list->push_back(std::move(cookie)); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 secure = false; | 228 secure = false; |
| 229 } | 229 } |
| 230 base::Time creation_time = | 230 base::Time creation_time = |
| 231 past_creation + base::TimeDelta::FromMicroseconds(i); | 231 past_creation + base::TimeDelta::FromMicroseconds(i); |
| 232 base::Time expiration_time = current + base::TimeDelta::FromDays(30); | 232 base::Time expiration_time = current + base::TimeDelta::FromDays(30); |
| 233 base::Time last_access_time = | 233 base::Time last_access_time = |
| 234 ((i - base) < num_old_cookies) | 234 ((i - base) < num_old_cookies) |
| 235 ? current - base::TimeDelta::FromDays(days_old) | 235 ? current - base::TimeDelta::FromDays(days_old) |
| 236 : current; | 236 : current; |
| 237 | 237 |
| 238 // The URL must be HTTPS since |secure| can be true or false, and because |
| 239 // strict secure cookies are enforced, the cookie will fail to be created if |
| 240 // |secure| is true but the URL is an insecure scheme. |
| 238 std::unique_ptr<CanonicalCookie> cc(CanonicalCookie::Create( | 241 std::unique_ptr<CanonicalCookie> cc(CanonicalCookie::Create( |
| 239 GURL(base::StringPrintf("http://h%05d.izzle/", i)), "a", "1", | 242 GURL(base::StringPrintf("https://h%05d.izzle/", i)), "a", "1", |
| 240 std::string(), "/path", creation_time, expiration_time, secure, false, | 243 std::string(), "/path", creation_time, expiration_time, secure, false, |
| 241 CookieSameSite::DEFAULT_MODE, false, COOKIE_PRIORITY_DEFAULT)); | 244 CookieSameSite::DEFAULT_MODE, COOKIE_PRIORITY_DEFAULT)); |
| 242 cc->SetLastAccessDate(last_access_time); | 245 cc->SetLastAccessDate(last_access_time); |
| 243 store->AddCookie(*cc); | 246 store->AddCookie(*cc); |
| 244 } | 247 } |
| 245 | 248 |
| 246 return base::MakeUnique<CookieMonster>(store.get(), nullptr); | 249 return base::MakeUnique<CookieMonster>(store.get(), nullptr); |
| 247 } | 250 } |
| 248 | 251 |
| 249 MockSimplePersistentCookieStore::~MockSimplePersistentCookieStore() { | 252 MockSimplePersistentCookieStore::~MockSimplePersistentCookieStore() { |
| 250 } | 253 } |
| 251 | 254 |
| 252 } // namespace net | 255 } // namespace net |
| OLD | NEW |