Commit a8fcc7e0 authored by Renjie Tang's avatar Renjie Tang Committed by Commit Bot

Covert base::Bind in ios/net to use base::BindOnce and base::BindRepeating.

This is part of the base::Callback migration.

Context: https://cs.chromium.org/chromium/src/docs/callback.md?rcl=9fcc3764aea8f97e9f6de4a9ee61d554e67edcda&l=40


Bug: 1007794
Change-Id: Id473723248de78393f0b2790f518392b86fcedb8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2500181
Commit-Queue: David Roger <droger@chromium.org>
Auto-Submit: Renjie Tang <renjietang@chromium.org>
Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821136}
parent 8c5e3d06
...@@ -198,7 +198,7 @@ class CookieStoreIOS : public net::CookieStore, ...@@ -198,7 +198,7 @@ class CookieStoreIOS : public net::CookieStore,
std::unique_ptr<net::CookieMonster> cookie_monster_; std::unique_ptr<net::CookieMonster> cookie_monster_;
std::unique_ptr<SystemCookieStore> system_store_; std::unique_ptr<SystemCookieStore> system_store_;
bool metrics_enabled_; bool metrics_enabled_;
base::CancelableClosure flush_closure_; base::CancelableOnceClosure flush_closure_;
// Cookie notification methods. // Cookie notification methods.
// The cookie cache is updated from both the system store and the // The cookie cache is updated from both the system store and the
......
...@@ -518,8 +518,9 @@ void CookieStoreIOS::OnSystemCookiesChanged() { ...@@ -518,8 +518,9 @@ void CookieStoreIOS::OnSystemCookiesChanged() {
if (!flush_closure_.IsCancelled()) if (!flush_closure_.IsCancelled())
return; return;
flush_closure_.Reset(base::Bind(&CookieStoreIOS::FlushStore, flush_closure_.Reset(base::BindOnce(&CookieStoreIOS::FlushStore,
weak_factory_.GetWeakPtr(), base::Closure())); weak_factory_.GetWeakPtr(),
base::OnceClosure()));
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, flush_closure_.callback(), base::TimeDelta::FromSeconds(10)); FROM_HERE, flush_closure_.callback(), base::TimeDelta::FromSeconds(10));
} }
......
...@@ -346,8 +346,8 @@ TEST_F(CookieStoreIOSTest, GetAllCookies) { ...@@ -346,8 +346,8 @@ TEST_F(CookieStoreIOSTest, GetAllCookies) {
GetAllCookiesHelperCallback callback; GetAllCookiesHelperCallback callback;
cookie_store->GetCookieListWithOptionsAsync( cookie_store->GetCookieListWithOptionsAsync(
kTestCookieURLFooBar, net::CookieOptions::MakeAllInclusive(), kTestCookieURLFooBar, net::CookieOptions::MakeAllInclusive(),
base::Bind(&GetAllCookiesHelperCallback::Run, base::BindOnce(&GetAllCookiesHelperCallback::Run,
base::Unretained(&callback))); base::Unretained(&callback)));
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
EXPECT_TRUE(callback.did_run()); EXPECT_TRUE(callback.did_run());
EXPECT_EQ(1u, callback.cookie_list().size()); EXPECT_EQ(1u, callback.cookie_list().size());
...@@ -382,7 +382,7 @@ TEST_F(CookieStoreIOSTest, NotifyOnAdd) { ...@@ -382,7 +382,7 @@ TEST_F(CookieStoreIOSTest, NotifyOnAdd) {
std::unique_ptr<net::CookieChangeSubscription> handle = std::unique_ptr<net::CookieChangeSubscription> handle =
store_->GetChangeDispatcher().AddCallbackForCookie( store_->GetChangeDispatcher().AddCallbackForCookie(
kTestCookieURLFooBar, "abc", kTestCookieURLFooBar, "abc",
base::Bind(&RecordCookieChanges, &cookies, &removes)); base::BindRepeating(&RecordCookieChanges, &cookies, &removes));
EXPECT_EQ(0U, cookies.size()); EXPECT_EQ(0U, cookies.size());
EXPECT_EQ(0U, removes.size()); EXPECT_EQ(0U, removes.size());
SetSystemCookie(kTestCookieURLFooBar, "abc", "def"); SetSystemCookie(kTestCookieURLFooBar, "abc", "def");
...@@ -406,7 +406,7 @@ TEST_F(CookieStoreIOSTest, NotifyOnChange) { ...@@ -406,7 +406,7 @@ TEST_F(CookieStoreIOSTest, NotifyOnChange) {
std::unique_ptr<net::CookieChangeSubscription> handle = std::unique_ptr<net::CookieChangeSubscription> handle =
store_->GetChangeDispatcher().AddCallbackForCookie( store_->GetChangeDispatcher().AddCallbackForCookie(
kTestCookieURLFooBar, "abc", kTestCookieURLFooBar, "abc",
base::Bind(&RecordCookieChanges, &cookies, &removes)); base::BindRepeating(&RecordCookieChanges, &cookies, &removes));
EXPECT_EQ(0U, cookies.size()); EXPECT_EQ(0U, cookies.size());
SetSystemCookie(kTestCookieURLFooBar, "abc", "def"); SetSystemCookie(kTestCookieURLFooBar, "abc", "def");
EXPECT_EQ(1U, cookies.size()); EXPECT_EQ(1U, cookies.size());
...@@ -430,7 +430,7 @@ TEST_F(CookieStoreIOSTest, NotifyOnDelete) { ...@@ -430,7 +430,7 @@ TEST_F(CookieStoreIOSTest, NotifyOnDelete) {
std::unique_ptr<net::CookieChangeSubscription> handle = std::unique_ptr<net::CookieChangeSubscription> handle =
store_->GetChangeDispatcher().AddCallbackForCookie( store_->GetChangeDispatcher().AddCallbackForCookie(
kTestCookieURLFooBar, "abc", kTestCookieURLFooBar, "abc",
base::Bind(&RecordCookieChanges, &cookies, &removes)); base::BindRepeating(&RecordCookieChanges, &cookies, &removes));
EXPECT_EQ(0U, cookies.size()); EXPECT_EQ(0U, cookies.size());
DeleteSystemCookie(kTestCookieURLFooBar, "abc"); DeleteSystemCookie(kTestCookieURLFooBar, "abc");
EXPECT_EQ(1U, cookies.size()); EXPECT_EQ(1U, cookies.size());
...@@ -448,7 +448,7 @@ TEST_F(CookieStoreIOSTest, NoNotifyOnNoChange) { ...@@ -448,7 +448,7 @@ TEST_F(CookieStoreIOSTest, NoNotifyOnNoChange) {
std::unique_ptr<net::CookieChangeSubscription> handle = std::unique_ptr<net::CookieChangeSubscription> handle =
store_->GetChangeDispatcher().AddCallbackForCookie( store_->GetChangeDispatcher().AddCallbackForCookie(
kTestCookieURLFooBar, "abc", kTestCookieURLFooBar, "abc",
base::Bind(&RecordCookieChanges, &cookies, nullptr)); base::BindRepeating(&RecordCookieChanges, &cookies, nullptr));
EXPECT_EQ(0U, cookies.size()); EXPECT_EQ(0U, cookies.size());
SetSystemCookie(kTestCookieURLFooBar, "abc", "def"); SetSystemCookie(kTestCookieURLFooBar, "abc", "def");
EXPECT_EQ(1U, cookies.size()); EXPECT_EQ(1U, cookies.size());
...@@ -465,19 +465,19 @@ TEST_F(CookieStoreIOSTest, MultipleNotifies) { ...@@ -465,19 +465,19 @@ TEST_F(CookieStoreIOSTest, MultipleNotifies) {
std::unique_ptr<net::CookieChangeSubscription> handle = std::unique_ptr<net::CookieChangeSubscription> handle =
store_->GetChangeDispatcher().AddCallbackForCookie( store_->GetChangeDispatcher().AddCallbackForCookie(
kTestCookieURLFooBar, "abc", kTestCookieURLFooBar, "abc",
base::Bind(&RecordCookieChanges, &cookies, nullptr)); base::BindRepeating(&RecordCookieChanges, &cookies, nullptr));
std::unique_ptr<net::CookieChangeSubscription> handle2 = std::unique_ptr<net::CookieChangeSubscription> handle2 =
store_->GetChangeDispatcher().AddCallbackForCookie( store_->GetChangeDispatcher().AddCallbackForCookie(
kTestCookieURLFooBaz, "abc", kTestCookieURLFooBaz, "abc",
base::Bind(&RecordCookieChanges, &cookies2, nullptr)); base::BindRepeating(&RecordCookieChanges, &cookies2, nullptr));
std::unique_ptr<net::CookieChangeSubscription> handle3 = std::unique_ptr<net::CookieChangeSubscription> handle3 =
store_->GetChangeDispatcher().AddCallbackForCookie( store_->GetChangeDispatcher().AddCallbackForCookie(
kTestCookieURLFoo, "abc", kTestCookieURLFoo, "abc",
base::Bind(&RecordCookieChanges, &cookies3, nullptr)); base::BindRepeating(&RecordCookieChanges, &cookies3, nullptr));
std::unique_ptr<net::CookieChangeSubscription> handle4 = std::unique_ptr<net::CookieChangeSubscription> handle4 =
store_->GetChangeDispatcher().AddCallbackForCookie( store_->GetChangeDispatcher().AddCallbackForCookie(
kTestCookieURLBarBar, "abc", kTestCookieURLBarBar, "abc",
base::Bind(&RecordCookieChanges, &cookies4, nullptr)); base::BindRepeating(&RecordCookieChanges, &cookies4, nullptr));
SetSystemCookie(kTestCookieURLFooBar, "abc", "def"); SetSystemCookie(kTestCookieURLFooBar, "abc", "def");
SetSystemCookie(kTestCookieURLFooBaz, "abc", "def"); SetSystemCookie(kTestCookieURLFooBaz, "abc", "def");
SetSystemCookie(kTestCookieURLFoo, "abc", "def"); SetSystemCookie(kTestCookieURLFoo, "abc", "def");
...@@ -498,7 +498,7 @@ TEST_F(CookieStoreIOSTest, LessSpecificNestedCookie) { ...@@ -498,7 +498,7 @@ TEST_F(CookieStoreIOSTest, LessSpecificNestedCookie) {
std::unique_ptr<net::CookieChangeSubscription> handle = std::unique_ptr<net::CookieChangeSubscription> handle =
store_->GetChangeDispatcher().AddCallbackForCookie( store_->GetChangeDispatcher().AddCallbackForCookie(
kTestCookieURLFooBaz, "abc", kTestCookieURLFooBaz, "abc",
base::Bind(&RecordCookieChanges, &cookies, nullptr)); base::BindRepeating(&RecordCookieChanges, &cookies, nullptr));
EXPECT_EQ(0U, cookies.size()); EXPECT_EQ(0U, cookies.size());
SetSystemCookie(kTestCookieURLFoo, "abc", "ghi"); SetSystemCookie(kTestCookieURLFoo, "abc", "ghi");
EXPECT_EQ(1U, cookies.size()); EXPECT_EQ(1U, cookies.size());
...@@ -511,7 +511,7 @@ TEST_F(CookieStoreIOSTest, MoreSpecificNestedCookie) { ...@@ -511,7 +511,7 @@ TEST_F(CookieStoreIOSTest, MoreSpecificNestedCookie) {
std::unique_ptr<net::CookieChangeSubscription> handle = std::unique_ptr<net::CookieChangeSubscription> handle =
store_->GetChangeDispatcher().AddCallbackForCookie( store_->GetChangeDispatcher().AddCallbackForCookie(
kTestCookieURLFooBaz, "abc", kTestCookieURLFooBaz, "abc",
base::Bind(&RecordCookieChanges, &cookies, nullptr)); base::BindRepeating(&RecordCookieChanges, &cookies, nullptr));
EXPECT_EQ(0U, cookies.size()); EXPECT_EQ(0U, cookies.size());
SetSystemCookie(kTestCookieURLFooBaz, "abc", "ghi"); SetSystemCookie(kTestCookieURLFooBaz, "abc", "ghi");
EXPECT_EQ(1U, cookies.size()); EXPECT_EQ(1U, cookies.size());
...@@ -524,7 +524,7 @@ TEST_F(CookieStoreIOSTest, MoreSpecificNestedCookieWithSameValue) { ...@@ -524,7 +524,7 @@ TEST_F(CookieStoreIOSTest, MoreSpecificNestedCookieWithSameValue) {
std::unique_ptr<net::CookieChangeSubscription> handle = std::unique_ptr<net::CookieChangeSubscription> handle =
store_->GetChangeDispatcher().AddCallbackForCookie( store_->GetChangeDispatcher().AddCallbackForCookie(
kTestCookieURLFooBaz, "abc", kTestCookieURLFooBaz, "abc",
base::Bind(&RecordCookieChanges, &cookies, nullptr)); base::BindRepeating(&RecordCookieChanges, &cookies, nullptr));
EXPECT_EQ(0U, cookies.size()); EXPECT_EQ(0U, cookies.size());
SetSystemCookie(kTestCookieURLFooBaz, "abc", "def"); SetSystemCookie(kTestCookieURLFooBaz, "abc", "def");
EXPECT_EQ(1U, cookies.size()); EXPECT_EQ(1U, cookies.size());
...@@ -537,7 +537,7 @@ TEST_F(CookieStoreIOSTest, RemoveCallback) { ...@@ -537,7 +537,7 @@ TEST_F(CookieStoreIOSTest, RemoveCallback) {
std::unique_ptr<net::CookieChangeSubscription> handle = std::unique_ptr<net::CookieChangeSubscription> handle =
store_->GetChangeDispatcher().AddCallbackForCookie( store_->GetChangeDispatcher().AddCallbackForCookie(
kTestCookieURLFooBar, "abc", kTestCookieURLFooBar, "abc",
base::Bind(&RecordCookieChanges, &cookies, nullptr)); base::BindRepeating(&RecordCookieChanges, &cookies, nullptr));
EXPECT_EQ(0U, cookies.size()); EXPECT_EQ(0U, cookies.size());
SetSystemCookie(kTestCookieURLFooBar, "abc", "ghi"); SetSystemCookie(kTestCookieURLFooBar, "abc", "ghi");
EXPECT_EQ(2U, cookies.size()); EXPECT_EQ(2U, cookies.size());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment