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 // This file contains test infrastructure for multiple files | 5 // This file contains test infrastructure for multiple files |
6 // (current cookie_monster_unittest.cc and cookie_monster_perftest.cc) | 6 // (current cookie_monster_unittest.cc and cookie_monster_perftest.cc) |
7 // that need to test out CookieMonster interactions with the backing store. | 7 // that need to test out CookieMonster interactions with the backing store. |
8 // It should only be included by test code. | 8 // It should only be included by test code. |
9 | 9 |
10 #ifndef NET_COOKIES_COOKIE_MONSTER_STORE_TEST_H_ | 10 #ifndef NET_COOKIES_COOKIE_MONSTER_STORE_TEST_H_ |
11 #define NET_COOKIES_COOKIE_MONSTER_STORE_TEST_H_ | 11 #define NET_COOKIES_COOKIE_MONSTER_STORE_TEST_H_ |
12 | 12 |
13 #include <stdint.h> | 13 #include <stdint.h> |
14 | 14 |
15 #include <map> | 15 #include <map> |
| 16 #include <memory> |
16 #include <string> | 17 #include <string> |
17 #include <utility> | 18 #include <utility> |
18 #include <vector> | 19 #include <vector> |
19 | 20 |
20 #include "base/macros.h" | 21 #include "base/macros.h" |
21 #include "base/memory/scoped_ptr.h" | |
22 #include "net/cookies/canonical_cookie.h" | 22 #include "net/cookies/canonical_cookie.h" |
23 #include "net/cookies/cookie_monster.h" | 23 #include "net/cookies/cookie_monster.h" |
24 | 24 |
25 class GURL; | 25 class GURL; |
26 | 26 |
27 namespace base { | 27 namespace base { |
28 class Time; | 28 class Time; |
29 } | 29 } |
30 | 30 |
31 namespace net { | 31 namespace net { |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 | 161 |
162 private: | 162 private: |
163 ~MockCookieMonsterDelegate() override; | 163 ~MockCookieMonsterDelegate() override; |
164 | 164 |
165 std::vector<CookieNotification> changes_; | 165 std::vector<CookieNotification> changes_; |
166 | 166 |
167 DISALLOW_COPY_AND_ASSIGN(MockCookieMonsterDelegate); | 167 DISALLOW_COPY_AND_ASSIGN(MockCookieMonsterDelegate); |
168 }; | 168 }; |
169 | 169 |
170 // Helper to build a single CanonicalCookie. | 170 // Helper to build a single CanonicalCookie. |
171 scoped_ptr<CanonicalCookie> BuildCanonicalCookie( | 171 std::unique_ptr<CanonicalCookie> BuildCanonicalCookie( |
172 const GURL& url, | 172 const GURL& url, |
173 const std::string& cookie_line, | 173 const std::string& cookie_line, |
174 const base::Time& creation_time); | 174 const base::Time& creation_time); |
175 | 175 |
176 // Helper to build a list of CanonicalCookie*s. | 176 // Helper to build a list of CanonicalCookie*s. |
177 void AddCookieToList(const GURL& url, | 177 void AddCookieToList(const GURL& url, |
178 const std::string& cookie_line, | 178 const std::string& cookie_line, |
179 const base::Time& creation_time, | 179 const base::Time& creation_time, |
180 std::vector<CanonicalCookie*>* out_list); | 180 std::vector<CanonicalCookie*>* out_list); |
181 | 181 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 | 216 |
217 // Helper function for creating a CookieMonster backed by a | 217 // Helper function for creating a CookieMonster backed by a |
218 // MockSimplePersistentCookieStore for garbage collection testing. | 218 // MockSimplePersistentCookieStore for garbage collection testing. |
219 // | 219 // |
220 // Fill the store through import with |num_*_cookies| cookies, | 220 // Fill the store through import with |num_*_cookies| cookies, |
221 // |num_old_*_cookies| with access time Now()-days_old, the rest with access | 221 // |num_old_*_cookies| with access time Now()-days_old, the rest with access |
222 // time Now(). Cookies made by |num_secure_cookies| and |num_non_secure_cookies| | 222 // time Now(). Cookies made by |num_secure_cookies| and |num_non_secure_cookies| |
223 // will be marked secure and non-secure, respectively. Do two SetCookies(). | 223 // will be marked secure and non-secure, respectively. Do two SetCookies(). |
224 // Return whether each of the two SetCookies() took longer than |gc_perf_micros| | 224 // Return whether each of the two SetCookies() took longer than |gc_perf_micros| |
225 // to complete, and how many cookie were left in the store afterwards. | 225 // to complete, and how many cookie were left in the store afterwards. |
226 scoped_ptr<CookieMonster> CreateMonsterFromStoreForGC( | 226 std::unique_ptr<CookieMonster> CreateMonsterFromStoreForGC( |
227 int num_secure_cookies, | 227 int num_secure_cookies, |
228 int num_old_secure_cookies, | 228 int num_old_secure_cookies, |
229 int num_non_secure_cookies, | 229 int num_non_secure_cookies, |
230 int num_old_non_secure_cookies, | 230 int num_old_non_secure_cookies, |
231 int days_old); | 231 int days_old); |
232 | 232 |
233 } // namespace net | 233 } // namespace net |
234 | 234 |
235 #endif // NET_COOKIES_COOKIE_MONSTER_STORE_TEST_H_ | 235 #endif // NET_COOKIES_COOKIE_MONSTER_STORE_TEST_H_ |
OLD | NEW |