OLD | NEW |
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 #include "base/callback_registry.h" | 5 #include "base/callback_list.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 | 11 |
12 namespace base { | 12 namespace base { |
13 | 13 |
14 class Foo { | 14 class Foo { |
15 public: | 15 public: |
(...skipping 11 matching lines...) Expand all Loading... |
27 | 27 |
28 private: | 28 private: |
29 DISALLOW_COPY_AND_ASSIGN(FooListener); | 29 DISALLOW_COPY_AND_ASSIGN(FooListener); |
30 }; | 30 }; |
31 | 31 |
32 | 32 |
33 #if defined(NCTEST_MOVE_ONLY_TYPE_PARAMETER) // [r"calling a private constructo
r of class"] | 33 #if defined(NCTEST_MOVE_ONLY_TYPE_PARAMETER) // [r"calling a private constructo
r of class"] |
34 | 34 |
35 // Callbacks run with a move-only typed parameter. | 35 // Callbacks run with a move-only typed parameter. |
36 // | 36 // |
37 // CallbackRegistry does not support move-only typed parameters. Notify() is | 37 // CallbackList does not support move-only typed parameters. Notify() is |
38 // designed to take zero or more parameters, and run each registered callback | 38 // designed to take zero or more parameters, and run each registered callback |
39 // with them. With move-only types, the parameter will be set to NULL after the | 39 // with them. With move-only types, the parameter will be set to NULL after the |
40 // first callback has been run. | 40 // first callback has been run. |
41 void WontCompile() { | 41 void WontCompile() { |
42 FooListener f; | 42 FooListener f; |
43 CallbackRegistry<void(scoped_ptr<Foo>)> c1; | 43 CallbackList<void(scoped_ptr<Foo>)> c1; |
44 scoped_ptr<CallbackRegistry<void(scoped_ptr<Foo>)>::Subscription> sub = | 44 scoped_ptr<CallbackList<void(scoped_ptr<Foo>)>::Subscription> sub = |
45 c1.Add(Bind(&FooListener::GotAScopedFoo, Unretained(&f))); | 45 c1.Add(Bind(&FooListener::GotAScopedFoo, Unretained(&f))); |
46 c1.Notify(scoped_ptr<Foo>(new Foo())); | 46 c1.Notify(scoped_ptr<Foo>(new Foo())); |
47 } | 47 } |
48 | 48 |
49 #endif | 49 #endif |
50 | 50 |
51 } // namespace base | 51 } // namespace base |
OLD | NEW |