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

Side by Side Diff: components/keyed_service/core/keyed_service_shutdown_notifier.h

Issue 1918083002: Convert //components/[f-n]* from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: … Created 4 years, 7 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 COMPONENTS_KEYED_SERVICE_CORE_KEYED_SERVICE_SHUTDOWN_NOTIFIER_H_ 5 #ifndef COMPONENTS_KEYED_SERVICE_CORE_KEYED_SERVICE_SHUTDOWN_NOTIFIER_H_
6 #define COMPONENTS_KEYED_SERVICE_CORE_KEYED_SERVICE_SHUTDOWN_NOTIFIER_H_ 6 #define COMPONENTS_KEYED_SERVICE_CORE_KEYED_SERVICE_SHUTDOWN_NOTIFIER_H_
7 7
8 #include <memory>
9
8 #include "base/callback_list.h" 10 #include "base/callback_list.h"
9 #include "base/macros.h" 11 #include "base/macros.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "components/keyed_service/core/keyed_service.h" 12 #include "components/keyed_service/core/keyed_service.h"
12 13
13 // This is a helper class for objects that depend on one or more keyed services, 14 // This is a helper class for objects that depend on one or more keyed services,
14 // but which cannot be keyed services themselves, for example because they don't 15 // but which cannot be keyed services themselves, for example because they don't
15 // correspond 1:1 to a context, or because they have a different lifetime. 16 // correspond 1:1 to a context, or because they have a different lifetime.
16 // 17 //
17 // To use this class, add a factory class and declare the dependencies there. 18 // To use this class, add a factory class and declare the dependencies there.
18 // This class (being a KeyedService itself) will be shut down before its 19 // This class (being a KeyedService itself) will be shut down before its
19 // dependencies and notify its observers. 20 // dependencies and notify its observers.
20 class KEYED_SERVICE_EXPORT KeyedServiceShutdownNotifier : public KeyedService { 21 class KEYED_SERVICE_EXPORT KeyedServiceShutdownNotifier : public KeyedService {
21 public: 22 public:
22 using Subscription = base::CallbackList<void()>::Subscription; 23 using Subscription = base::CallbackList<void()>::Subscription;
23 24
24 KeyedServiceShutdownNotifier(); 25 KeyedServiceShutdownNotifier();
25 ~KeyedServiceShutdownNotifier() override; 26 ~KeyedServiceShutdownNotifier() override;
26 27
27 // Subscribe for a notification when the keyed services this object depends on 28 // Subscribe for a notification when the keyed services this object depends on
28 // (as defined by its factory) are shut down. The subscription object can be 29 // (as defined by its factory) are shut down. The subscription object can be
29 // destroyed to unsubscribe. 30 // destroyed to unsubscribe.
30 scoped_ptr<Subscription> Subscribe(const base::Closure& callback); 31 std::unique_ptr<Subscription> Subscribe(const base::Closure& callback);
31 32
32 private: 33 private:
33 // KeyedService implementation: 34 // KeyedService implementation:
34 void Shutdown() override; 35 void Shutdown() override;
35 36
36 base::CallbackList<void()> callback_list_; 37 base::CallbackList<void()> callback_list_;
37 38
38 DISALLOW_COPY_AND_ASSIGN(KeyedServiceShutdownNotifier); 39 DISALLOW_COPY_AND_ASSIGN(KeyedServiceShutdownNotifier);
39 }; 40 };
40 41
41 #endif // COMPONENTS_KEYED_SERVICE_CORE_KEYED_SERVICE_SHUTDOWN_NOTIFIER_H_ 42 #endif // COMPONENTS_KEYED_SERVICE_CORE_KEYED_SERVICE_SHUTDOWN_NOTIFIER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698