blob: 48c32680a9ae849cf00b206f9deb3bfa0feb2bea [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
5#ifndef CHROME_BROWSER_LIFETIME_SCOPED_KEEP_ALIVE_H_
6#define CHROME_BROWSER_LIFETIME_SCOPED_KEEP_ALIVE_H_
7
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
29#endif // CHROME_BROWSER_LIFETIME_SCOPED_KEEP_ALIVE_H_