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

Side by Side Diff: base/memory/ref_counted_delete_on_message_loop.h

Issue 1800743003: base: Remove some unnecessary const scoped_refptr<>&. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 BASE_MEMORY_REF_COUNTED_DELETE_ON_MESSAGE_LOOP_H_ 5 #ifndef BASE_MEMORY_REF_COUNTED_DELETE_ON_MESSAGE_LOOP_H_
6 #define BASE_MEMORY_REF_COUNTED_DELETE_ON_MESSAGE_LOOP_H_ 6 #define BASE_MEMORY_REF_COUNTED_DELETE_ON_MESSAGE_LOOP_H_
7 7
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/single_thread_task_runner.h" 12 #include "base/single_thread_task_runner.h"
13 13
14 namespace base { 14 namespace base {
15 15
16 // RefCountedDeleteOnMessageLoop is similar to RefCountedThreadSafe, and ensures 16 // RefCountedDeleteOnMessageLoop is similar to RefCountedThreadSafe, and ensures
17 // that the object will be deleted on a specified message loop. 17 // that the object will be deleted on a specified message loop.
18 // 18 //
19 // Sample usage: 19 // Sample usage:
20 // class Foo : public RefCountedDeleteOnMessageLoop<Foo> { 20 // class Foo : public RefCountedDeleteOnMessageLoop<Foo> {
21 // 21 //
22 // Foo(const scoped_refptr<SingleThreadTaskRunner>& loop) 22 // Foo(scoped_refptr<SingleThreadTaskRunner> loop)
23 // : RefCountedDeleteOnMessageLoop<Foo>(loop) { 23 // : RefCountedDeleteOnMessageLoop<Foo>(std::move(loop)) {}
24 // ...
25 // }
26 // ... 24 // ...
27 // private: 25 // private:
28 // friend class RefCountedDeleteOnMessageLoop<Foo>; 26 // friend class RefCountedDeleteOnMessageLoop<Foo>;
29 // friend class DeleteHelper<Foo>; 27 // friend class DeleteHelper<Foo>;
30 // 28 //
31 // ~Foo(); 29 // ~Foo();
32 // }; 30 // };
33 31
34 // TODO(skyostil): Rename this to RefCountedDeleteOnTaskRunner. 32 // TODO(skyostil): Rename this to RefCountedDeleteOnTaskRunner.
35 template <class T> 33 template <class T>
36 class RefCountedDeleteOnMessageLoop : public subtle::RefCountedThreadSafeBase { 34 class RefCountedDeleteOnMessageLoop : public subtle::RefCountedThreadSafeBase {
37 public: 35 public:
38 // This constructor will accept a MessageL00pProxy object, but new code should 36 // This constructor will accept a MessageL00pProxy object, but new code should
39 // prefer a SingleThreadTaskRunner. A SingleThreadTaskRunner for the 37 // prefer a SingleThreadTaskRunner. A SingleThreadTaskRunner for the
40 // MessageLoop on the current thread can be acquired by calling 38 // MessageLoop on the current thread can be acquired by calling
41 // MessageLoop::current()->task_runner(). 39 // MessageLoop::current()->task_runner().
42 RefCountedDeleteOnMessageLoop( 40 RefCountedDeleteOnMessageLoop(
43 const scoped_refptr<SingleThreadTaskRunner>& task_runner) 41 scoped_refptr<SingleThreadTaskRunner> task_runner)
44 : task_runner_(task_runner) { 42 : task_runner_(std::move(task_runner)) {
45 DCHECK(task_runner_); 43 DCHECK(task_runner_);
46 } 44 }
47 45
48 void AddRef() const { 46 void AddRef() const {
49 subtle::RefCountedThreadSafeBase::AddRef(); 47 subtle::RefCountedThreadSafeBase::AddRef();
50 } 48 }
51 49
52 void Release() const { 50 void Release() const {
53 if (subtle::RefCountedThreadSafeBase::Release()) 51 if (subtle::RefCountedThreadSafeBase::Release())
54 DestructOnMessageLoop(); 52 DestructOnMessageLoop();
(...skipping 13 matching lines...) Expand all
68 66
69 scoped_refptr<SingleThreadTaskRunner> task_runner_; 67 scoped_refptr<SingleThreadTaskRunner> task_runner_;
70 68
71 private: 69 private:
72 DISALLOW_COPY_AND_ASSIGN(RefCountedDeleteOnMessageLoop); 70 DISALLOW_COPY_AND_ASSIGN(RefCountedDeleteOnMessageLoop);
73 }; 71 };
74 72
75 } // namespace base 73 } // namespace base
76 74
77 #endif // BASE_MEMORY_REF_COUNTED_DELETE_ON_MESSAGE_LOOP_H_ 75 #endif // BASE_MEMORY_REF_COUNTED_DELETE_ON_MESSAGE_LOOP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698