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> |
| 14 |
13 #include <map> | 15 #include <map> |
14 #include <string> | 16 #include <string> |
15 #include <utility> | 17 #include <utility> |
16 #include <vector> | 18 #include <vector> |
| 19 |
| 20 #include "base/macros.h" |
17 #include "net/cookies/canonical_cookie.h" | 21 #include "net/cookies/canonical_cookie.h" |
18 #include "net/cookies/cookie_monster.h" | 22 #include "net/cookies/cookie_monster.h" |
19 | 23 |
20 namespace base { | 24 namespace base { |
21 class Time; | 25 class Time; |
22 } | 26 } |
23 | 27 |
24 namespace net { | 28 namespace net { |
25 | 29 |
26 // Wrapper class for posting a loaded callback. Since the Callback class is not | 30 // Wrapper class for posting a loaded callback. Since the Callback class is not |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 void DeleteCookie(const CanonicalCookie& cookie) override; | 163 void DeleteCookie(const CanonicalCookie& cookie) override; |
160 | 164 |
161 void Flush(const base::Closure& callback) override; | 165 void Flush(const base::Closure& callback) override; |
162 | 166 |
163 void SetForceKeepSessionState() override; | 167 void SetForceKeepSessionState() override; |
164 | 168 |
165 protected: | 169 protected: |
166 ~MockSimplePersistentCookieStore() override; | 170 ~MockSimplePersistentCookieStore() override; |
167 | 171 |
168 private: | 172 private: |
169 typedef std::map<int64, CanonicalCookie> CanonicalCookieMap; | 173 typedef std::map<int64_t, CanonicalCookie> CanonicalCookieMap; |
170 | 174 |
171 CanonicalCookieMap cookies_; | 175 CanonicalCookieMap cookies_; |
172 | 176 |
173 // Indicates if the store has been fully loaded to avoid return duplicate | 177 // Indicates if the store has been fully loaded to avoid return duplicate |
174 // cookies in subsequent load requests | 178 // cookies in subsequent load requests |
175 bool loaded_; | 179 bool loaded_; |
176 }; | 180 }; |
177 | 181 |
178 // Helper function for creating a CookieMonster backed by a | 182 // Helper function for creating a CookieMonster backed by a |
179 // MockSimplePersistentCookieStore for garbage collection testing. | 183 // MockSimplePersistentCookieStore for garbage collection testing. |
180 // | 184 // |
181 // Fill the store through import with |num_*_cookies| cookies, | 185 // Fill the store through import with |num_*_cookies| cookies, |
182 // |num_old_*_cookies| with access time Now()-days_old, the rest with access | 186 // |num_old_*_cookies| with access time Now()-days_old, the rest with access |
183 // time Now(). Cookies made by |num_secure_cookies| and |num_non_secure_cookies| | 187 // time Now(). Cookies made by |num_secure_cookies| and |num_non_secure_cookies| |
184 // will be marked secure and non-secure, respectively. Do two SetCookies(). | 188 // will be marked secure and non-secure, respectively. Do two SetCookies(). |
185 // Return whether each of the two SetCookies() took longer than |gc_perf_micros| | 189 // Return whether each of the two SetCookies() took longer than |gc_perf_micros| |
186 // to complete, and how many cookie were left in the store afterwards. | 190 // to complete, and how many cookie were left in the store afterwards. |
187 CookieMonster* CreateMonsterFromStoreForGC(int num_secure_cookies, | 191 CookieMonster* CreateMonsterFromStoreForGC(int num_secure_cookies, |
188 int num_old_secure_cookies, | 192 int num_old_secure_cookies, |
189 int num_non_secure_cookies, | 193 int num_non_secure_cookies, |
190 int num_old_non_secure_cookies, | 194 int num_old_non_secure_cookies, |
191 int days_old); | 195 int days_old); |
192 | 196 |
193 } // namespace net | 197 } // namespace net |
194 | 198 |
195 #endif // NET_COOKIES_COOKIE_MONSTER_STORE_TEST_H_ | 199 #endif // NET_COOKIES_COOKIE_MONSTER_STORE_TEST_H_ |
OLD | NEW |