Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: net/cookies/cookie_monster_store_test.h

Issue 2383393002: Remove stl_util's deletion functions from net/cookies/ and net/extras/. (Closed)
Patch Set: removing Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/cookies/cookie_monster_perftest.cc ('k') | net/cookies/cookie_monster_store_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_
(...skipping 12 matching lines...) Expand all
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 {
32 32
33 // Wrapper class for posting a loaded callback. Since the Callback class is not
34 // reference counted, we cannot post a callback to the message loop directly,
35 // instead we post a LoadedCallbackTask.
36 class LoadedCallbackTask
37 : public base::RefCountedThreadSafe<LoadedCallbackTask> {
38 public:
39 typedef CookieMonster::PersistentCookieStore::LoadedCallback LoadedCallback;
40
41 LoadedCallbackTask(LoadedCallback loaded_callback,
42 std::vector<CanonicalCookie*> cookies);
43
44 void Run() { loaded_callback_.Run(cookies_); }
45
46 private:
47 friend class base::RefCountedThreadSafe<LoadedCallbackTask>;
48 ~LoadedCallbackTask();
49
50 LoadedCallback loaded_callback_;
51 std::vector<CanonicalCookie*> cookies_;
52
53 DISALLOW_COPY_AND_ASSIGN(LoadedCallbackTask);
54 }; // Wrapper class LoadedCallbackTask
55
56 // Describes a call to one of the 5 functions of PersistentCookieStore. 33 // Describes a call to one of the 5 functions of PersistentCookieStore.
57 struct CookieStoreCommand { 34 struct CookieStoreCommand {
58 enum Type { 35 enum Type {
59 LOAD, 36 LOAD,
60 LOAD_COOKIES_FOR_KEY, 37 LOAD_COOKIES_FOR_KEY,
61 // UPDATE_ACCESS_TIME is not included in this list, because get cookie 38 // UPDATE_ACCESS_TIME is not included in this list, because get cookie
62 // commands may or may not end updating the access time, unless they have 39 // commands may or may not end updating the access time, unless they have
63 // the option set not to do so. 40 // the option set not to do so.
64 ADD, 41 ADD,
65 REMOVE, 42 REMOVE,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 77
101 MockPersistentCookieStore(); 78 MockPersistentCookieStore();
102 79
103 // When set, Load() and LoadCookiesForKey() calls are store in the command 80 // When set, Load() and LoadCookiesForKey() calls are store in the command
104 // list, rather than being automatically executed. Defaults to false. 81 // list, rather than being automatically executed. Defaults to false.
105 void set_store_load_commands(bool store_load_commands) { 82 void set_store_load_commands(bool store_load_commands) {
106 store_load_commands_ = store_load_commands; 83 store_load_commands_ = store_load_commands;
107 } 84 }
108 85
109 void SetLoadExpectation(bool return_value, 86 void SetLoadExpectation(bool return_value,
110 const std::vector<CanonicalCookie*>& result); 87 std::vector<std::unique_ptr<CanonicalCookie>> result);
111 88
112 const CommandList& commands() const { return commands_; } 89 const CommandList& commands() const { return commands_; }
113 90
114 void Load(const LoadedCallback& loaded_callback) override; 91 void Load(const LoadedCallback& loaded_callback) override;
115 92
116 void LoadCookiesForKey(const std::string& key, 93 void LoadCookiesForKey(const std::string& key,
117 const LoadedCallback& loaded_callback) override; 94 const LoadedCallback& loaded_callback) override;
118 95
119 void AddCookie(const CanonicalCookie& cookie) override; 96 void AddCookie(const CanonicalCookie& cookie) override;
120 97
121 void UpdateCookieAccessTime(const CanonicalCookie& cookie) override; 98 void UpdateCookieAccessTime(const CanonicalCookie& cookie) override;
122 99
123 void DeleteCookie(const CanonicalCookie& cookie) override; 100 void DeleteCookie(const CanonicalCookie& cookie) override;
124 101
125 void Flush(const base::Closure& callback) override; 102 void Flush(const base::Closure& callback) override;
126 103
127 void SetForceKeepSessionState() override; 104 void SetForceKeepSessionState() override;
128 105
129 protected: 106 protected:
130 ~MockPersistentCookieStore() override; 107 ~MockPersistentCookieStore() override;
131 108
132 private: 109 private:
133 CommandList commands_; 110 CommandList commands_;
134 111
135 bool store_load_commands_; 112 bool store_load_commands_;
136 113
137 // Deferred result to use when Load() is called. 114 // Deferred result to use when Load() is called.
138 bool load_return_value_; 115 bool load_return_value_;
139 std::vector<CanonicalCookie*> load_result_; 116 std::vector<std::unique_ptr<CanonicalCookie>> load_result_;
140 // Indicates if the store has been fully loaded to avoid returning duplicate 117 // Indicates if the store has been fully loaded to avoid returning duplicate
141 // cookies. 118 // cookies.
142 bool loaded_; 119 bool loaded_;
143 120
144 DISALLOW_COPY_AND_ASSIGN(MockPersistentCookieStore); 121 DISALLOW_COPY_AND_ASSIGN(MockPersistentCookieStore);
145 }; 122 };
146 123
147 // Mock for CookieMonsterDelegate 124 // Mock for CookieMonsterDelegate
148 class MockCookieMonsterDelegate : public CookieMonsterDelegate { 125 class MockCookieMonsterDelegate : public CookieMonsterDelegate {
149 public: 126 public:
(...skipping 20 matching lines...) Expand all
170 // Helper to build a single CanonicalCookie. 147 // Helper to build a single CanonicalCookie.
171 std::unique_ptr<CanonicalCookie> BuildCanonicalCookie( 148 std::unique_ptr<CanonicalCookie> BuildCanonicalCookie(
172 const GURL& url, 149 const GURL& url,
173 const std::string& cookie_line, 150 const std::string& cookie_line,
174 const base::Time& creation_time); 151 const base::Time& creation_time);
175 152
176 // Helper to build a list of CanonicalCookie*s. 153 // Helper to build a list of CanonicalCookie*s.
177 void AddCookieToList(const GURL& url, 154 void AddCookieToList(const GURL& url,
178 const std::string& cookie_line, 155 const std::string& cookie_line,
179 const base::Time& creation_time, 156 const base::Time& creation_time,
180 std::vector<CanonicalCookie*>* out_list); 157 std::vector<std::unique_ptr<CanonicalCookie>>* out_list);
181 158
182 // Just act like a backing database. Keep cookie information from 159 // Just act like a backing database. Keep cookie information from
183 // Add/Update/Delete and regurgitate it when Load is called. 160 // Add/Update/Delete and regurgitate it when Load is called.
184 class MockSimplePersistentCookieStore 161 class MockSimplePersistentCookieStore
185 : public CookieMonster::PersistentCookieStore { 162 : public CookieMonster::PersistentCookieStore {
186 public: 163 public:
187 MockSimplePersistentCookieStore(); 164 MockSimplePersistentCookieStore();
188 165
189 void Load(const LoadedCallback& loaded_callback) override; 166 void Load(const LoadedCallback& loaded_callback) override;
190 167
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 std::unique_ptr<CookieMonster> CreateMonsterFromStoreForGC( 203 std::unique_ptr<CookieMonster> CreateMonsterFromStoreForGC(
227 int num_secure_cookies, 204 int num_secure_cookies,
228 int num_old_secure_cookies, 205 int num_old_secure_cookies,
229 int num_non_secure_cookies, 206 int num_non_secure_cookies,
230 int num_old_non_secure_cookies, 207 int num_old_non_secure_cookies,
231 int days_old); 208 int days_old);
232 209
233 } // namespace net 210 } // namespace net
234 211
235 #endif // NET_COOKIES_COOKIE_MONSTER_STORE_TEST_H_ 212 #endif // NET_COOKIES_COOKIE_MONSTER_STORE_TEST_H_
OLDNEW
« no previous file with comments | « net/cookies/cookie_monster_perftest.cc ('k') | net/cookies/cookie_monster_store_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698