Don't preload rarely seen large images
[chromium-blink-merge.git] / components / keyed_service / core / keyed_service_shutdown_notifier.h
blob2f2ca294a76b5dcaf1ef287a1ff4460e7ad3aac5
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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_KEYED_SERVICE_CORE_KEYED_SERVICE_SHUTDOWN_NOTIFIER_H_
6 #define COMPONENTS_KEYED_SERVICE_CORE_KEYED_SERVICE_SHUTDOWN_NOTIFIER_H_
8 #include "base/callback_list.h"
9 #include "components/keyed_service/core/keyed_service.h"
11 // This is a helper class for objects that depend on one or more keyed services,
12 // but which cannot be keyed services themselves, for example because they don't
13 // correspond 1:1 to a context, or because they have a different lifetime.
15 // To use this class, add a factory class and declare the dependencies there.
16 // This class (being a KeyedService itself) will be shut down before its
17 // dependencies and notify its observers.
18 class KEYED_SERVICE_EXPORT KeyedServiceShutdownNotifier : public KeyedService {
19 public:
20 using Subscription = base::CallbackList<void()>::Subscription;
22 KeyedServiceShutdownNotifier();
23 ~KeyedServiceShutdownNotifier() override;
25 // Subscribe for a notification when the keyed services this object depends on
26 // (as defined by its factory) are shut down. The subscription object can be
27 // destroyed to unsubscribe.
28 scoped_ptr<Subscription> Subscribe(const base::Closure& callback);
30 private:
31 // KeyedService implementation:
32 void Shutdown() override;
34 base::CallbackList<void()> callback_list_;
36 DISALLOW_COPY_AND_ASSIGN(KeyedServiceShutdownNotifier);
39 #endif // COMPONENTS_KEYED_SERVICE_CORE_KEYED_SERVICE_SHUTDOWN_NOTIFIER_H_