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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 // This helper is simplistic in interpreting a parsed cookie, in order to | 123 // This helper is simplistic in interpreting a parsed cookie, in order to |
124 // avoid duplicated CookieMonster's CanonPath() and CanonExpiration() | 124 // avoid duplicated CookieMonster's CanonPath() and CanonExpiration() |
125 // functions. Would be nice to export them, and re-use here. | 125 // functions. Would be nice to export them, and re-use here. |
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(pc.Name(), pc.Value(), "." + url.host(), | 133 return base::MakeUnique<CanonicalCookie>( |
134 cookie_path, creation_time, cookie_expires, | 134 pc.Name(), pc.Value(), "." + url.host(), cookie_path, creation_time, |
135 base::Time(), pc.IsSecure(), pc.IsHttpOnly(), | 135 cookie_expires, base::Time(), pc.IsSecure(), pc.IsHttpOnly(), |
136 pc.SameSite(), pc.Priority()); | 136 pc.SameSite(), 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 | 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 | 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. | 240 // |secure| is true but the URL is an insecure scheme. |
241 std::unique_ptr<CanonicalCookie> cc(CanonicalCookie::Create( | 241 std::unique_ptr<CanonicalCookie> cc(base::MakeUnique<CanonicalCookie>( |
242 "a", "1", base::StringPrintf("h%05d.izzle", i), "/path", creation_time, | 242 "a", "1", base::StringPrintf("h%05d.izzle", i), "/path", creation_time, |
243 expiration_time, base::Time(), secure, false, | 243 expiration_time, base::Time(), secure, false, |
244 CookieSameSite::DEFAULT_MODE, COOKIE_PRIORITY_DEFAULT)); | 244 CookieSameSite::DEFAULT_MODE, COOKIE_PRIORITY_DEFAULT)); |
245 cc->SetLastAccessDate(last_access_time); | 245 cc->SetLastAccessDate(last_access_time); |
246 store->AddCookie(*cc); | 246 store->AddCookie(*cc); |
247 } | 247 } |
248 | 248 |
249 return base::MakeUnique<CookieMonster>(store.get(), nullptr); | 249 return base::MakeUnique<CookieMonster>(store.get(), nullptr); |
250 } | 250 } |
251 | 251 |
252 MockSimplePersistentCookieStore::~MockSimplePersistentCookieStore() { | 252 MockSimplePersistentCookieStore::~MockSimplePersistentCookieStore() { |
253 } | 253 } |
254 | 254 |
255 } // namespace net | 255 } // namespace net |
OLD | NEW |