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

Side by Side Diff: android_webview/browser/net/aw_cookie_store_wrapper.cc

Issue 2591963004: Transform RefCountedDeleteOnMessageLoop to RefCountedDeleteOnSequence. (Closed)
Patch Set: similarity Created 3 years, 12 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 | « no previous file | base/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_sequence.h"
11 #include "base/threading/thread_task_runner_handle.h" 11 #include "base/threading/thread_task_runner_handle.h"
12 #include "url/gurl.h" 12 #include "url/gurl.h"
13 13
14 namespace android_webview { 14 namespace android_webview {
15 15
16 namespace { 16 namespace {
17 17
18 // Posts |task| to the thread that the global CookieStore lives on. 18 // Posts |task| to the thread that the global CookieStore lives on.
19 void PostTaskToCookieStoreTaskRunner(const base::Closure& task) { 19 void PostTaskToCookieStoreTaskRunner(const base::Closure& task) {
20 GetCookieStoreTaskRunner()->PostTask(FROM_HERE, task); 20 GetCookieStoreTaskRunner()->PostTask(FROM_HERE, task);
(...skipping 18 matching lines...) Expand all
39 nested_subscription_ = 39 nested_subscription_ =
40 new NestedSubscription(url, name, weak_factory_.GetWeakPtr()); 40 new NestedSubscription(url, name, weak_factory_.GetWeakPtr());
41 return callback_list_.Add(callback); 41 return callback_list_.Add(callback);
42 } 42 }
43 43
44 private: 44 private:
45 // The NestedSubscription is responsible for creating and managing the 45 // The NestedSubscription is responsible for creating and managing the
46 // underlying subscription to the real CookieStore, and posting notifications 46 // underlying subscription to the real CookieStore, and posting notifications
47 // back to |callback_list_|. 47 // back to |callback_list_|.
48 class NestedSubscription 48 class NestedSubscription
49 : public base::RefCountedDeleteOnMessageLoop<NestedSubscription> { 49 : public base::RefCountedDeleteOnSequence<NestedSubscription> {
50 public: 50 public:
51 NestedSubscription(const GURL& url, 51 NestedSubscription(const GURL& url,
52 const std::string& name, 52 const std::string& name,
53 base::WeakPtr<SubscriptionWrapper> subscription_wrapper) 53 base::WeakPtr<SubscriptionWrapper> subscription_wrapper)
54 : base::RefCountedDeleteOnMessageLoop<NestedSubscription>( 54 : base::RefCountedDeleteOnSequence<NestedSubscription>(
55 GetCookieStoreTaskRunner()), 55 GetCookieStoreTaskRunner()),
56 subscription_wrapper_(subscription_wrapper), 56 subscription_wrapper_(subscription_wrapper),
57 client_task_runner_(base::ThreadTaskRunnerHandle::Get()) { 57 client_task_runner_(base::ThreadTaskRunnerHandle::Get()) {
58 PostTaskToCookieStoreTaskRunner( 58 PostTaskToCookieStoreTaskRunner(
59 base::Bind(&NestedSubscription::Subscribe, this, url, name)); 59 base::Bind(&NestedSubscription::Subscribe, this, url, name));
60 } 60 }
61 61
62 private: 62 private:
63 friend class base::RefCountedDeleteOnMessageLoop<NestedSubscription>; 63 friend class base::RefCountedDeleteOnSequence<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, 73 void OnChanged(const net::CanonicalCookie& cookie,
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 base::Bind(&AwCookieStoreWrapper::RunClosureCallback, 350 base::Bind(&AwCookieStoreWrapper::RunClosureCallback,
351 weak_factory_.GetWeakPtr(), callback)); 351 weak_factory_.GetWeakPtr(), callback));
352 } 352 }
353 353
354 void AwCookieStoreWrapper::RunClosureCallback(const base::Closure& callback) { 354 void AwCookieStoreWrapper::RunClosureCallback(const base::Closure& callback) {
355 DCHECK(client_task_runner_->RunsTasksOnCurrentThread()); 355 DCHECK(client_task_runner_->RunsTasksOnCurrentThread());
356 callback.Run(); 356 callback.Run();
357 } 357 }
358 358
359 } // namespace android_webview 359 } // namespace android_webview
OLDNEW
« no previous file with comments | « no previous file | base/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698