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

Side by Side Diff: tools/android/forwarder2/self_deleter_helper.h

Issue 1641513004: Update //base to chromium 9659b08ea5a34f889dc4166217f438095ddc10d2 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 10 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef TOOLS_ANDROID_FORWARDER2_SELF_DELETER_HELPER_H_ 5 #ifndef TOOLS_ANDROID_FORWARDER2_SELF_DELETER_HELPER_H_
6 #define TOOLS_ANDROID_FORWARDER2_SELF_DELETER_HELPER_H_ 6 #define TOOLS_ANDROID_FORWARDER2_SELF_DELETER_HELPER_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/message_loop/message_loop_proxy.h"
17 16
18 namespace base { 17 namespace base {
19 18
20 class SingleThreadTaskRunner; 19 class SingleThreadTaskRunner;
21 20
22 } // namespace base 21 } // namespace base
23 22
24 namespace forwarder2 { 23 namespace forwarder2 {
25 24
26 // Helper template class to be used in the following case: 25 // Helper template class to be used in the following case:
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 // scoped_ptr<Object> object_; 91 // scoped_ptr<Object> object_;
93 // }; 92 // };
94 // 93 //
95 template <typename T> 94 template <typename T>
96 class SelfDeleterHelper { 95 class SelfDeleterHelper {
97 public: 96 public:
98 typedef base::Callback<void (scoped_ptr<T>)> DeletionCallback; 97 typedef base::Callback<void (scoped_ptr<T>)> DeletionCallback;
99 98
100 SelfDeleterHelper(T* self_deleting_object, 99 SelfDeleterHelper(T* self_deleting_object,
101 const DeletionCallback& deletion_callback) 100 const DeletionCallback& deletion_callback)
102 : construction_runner_(base::MessageLoopProxy::current()), 101 : construction_runner_(base::MessageLoop::current()->task_runner()),
103 self_deleting_object_(self_deleting_object), 102 self_deleting_object_(self_deleting_object),
104 deletion_callback_(deletion_callback), 103 deletion_callback_(deletion_callback),
105 weak_ptr_factory_(this) { 104 weak_ptr_factory_(this) {}
106 }
107 105
108 ~SelfDeleterHelper() { 106 ~SelfDeleterHelper() {
109 DCHECK(construction_runner_->RunsTasksOnCurrentThread()); 107 DCHECK(construction_runner_->RunsTasksOnCurrentThread());
110 } 108 }
111 109
112 void MaybeSelfDeleteSoon() { 110 void MaybeSelfDeleteSoon() {
113 DCHECK(!construction_runner_->RunsTasksOnCurrentThread()); 111 DCHECK(!construction_runner_->RunsTasksOnCurrentThread());
114 construction_runner_->PostTask( 112 construction_runner_->PostTask(
115 FROM_HERE, 113 FROM_HERE,
116 base::Bind(&SelfDeleterHelper::SelfDelete, 114 base::Bind(&SelfDeleterHelper::SelfDelete,
(...skipping 15 matching lines...) Expand all
132 // that any WeakPtrs to Controller are invalidated before its members 130 // that any WeakPtrs to Controller are invalidated before its members
133 // variable's destructors are executed, rendering them invalid. 131 // variable's destructors are executed, rendering them invalid.
134 base::WeakPtrFactory<SelfDeleterHelper<T> > weak_ptr_factory_; 132 base::WeakPtrFactory<SelfDeleterHelper<T> > weak_ptr_factory_;
135 133
136 DISALLOW_COPY_AND_ASSIGN(SelfDeleterHelper); 134 DISALLOW_COPY_AND_ASSIGN(SelfDeleterHelper);
137 }; 135 };
138 136
139 } // namespace forwarder2 137 } // namespace forwarder2
140 138
141 #endif // TOOLS_ANDROID_FORWARDER2_SELF_DELETER_HELPER_H_ 139 #endif // TOOLS_ANDROID_FORWARDER2_SELF_DELETER_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698