blob: 8260c803b0a000f590486d5b5ab605d89983bf7a [file] [log] [blame]
dgn3d351ad12016-02-26 17:36:451// Copyright 2016 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
Michael Giuffrida2dbce0d12017-09-02 03:30:595#ifndef COMPONENTS_KEEP_ALIVE_REGISTRY_SCOPED_KEEP_ALIVE_H_
6#define COMPONENTS_KEEP_ALIVE_REGISTRY_SCOPED_KEEP_ALIVE_H_
dgn3d351ad12016-02-26 17:36:457
8#include "base/macros.h"
9
10enum class KeepAliveOrigin;
dgn3563ecaf2016-03-09 19:28:2611enum class KeepAliveRestartOption;
dgn3d351ad12016-02-26 17:36:4512
13// Registers with KeepAliveRegistry on creation and unregisters them
14// on destruction. Use these objects with a scoped_ptr for easy management.
dgn43f25e42016-07-18 15:46:1715// Note: The registration will hit a CHECK if it happens while we are
16// shutting down. Caller code should make sure that this can't happen.
dgn3d351ad12016-02-26 17:36:4517class ScopedKeepAlive {
18 public:
dgn3563ecaf2016-03-09 19:28:2619 ScopedKeepAlive(KeepAliveOrigin origin, KeepAliveRestartOption restart);
dgn3d351ad12016-02-26 17:36:4520 ~ScopedKeepAlive();
21
22 private:
23 const KeepAliveOrigin origin_;
dgn3563ecaf2016-03-09 19:28:2624 const KeepAliveRestartOption restart_;
dgn3d351ad12016-02-26 17:36:4525
26 DISALLOW_COPY_AND_ASSIGN(ScopedKeepAlive);
27};
28
Michael Giuffrida2dbce0d12017-09-02 03:30:5929#endif // COMPONENTS_KEEP_ALIVE_REGISTRY_SCOPED_KEEP_ALIVE_H_