OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_BASE_COOKIE_MONSTER_STORE_TEST_H_ | 10 #ifndef NET_BASE_COOKIE_MONSTER_STORE_TEST_H_ |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 const CookieMonster::CanonicalCookie& cookie) OVERRIDE; | 93 const CookieMonster::CanonicalCookie& cookie) OVERRIDE; |
94 | 94 |
95 virtual void DeleteCookie( | 95 virtual void DeleteCookie( |
96 const CookieMonster::CanonicalCookie& cookie) OVERRIDE; | 96 const CookieMonster::CanonicalCookie& cookie) OVERRIDE; |
97 | 97 |
98 virtual void Flush(Task* completion_task) OVERRIDE; | 98 virtual void Flush(Task* completion_task) OVERRIDE; |
99 | 99 |
100 // No files are created so nothing to clear either | 100 // No files are created so nothing to clear either |
101 virtual void SetClearLocalStateOnExit(bool clear_local_state) OVERRIDE; | 101 virtual void SetClearLocalStateOnExit(bool clear_local_state) OVERRIDE; |
102 | 102 |
| 103 virtual void DeleteSessionCookies() OVERRIDE; |
| 104 |
103 private: | 105 private: |
104 CommandList commands_; | 106 CommandList commands_; |
105 | 107 |
106 // Deferred result to use when Load() is called. | 108 // Deferred result to use when Load() is called. |
107 bool load_return_value_; | 109 bool load_return_value_; |
108 std::vector<CookieMonster::CanonicalCookie*> load_result_; | 110 std::vector<CookieMonster::CanonicalCookie*> load_result_; |
109 // Indicates if the store has been fully loaded to avoid returning duplicate | 111 // Indicates if the store has been fully loaded to avoid returning duplicate |
110 // cookies. | 112 // cookies. |
111 bool loaded_; | 113 bool loaded_; |
112 | 114 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 virtual void UpdateCookieAccessTime( | 172 virtual void UpdateCookieAccessTime( |
171 const CookieMonster::CanonicalCookie& cookie) OVERRIDE; | 173 const CookieMonster::CanonicalCookie& cookie) OVERRIDE; |
172 | 174 |
173 virtual void DeleteCookie( | 175 virtual void DeleteCookie( |
174 const CookieMonster::CanonicalCookie& cookie) OVERRIDE; | 176 const CookieMonster::CanonicalCookie& cookie) OVERRIDE; |
175 | 177 |
176 virtual void Flush(Task* completion_task) OVERRIDE; | 178 virtual void Flush(Task* completion_task) OVERRIDE; |
177 | 179 |
178 virtual void SetClearLocalStateOnExit(bool clear_local_state) OVERRIDE; | 180 virtual void SetClearLocalStateOnExit(bool clear_local_state) OVERRIDE; |
179 | 181 |
| 182 virtual void DeleteSessionCookies() OVERRIDE; |
| 183 |
180 private: | 184 private: |
181 typedef std::map<int64, CookieMonster::CanonicalCookie> | 185 typedef std::map<int64, CookieMonster::CanonicalCookie> |
182 CanonicalCookieMap; | 186 CanonicalCookieMap; |
183 | 187 |
184 CanonicalCookieMap cookies_; | 188 CanonicalCookieMap cookies_; |
185 | 189 |
186 // Indicates if the store has been fully loaded to avoid return duplicate | 190 // Indicates if the store has been fully loaded to avoid return duplicate |
187 // cookies in subsequent load requests | 191 // cookies in subsequent load requests |
188 bool loaded_; | 192 bool loaded_; |
189 }; | 193 }; |
190 | 194 |
191 // Helper function for creating a CookieMonster backed by a | 195 // Helper function for creating a CookieMonster backed by a |
192 // MockSimplePersistentCookieStore for garbage collection testing. | 196 // MockSimplePersistentCookieStore for garbage collection testing. |
193 // | 197 // |
194 // Fill the store through import with |num_cookies| cookies, |num_old_cookies| | 198 // Fill the store through import with |num_cookies| cookies, |num_old_cookies| |
195 // with access time Now()-days_old, the rest with access time Now(). | 199 // with access time Now()-days_old, the rest with access time Now(). |
196 // Do two SetCookies(). Return whether each of the two SetCookies() took | 200 // Do two SetCookies(). Return whether each of the two SetCookies() took |
197 // longer than |gc_perf_micros| to complete, and how many cookie were | 201 // longer than |gc_perf_micros| to complete, and how many cookie were |
198 // left in the store afterwards. | 202 // left in the store afterwards. |
199 CookieMonster* CreateMonsterFromStoreForGC( | 203 CookieMonster* CreateMonsterFromStoreForGC( |
200 int num_cookies, | 204 int num_cookies, |
201 int num_old_cookies, | 205 int num_old_cookies, |
202 int days_old); | 206 int days_old); |
203 | 207 |
204 } // namespace net | 208 } // namespace net |
205 | 209 |
206 #endif // NET_BASE_COOKIE_MONSTER_STORE_TEST_H_ | 210 #endif // NET_BASE_COOKIE_MONSTER_STORE_TEST_H_ |
OLD | NEW |