Omnibox: Fixes Allow-To-Be-Default-Match Code for HistoryQuick Provider
[chromium-blink-merge.git] / base / callback_list_unittest.nc
blob2d464cf1f1ba9c50488d3d9028d3d4110b5ae322
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.
5 #include "base/callback_list.h"
7 #include "base/basictypes.h"
8 #include "base/bind.h"
9 #include "base/bind_helpers.h"
10 #include "base/memory/scoped_ptr.h"
12 namespace base {
14 class Foo {
15  public:
16   Foo() {}
17   ~Foo() {}
20 class FooListener {
21  public:
22   FooListener() {}
24   void GotAScopedFoo(scoped_ptr<Foo> f) { foo_ = f.Pass(); }
26   scoped_ptr<Foo> foo_;
28  private:
29   DISALLOW_COPY_AND_ASSIGN(FooListener);
33 #if defined(NCTEST_MOVE_ONLY_TYPE_PARAMETER)  // [r"calling a private constructor of class"]
35 // Callbacks run with a move-only typed parameter.
37 // CallbackList 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   CallbackList<void(scoped_ptr<Foo>)> c1;
44   scoped_ptr<CallbackList<void(scoped_ptr<Foo>)>::Subscription> sub =
45       c1.Add(Bind(&FooListener::GotAScopedFoo, Unretained(&f)));
46   c1.Notify(scoped_ptr<Foo>(new Foo()));
49 #endif
51 }  // namespace base