scoped_keep_alive.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. // 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. #ifndef COMPONENTS_KEEP_ALIVE_REGISTRY_SCOPED_KEEP_ALIVE_H_
  5. #define COMPONENTS_KEEP_ALIVE_REGISTRY_SCOPED_KEEP_ALIVE_H_
  6. enum class KeepAliveOrigin;
  7. enum class KeepAliveRestartOption;
  8. // Prevents the BrowserProcess from shutting down. Registers with
  9. // KeepAliveRegistry on creation, and unregisters them on destruction. Use these
  10. // objects with a unique_ptr for easy management.
  11. //
  12. // If you need to access a particular Profile (or its KeyedServices) during the
  13. // same period, you should use a ScopedProfileKeepAlive as well.
  14. //
  15. // 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.
  17. class ScopedKeepAlive {
  18. public:
  19. ScopedKeepAlive(KeepAliveOrigin origin, KeepAliveRestartOption restart);
  20. ScopedKeepAlive(const ScopedKeepAlive&) = delete;
  21. ScopedKeepAlive& operator=(const ScopedKeepAlive&) = delete;
  22. ~ScopedKeepAlive();
  23. private:
  24. const KeepAliveOrigin origin_;
  25. const KeepAliveRestartOption restart_;
  26. };
  27. #endif // COMPONENTS_KEEP_ALIVE_REGISTRY_SCOPED_KEEP_ALIVE_H_