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

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

Issue 2283373002: Remove unneeded scoped_refptr<>::get() on method binding (Closed)
Patch Set: Created 4 years, 3 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/base/test_completion_callback_unittest.cc ('k') | no next file » | 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.h" 5 #include "net/cookies/cookie_monster.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 2515 matching lines...) Expand 10 before | Expand all | Expand 10 after
2526 // Test that FlushStore() is forwarded to the store and callbacks are posted. 2526 // Test that FlushStore() is forwarded to the store and callbacks are posted.
2527 TEST_F(CookieMonsterTest, FlushStore) { 2527 TEST_F(CookieMonsterTest, FlushStore) {
2528 scoped_refptr<CallbackCounter> counter(new CallbackCounter()); 2528 scoped_refptr<CallbackCounter> counter(new CallbackCounter());
2529 scoped_refptr<FlushablePersistentStore> store(new FlushablePersistentStore()); 2529 scoped_refptr<FlushablePersistentStore> store(new FlushablePersistentStore());
2530 std::unique_ptr<CookieMonster> cm(new CookieMonster(store.get(), nullptr)); 2530 std::unique_ptr<CookieMonster> cm(new CookieMonster(store.get(), nullptr));
2531 2531
2532 ASSERT_EQ(0, store->flush_count()); 2532 ASSERT_EQ(0, store->flush_count());
2533 ASSERT_EQ(0, counter->callback_count()); 2533 ASSERT_EQ(0, counter->callback_count());
2534 2534
2535 // Before initialization, FlushStore() should just run the callback. 2535 // Before initialization, FlushStore() should just run the callback.
2536 cm->FlushStore(base::Bind(&CallbackCounter::Callback, counter.get())); 2536 cm->FlushStore(base::Bind(&CallbackCounter::Callback, counter));
2537 base::RunLoop().RunUntilIdle(); 2537 base::RunLoop().RunUntilIdle();
2538 2538
2539 ASSERT_EQ(0, store->flush_count()); 2539 ASSERT_EQ(0, store->flush_count());
2540 ASSERT_EQ(1, counter->callback_count()); 2540 ASSERT_EQ(1, counter->callback_count());
2541 2541
2542 // NULL callback is safe. 2542 // NULL callback is safe.
2543 cm->FlushStore(base::Closure()); 2543 cm->FlushStore(base::Closure());
2544 base::RunLoop().RunUntilIdle(); 2544 base::RunLoop().RunUntilIdle();
2545 2545
2546 ASSERT_EQ(0, store->flush_count()); 2546 ASSERT_EQ(0, store->flush_count());
2547 ASSERT_EQ(1, counter->callback_count()); 2547 ASSERT_EQ(1, counter->callback_count());
2548 2548
2549 // After initialization, FlushStore() should delegate to the store. 2549 // After initialization, FlushStore() should delegate to the store.
2550 GetAllCookies(cm.get()); // Force init. 2550 GetAllCookies(cm.get()); // Force init.
2551 cm->FlushStore(base::Bind(&CallbackCounter::Callback, counter.get())); 2551 cm->FlushStore(base::Bind(&CallbackCounter::Callback, counter));
2552 base::RunLoop().RunUntilIdle(); 2552 base::RunLoop().RunUntilIdle();
2553 2553
2554 ASSERT_EQ(1, store->flush_count()); 2554 ASSERT_EQ(1, store->flush_count());
2555 ASSERT_EQ(2, counter->callback_count()); 2555 ASSERT_EQ(2, counter->callback_count());
2556 2556
2557 // NULL callback is still safe. 2557 // NULL callback is still safe.
2558 cm->FlushStore(base::Closure()); 2558 cm->FlushStore(base::Closure());
2559 base::RunLoop().RunUntilIdle(); 2559 base::RunLoop().RunUntilIdle();
2560 2560
2561 ASSERT_EQ(2, store->flush_count()); 2561 ASSERT_EQ(2, store->flush_count());
2562 ASSERT_EQ(2, counter->callback_count()); 2562 ASSERT_EQ(2, counter->callback_count());
2563 2563
2564 // If there's no backing store, FlushStore() is always a safe no-op. 2564 // If there's no backing store, FlushStore() is always a safe no-op.
2565 cm.reset(new CookieMonster(nullptr, nullptr)); 2565 cm.reset(new CookieMonster(nullptr, nullptr));
2566 GetAllCookies(cm.get()); // Force init. 2566 GetAllCookies(cm.get()); // Force init.
2567 cm->FlushStore(base::Closure()); 2567 cm->FlushStore(base::Closure());
2568 base::RunLoop().RunUntilIdle(); 2568 base::RunLoop().RunUntilIdle();
2569 2569
2570 ASSERT_EQ(2, counter->callback_count()); 2570 ASSERT_EQ(2, counter->callback_count());
2571 2571
2572 cm->FlushStore(base::Bind(&CallbackCounter::Callback, counter.get())); 2572 cm->FlushStore(base::Bind(&CallbackCounter::Callback, counter));
2573 base::RunLoop().RunUntilIdle(); 2573 base::RunLoop().RunUntilIdle();
2574 2574
2575 ASSERT_EQ(3, counter->callback_count()); 2575 ASSERT_EQ(3, counter->callback_count());
2576 } 2576 }
2577 2577
2578 TEST_F(CookieMonsterTest, SetAllCookies) { 2578 TEST_F(CookieMonsterTest, SetAllCookies) {
2579 scoped_refptr<FlushablePersistentStore> store(new FlushablePersistentStore()); 2579 scoped_refptr<FlushablePersistentStore> store(new FlushablePersistentStore());
2580 std::unique_ptr<CookieMonster> cm(new CookieMonster(store.get(), nullptr)); 2580 std::unique_ptr<CookieMonster> cm(new CookieMonster(store.get(), nullptr));
2581 cm->SetPersistSessionCookies(true); 2581 cm->SetPersistSessionCookies(true);
2582 2582
(...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after
3483 monster()->AddCallbackForCookie( 3483 monster()->AddCallbackForCookie(
3484 test_url_, "abc", 3484 test_url_, "abc",
3485 base::Bind(&RecordCookieChanges, &cookies1, nullptr))); 3485 base::Bind(&RecordCookieChanges, &cookies1, nullptr)));
3486 SetCookie(monster(), test_url_, "abc=def"); 3486 SetCookie(monster(), test_url_, "abc=def");
3487 base::RunLoop().RunUntilIdle(); 3487 base::RunLoop().RunUntilIdle();
3488 EXPECT_EQ(1U, cookies0.size()); 3488 EXPECT_EQ(1U, cookies0.size());
3489 EXPECT_EQ(1U, cookies0.size()); 3489 EXPECT_EQ(1U, cookies0.size());
3490 } 3490 }
3491 3491
3492 } // namespace net 3492 } // namespace net
OLDNEW
« no previous file with comments | « net/base/test_completion_callback_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698