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 #include "net/extras/sqlite/sqlite_persistent_cookie_store.h" | 5 #include "net/extras/sqlite/sqlite_persistent_cookie_store.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <memory> | 8 #include <memory> |
9 #include <set> | 9 #include <set> |
| 10 #include <utility> |
10 | 11 |
11 #include "base/bind.h" | 12 #include "base/bind.h" |
12 #include "base/callback.h" | 13 #include "base/callback.h" |
13 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
14 #include "base/files/scoped_temp_dir.h" | 15 #include "base/files/scoped_temp_dir.h" |
15 #include "base/location.h" | 16 #include "base/location.h" |
16 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 18 #include "base/run_loop.h" |
17 #include "base/sequenced_task_runner.h" | 19 #include "base/sequenced_task_runner.h" |
18 #include "base/synchronization/waitable_event.h" | 20 #include "base/synchronization/waitable_event.h" |
19 #include "base/test/sequenced_worker_pool_owner.h" | 21 #include "base/task_scheduler/post_task.h" |
20 #include "base/threading/sequenced_worker_pool.h" | 22 #include "base/test/scoped_task_environment.h" |
21 #include "base/time/time.h" | 23 #include "base/time/time.h" |
22 #include "crypto/encryptor.h" | 24 #include "crypto/encryptor.h" |
23 #include "crypto/symmetric_key.h" | 25 #include "crypto/symmetric_key.h" |
24 #include "net/cookies/canonical_cookie.h" | 26 #include "net/cookies/canonical_cookie.h" |
25 #include "net/cookies/cookie_constants.h" | 27 #include "net/cookies/cookie_constants.h" |
26 #include "net/extras/sqlite/cookie_crypto_delegate.h" | 28 #include "net/extras/sqlite/cookie_crypto_delegate.h" |
| 29 #include "net/test/net_test_suite.h" |
27 #include "sql/connection.h" | 30 #include "sql/connection.h" |
28 #include "sql/meta_table.h" | 31 #include "sql/meta_table.h" |
29 #include "sql/statement.h" | 32 #include "sql/statement.h" |
30 #include "testing/gtest/include/gtest/gtest.h" | 33 #include "testing/gtest/include/gtest/gtest.h" |
31 #include "url/gurl.h" | 34 #include "url/gurl.h" |
32 | 35 |
33 namespace net { | 36 namespace net { |
34 | 37 |
35 namespace { | 38 namespace { |
36 | 39 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 return encryptor_.Decrypt(ciphertext, plaintext); | 81 return encryptor_.Decrypt(ciphertext, plaintext); |
79 } | 82 } |
80 | 83 |
81 } // namespace | 84 } // namespace |
82 | 85 |
83 typedef std::vector<std::unique_ptr<CanonicalCookie>> CanonicalCookieVector; | 86 typedef std::vector<std::unique_ptr<CanonicalCookie>> CanonicalCookieVector; |
84 | 87 |
85 class SQLitePersistentCookieStoreTest : public testing::Test { | 88 class SQLitePersistentCookieStoreTest : public testing::Test { |
86 public: | 89 public: |
87 SQLitePersistentCookieStoreTest() | 90 SQLitePersistentCookieStoreTest() |
88 : pool_owner_(new base::SequencedWorkerPoolOwner(3, "Background Pool")), | 91 : loaded_event_(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
89 loaded_event_(base::WaitableEvent::ResetPolicy::AUTOMATIC, | |
90 base::WaitableEvent::InitialState::NOT_SIGNALED), | 92 base::WaitableEvent::InitialState::NOT_SIGNALED), |
91 key_loaded_event_(base::WaitableEvent::ResetPolicy::AUTOMATIC, | |
92 base::WaitableEvent::InitialState::NOT_SIGNALED), | |
93 db_thread_event_(base::WaitableEvent::ResetPolicy::AUTOMATIC, | 93 db_thread_event_(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
94 base::WaitableEvent::InitialState::NOT_SIGNALED) {} | 94 base::WaitableEvent::InitialState::NOT_SIGNALED) {} |
95 | 95 |
96 void OnLoaded(CanonicalCookieVector cookies) { | 96 void OnLoaded(CanonicalCookieVector cookies) { |
97 cookies_.swap(cookies); | 97 cookies_.swap(cookies); |
98 loaded_event_.Signal(); | 98 loaded_event_.Signal(); |
99 } | 99 } |
100 | 100 |
101 void OnKeyLoaded(CanonicalCookieVector cookies) { | 101 void OnKeyLoaded(base::OnceClosure closure, CanonicalCookieVector cookies) { |
102 cookies_.swap(cookies); | 102 cookies_.swap(cookies); |
103 key_loaded_event_.Signal(); | 103 std::move(closure).Run(); |
104 } | 104 } |
105 | 105 |
106 void Load(CanonicalCookieVector* cookies) { | 106 void Load(CanonicalCookieVector* cookies) { |
107 EXPECT_FALSE(loaded_event_.IsSignaled()); | 107 EXPECT_FALSE(loaded_event_.IsSignaled()); |
108 store_->Load(base::Bind(&SQLitePersistentCookieStoreTest::OnLoaded, | 108 store_->Load(base::Bind(&SQLitePersistentCookieStoreTest::OnLoaded, |
109 base::Unretained(this))); | 109 base::Unretained(this))); |
110 loaded_event_.Wait(); | 110 loaded_event_.Wait(); |
111 cookies->swap(cookies_); | 111 cookies->swap(cookies_); |
112 } | 112 } |
113 | 113 |
114 void Flush() { | 114 void Flush() { |
115 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC, | 115 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
116 base::WaitableEvent::InitialState::NOT_SIGNALED); | 116 base::WaitableEvent::InitialState::NOT_SIGNALED); |
117 store_->Flush( | 117 store_->Flush( |
118 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&event))); | 118 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&event))); |
119 event.Wait(); | 119 event.Wait(); |
120 } | 120 } |
121 | 121 |
122 scoped_refptr<base::SequencedTaskRunner> background_task_runner() { | |
123 return pool_owner_->pool()->GetSequencedTaskRunner( | |
124 pool_owner_->pool()->GetNamedSequenceToken("background")); | |
125 } | |
126 | |
127 scoped_refptr<base::SequencedTaskRunner> client_task_runner() { | |
128 return pool_owner_->pool()->GetSequencedTaskRunner( | |
129 pool_owner_->pool()->GetNamedSequenceToken("client")); | |
130 } | |
131 | |
132 void DestroyStore() { | 122 void DestroyStore() { |
133 store_ = nullptr; | 123 store_ = nullptr; |
134 // Make sure we wait until the destructor has run by shutting down the pool | 124 // Make sure we wait until the destructor has run by running all |
135 // resetting the owner (whose destructor blocks on the pool completion). | 125 // ScopedTaskEnvironment tasks. |
136 pool_owner_->pool()->Shutdown(); | 126 NetTestSuite::GetScopedTaskEnvironment()->RunUntilIdle(); |
137 // Create a new pool for the few tests that create multiple stores. In other | |
138 // cases this is wasted but harmless. | |
139 pool_owner_.reset(new base::SequencedWorkerPoolOwner(3, "Background Pool")); | |
140 } | 127 } |
141 | 128 |
142 void Create(bool crypt_cookies, bool restore_old_session_cookies) { | 129 void Create(bool crypt_cookies, bool restore_old_session_cookies) { |
143 if (crypt_cookies) | 130 if (crypt_cookies) |
144 cookie_crypto_delegate_.reset(new CookieCryptor()); | 131 cookie_crypto_delegate_.reset(new CookieCryptor()); |
145 | 132 |
146 store_ = new SQLitePersistentCookieStore( | 133 store_ = new SQLitePersistentCookieStore( |
147 temp_dir_.GetPath().Append(kCookieFilename), client_task_runner(), | 134 temp_dir_.GetPath().Append(kCookieFilename), client_task_runner_, |
148 background_task_runner(), restore_old_session_cookies, | 135 background_task_runner_, restore_old_session_cookies, |
149 cookie_crypto_delegate_.get()); | 136 cookie_crypto_delegate_.get()); |
150 } | 137 } |
151 | 138 |
152 void CreateAndLoad(bool crypt_cookies, | 139 void CreateAndLoad(bool crypt_cookies, |
153 bool restore_old_session_cookies, | 140 bool restore_old_session_cookies, |
154 CanonicalCookieVector* cookies) { | 141 CanonicalCookieVector* cookies) { |
155 Create(crypt_cookies, restore_old_session_cookies); | 142 Create(crypt_cookies, restore_old_session_cookies); |
156 Load(cookies); | 143 Load(cookies); |
157 } | 144 } |
158 | 145 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 return contents; | 183 return contents; |
197 } | 184 } |
198 | 185 |
199 void SetUp() override { ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); } | 186 void SetUp() override { ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); } |
200 | 187 |
201 void TearDown() override { | 188 void TearDown() override { |
202 DestroyStore(); | 189 DestroyStore(); |
203 } | 190 } |
204 | 191 |
205 protected: | 192 protected: |
206 std::unique_ptr<base::SequencedWorkerPoolOwner> pool_owner_; | 193 const scoped_refptr<base::SequencedTaskRunner> background_task_runner_ = |
| 194 base::CreateSequencedTaskRunnerWithTraits( |
| 195 {base::MayBlock(), base::WithBaseSyncPrimitives()}); |
| 196 const scoped_refptr<base::SequencedTaskRunner> client_task_runner_ = |
| 197 base::CreateSequencedTaskRunnerWithTraits({base::MayBlock()}); |
207 base::WaitableEvent loaded_event_; | 198 base::WaitableEvent loaded_event_; |
208 base::WaitableEvent key_loaded_event_; | |
209 base::WaitableEvent db_thread_event_; | 199 base::WaitableEvent db_thread_event_; |
210 CanonicalCookieVector cookies_; | 200 CanonicalCookieVector cookies_; |
211 base::ScopedTempDir temp_dir_; | 201 base::ScopedTempDir temp_dir_; |
212 scoped_refptr<SQLitePersistentCookieStore> store_; | 202 scoped_refptr<SQLitePersistentCookieStore> store_; |
213 std::unique_ptr<CookieCryptor> cookie_crypto_delegate_; | 203 std::unique_ptr<CookieCryptor> cookie_crypto_delegate_; |
214 }; | 204 }; |
215 | 205 |
216 TEST_F(SQLitePersistentCookieStoreTest, TestInvalidMetaTableRecovery) { | 206 TEST_F(SQLitePersistentCookieStoreTest, TestInvalidMetaTableRecovery) { |
217 InitializeStore(false, false); | 207 InitializeStore(false, false); |
218 AddCookie("A", "B", "foo.bar", "/", base::Time::Now()); | 208 AddCookie("A", "B", "foo.bar", "/", base::Time::Now()); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 AddCookieWithExpiration("A", "B", "b3.com", "/", t, base::Time()); | 291 AddCookieWithExpiration("A", "B", "b3.com", "/", t, base::Time()); |
302 t += base::TimeDelta::FromInternalValue(10); | 292 t += base::TimeDelta::FromInternalValue(10); |
303 AddCookieWithExpiration("A", "B", "b4.com", "/", t, base::Time()); | 293 AddCookieWithExpiration("A", "B", "b4.com", "/", t, base::Time()); |
304 t += base::TimeDelta::FromInternalValue(10); | 294 t += base::TimeDelta::FromInternalValue(10); |
305 AddCookieWithExpiration("A", "B", "b5.com", "/", t, base::Time()); | 295 AddCookieWithExpiration("A", "B", "b5.com", "/", t, base::Time()); |
306 DestroyStore(); | 296 DestroyStore(); |
307 | 297 |
308 // Load the store a second time. Before the store finishes loading, add a | 298 // Load the store a second time. Before the store finishes loading, add a |
309 // transient cookie and flush it to disk. | 299 // transient cookie and flush it to disk. |
310 store_ = new SQLitePersistentCookieStore( | 300 store_ = new SQLitePersistentCookieStore( |
311 temp_dir_.GetPath().Append(kCookieFilename), client_task_runner(), | 301 temp_dir_.GetPath().Append(kCookieFilename), client_task_runner_, |
312 background_task_runner(), false, nullptr); | 302 background_task_runner_, false, nullptr); |
313 | 303 |
314 // Posting a blocking task to db_thread_ makes sure that the DB thread waits | 304 // Posting a blocking task to db_thread_ makes sure that the DB thread waits |
315 // until both Load and Flush have been posted to its task queue. | 305 // until both Load and Flush have been posted to its task queue. |
316 background_task_runner()->PostTask( | 306 background_task_runner_->PostTask( |
317 FROM_HERE, base::Bind(&SQLitePersistentCookieStoreTest::WaitOnDBEvent, | 307 FROM_HERE, base::Bind(&SQLitePersistentCookieStoreTest::WaitOnDBEvent, |
318 base::Unretained(this))); | 308 base::Unretained(this))); |
319 store_->Load(base::Bind(&SQLitePersistentCookieStoreTest::OnLoaded, | 309 store_->Load(base::Bind(&SQLitePersistentCookieStoreTest::OnLoaded, |
320 base::Unretained(this))); | 310 base::Unretained(this))); |
321 t += base::TimeDelta::FromInternalValue(10); | 311 t += base::TimeDelta::FromInternalValue(10); |
322 AddCookieWithExpiration("A", "B", "c.com", "/", t, base::Time()); | 312 AddCookieWithExpiration("A", "B", "c.com", "/", t, base::Time()); |
323 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC, | 313 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
324 base::WaitableEvent::InitialState::NOT_SIGNALED); | 314 base::WaitableEvent::InitialState::NOT_SIGNALED); |
325 store_->Flush( | 315 store_->Flush( |
326 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&event))); | 316 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&event))); |
327 | 317 |
328 // Now the DB-thread queue contains: | 318 // Now the DB-thread queue contains: |
329 // (active:) | 319 // (active:) |
330 // 1. Wait (on db_event) | 320 // 1. Wait (on db_event) |
331 // (pending:) | 321 // (pending:) |
332 // 2. "Init And Chain-Load First Domain" | 322 // 2. "Init And Chain-Load First Domain" |
333 // 3. Add Cookie (c.com) | 323 // 3. Add Cookie (c.com) |
334 // 4. Flush Cookie (c.com) | 324 // 4. Flush Cookie (c.com) |
335 db_thread_event_.Signal(); | 325 db_thread_event_.Signal(); |
336 event.Wait(); | 326 event.Wait(); |
337 loaded_event_.Wait(); | 327 loaded_event_.Wait(); |
338 cookies_.clear(); | 328 cookies_.clear(); |
339 DestroyStore(); | 329 DestroyStore(); |
340 | 330 |
341 // Load the store a third time, this time restoring session cookies. The | 331 // Load the store a third time, this time restoring session cookies. The |
342 // store should contain exactly 4 cookies: the 3 persistent, and "c.com", | 332 // store should contain exactly 4 cookies: the 3 persistent, and "c.com", |
343 // which was added during the second cookie store load. | 333 // which was added during the second cookie store load. |
344 store_ = new SQLitePersistentCookieStore( | 334 store_ = new SQLitePersistentCookieStore( |
345 temp_dir_.GetPath().Append(kCookieFilename), client_task_runner(), | 335 temp_dir_.GetPath().Append(kCookieFilename), client_task_runner_, |
346 background_task_runner(), true, nullptr); | 336 background_task_runner_, true, nullptr); |
347 store_->Load(base::Bind(&SQLitePersistentCookieStoreTest::OnLoaded, | 337 store_->Load(base::Bind(&SQLitePersistentCookieStoreTest::OnLoaded, |
348 base::Unretained(this))); | 338 base::Unretained(this))); |
349 loaded_event_.Wait(); | 339 loaded_event_.Wait(); |
350 ASSERT_EQ(4u, cookies_.size()); | 340 ASSERT_EQ(4u, cookies_.size()); |
351 cookies_.clear(); | 341 cookies_.clear(); |
352 } | 342 } |
353 | 343 |
354 // Test that priority load of cookies for a specfic domain key could be | 344 // Test that priority load of cookies for a specfic domain key could be |
355 // completed before the entire store is loaded | 345 // completed before the entire store is loaded |
356 TEST_F(SQLitePersistentCookieStoreTest, TestLoadCookiesForKey) { | 346 TEST_F(SQLitePersistentCookieStoreTest, TestLoadCookiesForKey) { |
357 InitializeStore(false, false); | 347 InitializeStore(false, false); |
358 base::Time t = base::Time::Now(); | 348 base::Time t = base::Time::Now(); |
359 AddCookie("A", "B", "foo.bar", "/", t); | 349 AddCookie("A", "B", "foo.bar", "/", t); |
360 t += base::TimeDelta::FromInternalValue(10); | 350 t += base::TimeDelta::FromInternalValue(10); |
361 AddCookie("A", "B", "www.aaa.com", "/", t); | 351 AddCookie("A", "B", "www.aaa.com", "/", t); |
362 t += base::TimeDelta::FromInternalValue(10); | 352 t += base::TimeDelta::FromInternalValue(10); |
363 AddCookie("A", "B", "travel.aaa.com", "/", t); | 353 AddCookie("A", "B", "travel.aaa.com", "/", t); |
364 t += base::TimeDelta::FromInternalValue(10); | 354 t += base::TimeDelta::FromInternalValue(10); |
365 AddCookie("A", "B", "www.bbb.com", "/", t); | 355 AddCookie("A", "B", "www.bbb.com", "/", t); |
366 DestroyStore(); | 356 DestroyStore(); |
367 | 357 |
| 358 // base::test::ScopedTaskEnvironment runs |background_task_runner_| and |
| 359 // |client_task_runner_| on the same thread. Therefore, when a |
| 360 // |background_task_runner_| task is blocked, |client_task_runner_| tasks |
| 361 // can't run. To allow precise control of |background_task_runner_| without |
| 362 // preventing client tasks to run, use base::ThreadTaskRunnerHandle::Get() |
| 363 // instead of |client_task_runner_| for this test. |
368 store_ = new SQLitePersistentCookieStore( | 364 store_ = new SQLitePersistentCookieStore( |
369 temp_dir_.GetPath().Append(kCookieFilename), client_task_runner(), | 365 temp_dir_.GetPath().Append(kCookieFilename), |
370 background_task_runner(), false, nullptr); | 366 base::ThreadTaskRunnerHandle::Get(), background_task_runner_, false, |
| 367 nullptr); |
371 | 368 |
372 // Posting a blocking task to db_thread_ makes sure that the DB thread waits | 369 // Posting a blocking task to db_thread_ makes sure that the DB thread waits |
373 // until both Load and LoadCookiesForKey have been posted to its task queue. | 370 // until both Load and LoadCookiesForKey have been posted to its task queue. |
374 background_task_runner()->PostTask( | 371 background_task_runner_->PostTask( |
375 FROM_HERE, base::Bind(&SQLitePersistentCookieStoreTest::WaitOnDBEvent, | 372 FROM_HERE, base::Bind(&SQLitePersistentCookieStoreTest::WaitOnDBEvent, |
376 base::Unretained(this))); | 373 base::Unretained(this))); |
377 store_->Load(base::Bind(&SQLitePersistentCookieStoreTest::OnLoaded, | 374 store_->Load(base::Bind(&SQLitePersistentCookieStoreTest::OnLoaded, |
378 base::Unretained(this))); | 375 base::Unretained(this))); |
| 376 base::RunLoop run_loop; |
379 store_->LoadCookiesForKey( | 377 store_->LoadCookiesForKey( |
380 "aaa.com", base::Bind(&SQLitePersistentCookieStoreTest::OnKeyLoaded, | 378 "aaa.com", base::Bind(&SQLitePersistentCookieStoreTest::OnKeyLoaded, |
381 base::Unretained(this))); | 379 base::Unretained(this), run_loop.QuitClosure())); |
382 background_task_runner()->PostTask( | 380 background_task_runner_->PostTask( |
383 FROM_HERE, base::Bind(&SQLitePersistentCookieStoreTest::WaitOnDBEvent, | 381 FROM_HERE, base::Bind(&SQLitePersistentCookieStoreTest::WaitOnDBEvent, |
384 base::Unretained(this))); | 382 base::Unretained(this))); |
385 | 383 |
386 // Now the DB-thread queue contains: | 384 // Now the DB-thread queue contains: |
387 // (active:) | 385 // (active:) |
388 // 1. Wait (on db_event) | 386 // 1. Wait (on db_event) |
389 // (pending:) | 387 // (pending:) |
390 // 2. "Init And Chain-Load First Domain" | 388 // 2. "Init And Chain-Load First Domain" |
391 // 3. Priority Load (aaa.com) | 389 // 3. Priority Load (aaa.com) |
392 // 4. Wait (on db_event) | 390 // 4. Wait (on db_event) |
393 db_thread_event_.Signal(); | 391 db_thread_event_.Signal(); |
394 key_loaded_event_.Wait(); | 392 |
395 ASSERT_EQ(loaded_event_.IsSignaled(), false); | 393 // Wait until the OnKeyLoaded callback has run. |
| 394 run_loop.Run(); |
| 395 EXPECT_FALSE(loaded_event_.IsSignaled()); |
| 396 |
396 std::set<std::string> cookies_loaded; | 397 std::set<std::string> cookies_loaded; |
397 for (CanonicalCookieVector::const_iterator it = cookies_.begin(); | 398 for (CanonicalCookieVector::const_iterator it = cookies_.begin(); |
398 it != cookies_.end(); ++it) { | 399 it != cookies_.end(); ++it) { |
399 cookies_loaded.insert((*it)->Domain().c_str()); | 400 cookies_loaded.insert((*it)->Domain().c_str()); |
400 } | 401 } |
401 cookies_.clear(); | 402 cookies_.clear(); |
402 ASSERT_GT(4U, cookies_loaded.size()); | 403 ASSERT_GT(4U, cookies_loaded.size()); |
403 ASSERT_EQ(true, cookies_loaded.find("www.aaa.com") != cookies_loaded.end()); | 404 ASSERT_EQ(true, cookies_loaded.find("www.aaa.com") != cookies_loaded.end()); |
404 ASSERT_EQ(true, | 405 ASSERT_EQ(true, |
405 cookies_loaded.find("travel.aaa.com") != cookies_loaded.end()); | 406 cookies_loaded.find("travel.aaa.com") != cookies_loaded.end()); |
406 | 407 |
407 db_thread_event_.Signal(); | 408 db_thread_event_.Signal(); |
408 loaded_event_.Wait(); | 409 |
| 410 NetTestSuite::GetScopedTaskEnvironment()->RunUntilIdle(); |
| 411 EXPECT_TRUE(loaded_event_.IsSignaled()); |
| 412 |
409 for (CanonicalCookieVector::const_iterator it = cookies_.begin(); | 413 for (CanonicalCookieVector::const_iterator it = cookies_.begin(); |
410 it != cookies_.end(); ++it) { | 414 it != cookies_.end(); ++it) { |
411 cookies_loaded.insert((*it)->Domain().c_str()); | 415 cookies_loaded.insert((*it)->Domain().c_str()); |
412 } | 416 } |
413 ASSERT_EQ(4U, cookies_loaded.size()); | 417 ASSERT_EQ(4U, cookies_loaded.size()); |
414 ASSERT_EQ(cookies_loaded.find("foo.bar") != cookies_loaded.end(), true); | 418 ASSERT_EQ(cookies_loaded.find("foo.bar") != cookies_loaded.end(), true); |
415 ASSERT_EQ(cookies_loaded.find("www.bbb.com") != cookies_loaded.end(), true); | 419 ASSERT_EQ(cookies_loaded.find("www.bbb.com") != cookies_loaded.end(), true); |
416 cookies_.clear(); | 420 cookies_.clear(); |
417 } | 421 } |
418 | 422 |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
804 EXPECT_TRUE(was_called_with_no_cookies); | 808 EXPECT_TRUE(was_called_with_no_cookies); |
805 | 809 |
806 // Same with trying to load a specific cookie. | 810 // Same with trying to load a specific cookie. |
807 was_called_with_no_cookies = false; | 811 was_called_with_no_cookies = false; |
808 store_->LoadCookiesForKey("foo.bar", base::Bind(WasCalledWithNoCookies, | 812 store_->LoadCookiesForKey("foo.bar", base::Bind(WasCalledWithNoCookies, |
809 &was_called_with_no_cookies)); | 813 &was_called_with_no_cookies)); |
810 EXPECT_TRUE(was_called_with_no_cookies); | 814 EXPECT_TRUE(was_called_with_no_cookies); |
811 } | 815 } |
812 | 816 |
813 } // namespace net | 817 } // namespace net |
OLD | NEW |