| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "android_webview/browser/net/aw_cookie_store_wrapper.h" | 5 #include "android_webview/browser/net/aw_cookie_store_wrapper.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "android_webview/browser/net/init_native_callback.h" | 9 #include "android_webview/browser/net/init_native_callback.h" |
| 10 #include "base/memory/ref_counted_delete_on_message_loop.h" | 10 #include "base/memory/ref_counted_delete_on_message_loop.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 friend class base::RefCountedDeleteOnMessageLoop<NestedSubscription>; | 63 friend class base::RefCountedDeleteOnMessageLoop<NestedSubscription>; |
| 64 friend class base::DeleteHelper<NestedSubscription>; | 64 friend class base::DeleteHelper<NestedSubscription>; |
| 65 | 65 |
| 66 ~NestedSubscription() {} | 66 ~NestedSubscription() {} |
| 67 | 67 |
| 68 void Subscribe(const GURL& url, const std::string& name) { | 68 void Subscribe(const GURL& url, const std::string& name) { |
| 69 GetCookieStore()->AddCallbackForCookie( | 69 GetCookieStore()->AddCallbackForCookie( |
| 70 url, name, base::Bind(&NestedSubscription::OnChanged, this)); | 70 url, name, base::Bind(&NestedSubscription::OnChanged, this)); |
| 71 } | 71 } |
| 72 | 72 |
| 73 void OnChanged(const net::CanonicalCookie& cookie, bool removed) { | 73 void OnChanged(const net::CanonicalCookie& cookie, |
| 74 net::CookieStore::ChangeCause cause) { |
| 74 client_task_runner_->PostTask( | 75 client_task_runner_->PostTask( |
| 75 FROM_HERE, base::Bind(&SubscriptionWrapper::OnChanged, | 76 FROM_HERE, base::Bind(&SubscriptionWrapper::OnChanged, |
| 76 subscription_wrapper_, cookie, removed)); | 77 subscription_wrapper_, cookie, cause)); |
| 77 } | 78 } |
| 78 | 79 |
| 79 base::WeakPtr<SubscriptionWrapper> subscription_wrapper_; | 80 base::WeakPtr<SubscriptionWrapper> subscription_wrapper_; |
| 80 scoped_refptr<base::TaskRunner> client_task_runner_; | 81 scoped_refptr<base::TaskRunner> client_task_runner_; |
| 81 | 82 |
| 82 std::unique_ptr<net::CookieStore::CookieChangedSubscription> subscription_; | 83 std::unique_ptr<net::CookieStore::CookieChangedSubscription> subscription_; |
| 83 | 84 |
| 84 DISALLOW_COPY_AND_ASSIGN(NestedSubscription); | 85 DISALLOW_COPY_AND_ASSIGN(NestedSubscription); |
| 85 }; | 86 }; |
| 86 | 87 |
| 87 void OnChanged(const net::CanonicalCookie& cookie, bool removed) { | 88 void OnChanged(const net::CanonicalCookie& cookie, |
| 88 callback_list_.Notify(cookie, removed); | 89 net::CookieStore::ChangeCause cause) { |
| 90 callback_list_.Notify(cookie, cause); |
| 89 } | 91 } |
| 90 | 92 |
| 91 // The "list" only had one entry, so can just clean up now. | 93 // The "list" only had one entry, so can just clean up now. |
| 92 void OnUnsubscribe() { delete this; } | 94 void OnUnsubscribe() { delete this; } |
| 93 | 95 |
| 94 scoped_refptr<NestedSubscription> nested_subscription_; | 96 scoped_refptr<NestedSubscription> nested_subscription_; |
| 95 net::CookieStore::CookieChangedCallbackList callback_list_; | 97 net::CookieStore::CookieChangedCallbackList callback_list_; |
| 96 base::WeakPtrFactory<SubscriptionWrapper> weak_factory_; | 98 base::WeakPtrFactory<SubscriptionWrapper> weak_factory_; |
| 97 | 99 |
| 98 DISALLOW_COPY_AND_ASSIGN(SubscriptionWrapper); | 100 DISALLOW_COPY_AND_ASSIGN(SubscriptionWrapper); |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 base::Bind(&AwCookieStoreWrapper::RunClosureCallback, | 350 base::Bind(&AwCookieStoreWrapper::RunClosureCallback, |
| 349 weak_factory_.GetWeakPtr(), callback)); | 351 weak_factory_.GetWeakPtr(), callback)); |
| 350 } | 352 } |
| 351 | 353 |
| 352 void AwCookieStoreWrapper::RunClosureCallback(const base::Closure& callback) { | 354 void AwCookieStoreWrapper::RunClosureCallback(const base::Closure& callback) { |
| 353 DCHECK(client_task_runner_->RunsTasksOnCurrentThread()); | 355 DCHECK(client_task_runner_->RunsTasksOnCurrentThread()); |
| 354 callback.Run(); | 356 callback.Run(); |
| 355 } | 357 } |
| 356 | 358 |
| 357 } // namespace android_webview | 359 } // namespace android_webview |
| OLD | NEW |