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

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

Issue 2937963003: Shift cookie system callbacks to OnceCallback to impedance match mojo. (Closed)
Patch Set: Finish Merge Created 3 years, 6 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 #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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 class NewMockPersistentCookieStore 52 class NewMockPersistentCookieStore
53 : public CookieMonster::PersistentCookieStore { 53 : public CookieMonster::PersistentCookieStore {
54 public: 54 public:
55 MOCK_METHOD1(Load, void(const LoadedCallback& loaded_callback)); 55 MOCK_METHOD1(Load, void(const LoadedCallback& loaded_callback));
56 MOCK_METHOD2(LoadCookiesForKey, 56 MOCK_METHOD2(LoadCookiesForKey,
57 void(const std::string& key, 57 void(const std::string& key,
58 const LoadedCallback& loaded_callback)); 58 const LoadedCallback& loaded_callback));
59 MOCK_METHOD1(AddCookie, void(const CanonicalCookie& cc)); 59 MOCK_METHOD1(AddCookie, void(const CanonicalCookie& cc));
60 MOCK_METHOD1(UpdateCookieAccessTime, void(const CanonicalCookie& cc)); 60 MOCK_METHOD1(UpdateCookieAccessTime, void(const CanonicalCookie& cc));
61 MOCK_METHOD1(DeleteCookie, void(const CanonicalCookie& cc)); 61 MOCK_METHOD1(DeleteCookie, void(const CanonicalCookie& cc));
62 virtual void Flush(const base::Closure& callback) { 62 virtual void Flush(base::OnceClosure callback) {
63 if (!callback.is_null()) 63 if (!callback.is_null())
64 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback); 64 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
65 std::move(callback));
65 } 66 }
66 MOCK_METHOD0(SetForceKeepSessionState, void()); 67 MOCK_METHOD0(SetForceKeepSessionState, void());
67 68
68 private: 69 private:
69 virtual ~NewMockPersistentCookieStore() {} 70 virtual ~NewMockPersistentCookieStore() {}
70 }; 71 };
71 72
72 // False means 'less than or equal', so we test both ways for full equal. 73 // False means 'less than or equal', so we test both ways for full equal.
73 MATCHER_P(CookieEquals, expected, "") { 74 MATCHER_P(CookieEquals, expected, "") {
74 return !(arg.FullCompare(expected) || expected.FullCompare(arg)); 75 return !(arg.FullCompare(expected) || expected.FullCompare(arg));
(...skipping 2373 matching lines...) Expand 10 before | Expand all | Expand 10 after
2448 void LoadCookiesForKey(const std::string& key, 2449 void LoadCookiesForKey(const std::string& key,
2449 const LoadedCallback& loaded_callback) override { 2450 const LoadedCallback& loaded_callback) override {
2450 Load(loaded_callback); 2451 Load(loaded_callback);
2451 } 2452 }
2452 2453
2453 void AddCookie(const CanonicalCookie&) override {} 2454 void AddCookie(const CanonicalCookie&) override {}
2454 void UpdateCookieAccessTime(const CanonicalCookie&) override {} 2455 void UpdateCookieAccessTime(const CanonicalCookie&) override {}
2455 void DeleteCookie(const CanonicalCookie&) override {} 2456 void DeleteCookie(const CanonicalCookie&) override {}
2456 void SetForceKeepSessionState() override {} 2457 void SetForceKeepSessionState() override {}
2457 2458
2458 void Flush(const base::Closure& callback) override { 2459 void Flush(base::OnceClosure callback) override {
2459 ++flush_count_; 2460 ++flush_count_;
2460 if (!callback.is_null()) 2461 if (!callback.is_null())
2461 callback.Run(); 2462 std::move(callback).Run();
2462 } 2463 }
2463 2464
2464 int flush_count() { return flush_count_; } 2465 int flush_count() { return flush_count_; }
2465 2466
2466 private: 2467 private:
2467 ~FlushablePersistentStore() override {} 2468 ~FlushablePersistentStore() override {}
2468 2469
2469 volatile int flush_count_; 2470 volatile int flush_count_;
2470 }; 2471 };
2471 2472
(...skipping 959 matching lines...) Expand 10 before | Expand all | Expand 10 after
3431 monster()->AddCallbackForCookie( 3432 monster()->AddCallbackForCookie(
3432 test_url_, "abc", 3433 test_url_, "abc",
3433 base::Bind(&RecordCookieChanges, &cookies1, nullptr))); 3434 base::Bind(&RecordCookieChanges, &cookies1, nullptr)));
3434 SetCookie(monster(), test_url_, "abc=def"); 3435 SetCookie(monster(), test_url_, "abc=def");
3435 base::RunLoop().RunUntilIdle(); 3436 base::RunLoop().RunUntilIdle();
3436 EXPECT_EQ(1U, cookies0.size()); 3437 EXPECT_EQ(1U, cookies0.size());
3437 EXPECT_EQ(1U, cookies0.size()); 3438 EXPECT_EQ(1U, cookies0.size());
3438 } 3439 }
3439 3440
3440 } // namespace net 3441 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698