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

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: windows 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
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 14 matching lines...) Expand all
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 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, 34 // reference counted, we cannot post a callback to the message loop directly,
35 // instead we post a LoadedCallbackTask. 35 // instead we post a LoadedCallbackTask.
davidben 2016/10/10 23:05:00 Existing problem, but this comment seems a little
Avi (use Gerrit) 2016/10/11 00:57:48 Let's give that a try.
36 class LoadedCallbackTask 36 class LoadedCallbackTask
37 : public base::RefCountedThreadSafe<LoadedCallbackTask> { 37 : public base::RefCountedThreadSafe<LoadedCallbackTask> {
38 public: 38 public:
39 typedef CookieMonster::PersistentCookieStore::LoadedCallback LoadedCallback; 39 typedef CookieMonster::PersistentCookieStore::LoadedCallback LoadedCallback;
40 40
41 LoadedCallbackTask(LoadedCallback loaded_callback, 41 LoadedCallbackTask(LoadedCallback loaded_callback,
42 std::vector<CanonicalCookie*> cookies); 42 std::vector<std::unique_ptr<CanonicalCookie>> cookies);
43 43
44 void Run() { loaded_callback_.Run(cookies_); } 44 void Run() { loaded_callback_.Run(std::move(cookies_)); }
45 45
46 private: 46 private:
47 friend class base::RefCountedThreadSafe<LoadedCallbackTask>; 47 friend class base::RefCountedThreadSafe<LoadedCallbackTask>;
48 ~LoadedCallbackTask(); 48 ~LoadedCallbackTask();
49 49
50 LoadedCallback loaded_callback_; 50 LoadedCallback loaded_callback_;
51 std::vector<CanonicalCookie*> cookies_; 51 std::vector<std::unique_ptr<CanonicalCookie>> cookies_;
52 52
53 DISALLOW_COPY_AND_ASSIGN(LoadedCallbackTask); 53 DISALLOW_COPY_AND_ASSIGN(LoadedCallbackTask);
54 }; // Wrapper class LoadedCallbackTask 54 }; // Wrapper class LoadedCallbackTask
55 55
56 // Describes a call to one of the 5 functions of PersistentCookieStore. 56 // Describes a call to one of the 5 functions of PersistentCookieStore.
57 struct CookieStoreCommand { 57 struct CookieStoreCommand {
58 enum Type { 58 enum Type {
59 LOAD, 59 LOAD,
60 LOAD_COOKIES_FOR_KEY, 60 LOAD_COOKIES_FOR_KEY,
61 // UPDATE_ACCESS_TIME is not included in this list, because get cookie 61 // UPDATE_ACCESS_TIME is not included in this list, because get cookie
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 100
101 MockPersistentCookieStore(); 101 MockPersistentCookieStore();
102 102
103 // When set, Load() and LoadCookiesForKey() calls are store in the command 103 // When set, Load() and LoadCookiesForKey() calls are store in the command
104 // list, rather than being automatically executed. Defaults to false. 104 // list, rather than being automatically executed. Defaults to false.
105 void set_store_load_commands(bool store_load_commands) { 105 void set_store_load_commands(bool store_load_commands) {
106 store_load_commands_ = store_load_commands; 106 store_load_commands_ = store_load_commands;
107 } 107 }
108 108
109 void SetLoadExpectation(bool return_value, 109 void SetLoadExpectation(bool return_value,
110 const std::vector<CanonicalCookie*>& result); 110 std::vector<std::unique_ptr<CanonicalCookie>> result);
111 111
112 const CommandList& commands() const { return commands_; } 112 const CommandList& commands() const { return commands_; }
113 113
114 void Load(const LoadedCallback& loaded_callback) override; 114 void Load(const LoadedCallback& loaded_callback) override;
115 115
116 void LoadCookiesForKey(const std::string& key, 116 void LoadCookiesForKey(const std::string& key,
117 const LoadedCallback& loaded_callback) override; 117 const LoadedCallback& loaded_callback) override;
118 118
119 void AddCookie(const CanonicalCookie& cookie) override; 119 void AddCookie(const CanonicalCookie& cookie) override;
120 120
121 void UpdateCookieAccessTime(const CanonicalCookie& cookie) override; 121 void UpdateCookieAccessTime(const CanonicalCookie& cookie) override;
122 122
123 void DeleteCookie(const CanonicalCookie& cookie) override; 123 void DeleteCookie(const CanonicalCookie& cookie) override;
124 124
125 void Flush(const base::Closure& callback) override; 125 void Flush(const base::Closure& callback) override;
126 126
127 void SetForceKeepSessionState() override; 127 void SetForceKeepSessionState() override;
128 128
129 protected: 129 protected:
130 ~MockPersistentCookieStore() override; 130 ~MockPersistentCookieStore() override;
131 131
132 private: 132 private:
133 CommandList commands_; 133 CommandList commands_;
134 134
135 bool store_load_commands_; 135 bool store_load_commands_;
136 136
137 // Deferred result to use when Load() is called. 137 // Deferred result to use when Load() is called.
138 bool load_return_value_; 138 bool load_return_value_;
139 std::vector<CanonicalCookie*> load_result_; 139 std::vector<std::unique_ptr<CanonicalCookie>> load_result_;
140 // Indicates if the store has been fully loaded to avoid returning duplicate 140 // Indicates if the store has been fully loaded to avoid returning duplicate
141 // cookies. 141 // cookies.
142 bool loaded_; 142 bool loaded_;
143 143
144 DISALLOW_COPY_AND_ASSIGN(MockPersistentCookieStore); 144 DISALLOW_COPY_AND_ASSIGN(MockPersistentCookieStore);
145 }; 145 };
146 146
147 // Mock for CookieMonsterDelegate 147 // Mock for CookieMonsterDelegate
148 class MockCookieMonsterDelegate : public CookieMonsterDelegate { 148 class MockCookieMonsterDelegate : public CookieMonsterDelegate {
149 public: 149 public:
(...skipping 20 matching lines...) Expand all
170 // Helper to build a single CanonicalCookie. 170 // Helper to build a single CanonicalCookie.
171 std::unique_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<std::unique_ptr<CanonicalCookie>>* out_list);
181 181
182 // Just act like a backing database. Keep cookie information from 182 // Just act like a backing database. Keep cookie information from
183 // Add/Update/Delete and regurgitate it when Load is called. 183 // Add/Update/Delete and regurgitate it when Load is called.
184 class MockSimplePersistentCookieStore 184 class MockSimplePersistentCookieStore
185 : public CookieMonster::PersistentCookieStore { 185 : public CookieMonster::PersistentCookieStore {
186 public: 186 public:
187 MockSimplePersistentCookieStore(); 187 MockSimplePersistentCookieStore();
188 188
189 void Load(const LoadedCallback& loaded_callback) override; 189 void Load(const LoadedCallback& loaded_callback) override;
190 190
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 std::unique_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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698