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

Side by Side Diff: base/callback_registry_unittest.nc

Issue 24648002: Rename CallbackRegistry to CallbackList (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Doc fix Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « base/callback_registry_unittest.cc ('k') | chrome/browser/chromeos/settings/cros_settings.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/callback_registry.h"
6
7 #include "base/basictypes.h"
8 #include "base/bind.h"
9 #include "base/bind_helpers.h"
10 #include "base/memory/scoped_ptr.h"
11
12 namespace base {
13
14 class Foo {
15 public:
16 Foo() {}
17 ~Foo() {}
18 };
19
20 class FooListener {
21 public:
22 FooListener() {}
23
24 void GotAScopedFoo(scoped_ptr<Foo> f) { foo_ = f.Pass(); }
25
26 scoped_ptr<Foo> foo_;
27
28 private:
29 DISALLOW_COPY_AND_ASSIGN(FooListener);
30 };
31
32
33 #if defined(NCTEST_MOVE_ONLY_TYPE_PARAMETER) // [r"calling a private constructo r of class"]
34
35 // Callbacks run with a move-only typed parameter.
36 //
37 // CallbackRegistry does not support move-only typed parameters. Notify() is
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
40 // first callback has been run.
41 void WontCompile() {
42 FooListener f;
43 CallbackRegistry<void(scoped_ptr<Foo>)> c1;
44 scoped_ptr<CallbackRegistry<void(scoped_ptr<Foo>)>::Subscription> sub =
45 c1.Add(Bind(&FooListener::GotAScopedFoo, Unretained(&f)));
46 c1.Notify(scoped_ptr<Foo>(new Foo()));
47 }
48
49 #endif
50
51 } // namespace base
OLDNEW
« no previous file with comments | « base/callback_registry_unittest.cc ('k') | chrome/browser/chromeos/settings/cros_settings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698