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

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

Issue 1893083002: Change scoped_ptr to std::unique_ptr in //net. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptr-net-all: iwyu Created 4 years, 8 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_store_test.h ('k') | net/cookies/cookie_monster_unittest.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 #include "net/cookies/cookie_monster_store_test.h" 5 #include "net/cookies/cookie_monster_store_test.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/memory/ptr_util.h"
9 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
10 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
11 #include "base/thread_task_runner_handle.h" 12 #include "base/thread_task_runner_handle.h"
12 #include "base/time/time.h" 13 #include "base/time/time.h"
13 #include "net/cookies/cookie_constants.h" 14 #include "net/cookies/cookie_constants.h"
14 #include "net/cookies/cookie_util.h" 15 #include "net/cookies/cookie_util.h"
15 #include "net/cookies/parsed_cookie.h" 16 #include "net/cookies/parsed_cookie.h"
16 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
17 #include "url/gurl.h" 18 #include "url/gurl.h"
18 19
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 const CanonicalCookie& cookie, 117 const CanonicalCookie& cookie,
117 bool removed, 118 bool removed,
118 CookieMonsterDelegate::ChangeCause cause) { 119 CookieMonsterDelegate::ChangeCause cause) {
119 CookieNotification notification(cookie, removed); 120 CookieNotification notification(cookie, removed);
120 changes_.push_back(notification); 121 changes_.push_back(notification);
121 } 122 }
122 123
123 MockCookieMonsterDelegate::~MockCookieMonsterDelegate() { 124 MockCookieMonsterDelegate::~MockCookieMonsterDelegate() {
124 } 125 }
125 126
126 scoped_ptr<CanonicalCookie> BuildCanonicalCookie( 127 std::unique_ptr<CanonicalCookie> BuildCanonicalCookie(
127 const GURL& url, 128 const GURL& url,
128 const std::string& cookie_line, 129 const std::string& cookie_line,
129 const base::Time& creation_time) { 130 const base::Time& creation_time) {
130 // Parse the cookie line. 131 // Parse the cookie line.
131 ParsedCookie pc(cookie_line); 132 ParsedCookie pc(cookie_line);
132 EXPECT_TRUE(pc.IsValid()); 133 EXPECT_TRUE(pc.IsValid());
133 134
134 // This helper is simplistic in interpreting a parsed cookie, in order to 135 // This helper is simplistic in interpreting a parsed cookie, in order to
135 // avoid duplicated CookieMonster's CanonPath() and CanonExpiration() 136 // avoid duplicated CookieMonster's CanonPath() and CanonExpiration()
136 // functions. Would be nice to export them, and re-use here. 137 // functions. Would be nice to export them, and re-use here.
137 EXPECT_FALSE(pc.HasMaxAge()); 138 EXPECT_FALSE(pc.HasMaxAge());
138 EXPECT_TRUE(pc.HasPath()); 139 EXPECT_TRUE(pc.HasPath());
139 base::Time cookie_expires = pc.HasExpires() 140 base::Time cookie_expires = pc.HasExpires()
140 ? cookie_util::ParseCookieTime(pc.Expires()) 141 ? cookie_util::ParseCookieTime(pc.Expires())
141 : base::Time(); 142 : base::Time();
142 std::string cookie_path = pc.Path(); 143 std::string cookie_path = pc.Path();
143 144
144 return CanonicalCookie::Create(url, pc.Name(), pc.Value(), url.host(), 145 return CanonicalCookie::Create(url, pc.Name(), pc.Value(), url.host(),
145 cookie_path, creation_time, cookie_expires, 146 cookie_path, creation_time, cookie_expires,
146 pc.IsSecure(), pc.IsHttpOnly(), pc.SameSite(), 147 pc.IsSecure(), pc.IsHttpOnly(), pc.SameSite(),
147 false, pc.Priority()); 148 false, pc.Priority());
148 } 149 }
149 150
150 void AddCookieToList(const GURL& url, 151 void AddCookieToList(const GURL& url,
151 const std::string& cookie_line, 152 const std::string& cookie_line,
152 const base::Time& creation_time, 153 const base::Time& creation_time,
153 std::vector<CanonicalCookie*>* out_list) { 154 std::vector<CanonicalCookie*>* out_list) {
154 scoped_ptr<CanonicalCookie> cookie( 155 std::unique_ptr<CanonicalCookie> cookie(
155 BuildCanonicalCookie(url, cookie_line, creation_time)); 156 BuildCanonicalCookie(url, cookie_line, creation_time));
156 157
157 out_list->push_back(cookie.release()); 158 out_list->push_back(cookie.release());
158 } 159 }
159 160
160 MockSimplePersistentCookieStore::MockSimplePersistentCookieStore() 161 MockSimplePersistentCookieStore::MockSimplePersistentCookieStore()
161 : loaded_(false) { 162 : loaded_(false) {
162 } 163 }
163 164
164 void MockSimplePersistentCookieStore::Load( 165 void MockSimplePersistentCookieStore::Load(
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 } 213 }
213 214
214 void MockSimplePersistentCookieStore::Flush(const base::Closure& callback) { 215 void MockSimplePersistentCookieStore::Flush(const base::Closure& callback) {
215 if (!callback.is_null()) 216 if (!callback.is_null())
216 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback); 217 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback);
217 } 218 }
218 219
219 void MockSimplePersistentCookieStore::SetForceKeepSessionState() { 220 void MockSimplePersistentCookieStore::SetForceKeepSessionState() {
220 } 221 }
221 222
222 scoped_ptr<CookieMonster> CreateMonsterFromStoreForGC( 223 std::unique_ptr<CookieMonster> CreateMonsterFromStoreForGC(
223 int num_secure_cookies, 224 int num_secure_cookies,
224 int num_old_secure_cookies, 225 int num_old_secure_cookies,
225 int num_non_secure_cookies, 226 int num_non_secure_cookies,
226 int num_old_non_secure_cookies, 227 int num_old_non_secure_cookies,
227 int days_old) { 228 int days_old) {
228 base::Time current(base::Time::Now()); 229 base::Time current(base::Time::Now());
229 base::Time past_creation(base::Time::Now() - base::TimeDelta::FromDays(1000)); 230 base::Time past_creation(base::Time::Now() - base::TimeDelta::FromDays(1000));
230 scoped_refptr<MockSimplePersistentCookieStore> store( 231 scoped_refptr<MockSimplePersistentCookieStore> store(
231 new MockSimplePersistentCookieStore); 232 new MockSimplePersistentCookieStore);
232 int total_cookies = num_secure_cookies + num_non_secure_cookies; 233 int total_cookies = num_secure_cookies + num_non_secure_cookies;
(...skipping 18 matching lines...) Expand all
251 ? current - base::TimeDelta::FromDays(days_old) 252 ? current - base::TimeDelta::FromDays(days_old)
252 : current; 253 : current;
253 254
254 CanonicalCookie cc(GURL(), "a", "1", base::StringPrintf("h%05d.izzle", i), 255 CanonicalCookie cc(GURL(), "a", "1", base::StringPrintf("h%05d.izzle", i),
255 "/path", creation_time, expiration_time, 256 "/path", creation_time, expiration_time,
256 last_access_time, secure, false, 257 last_access_time, secure, false,
257 CookieSameSite::DEFAULT_MODE, COOKIE_PRIORITY_DEFAULT); 258 CookieSameSite::DEFAULT_MODE, COOKIE_PRIORITY_DEFAULT);
258 store->AddCookie(cc); 259 store->AddCookie(cc);
259 } 260 }
260 261
261 return make_scoped_ptr(new CookieMonster(store.get(), nullptr)); 262 return base::WrapUnique(new CookieMonster(store.get(), nullptr));
262 } 263 }
263 264
264 MockSimplePersistentCookieStore::~MockSimplePersistentCookieStore() { 265 MockSimplePersistentCookieStore::~MockSimplePersistentCookieStore() {
265 } 266 }
266 267
267 } // namespace net 268 } // namespace net
OLDNEW
« no previous file with comments | « net/cookies/cookie_monster_store_test.h ('k') | net/cookies/cookie_monster_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698