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

Unified Diff: chrome/browser/lifetime/browser_keep_alive.h

Issue 1376063005: Cleanup: Pull some browser keep alive functions into its own file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/lifetime/browser_keep_alive.h
diff --git a/chrome/browser/lifetime/browser_keep_alive.h b/chrome/browser/lifetime/browser_keep_alive.h
new file mode 100644
index 0000000000000000000000000000000000000000..73047f4362141da069e05375450d64d1da80bee2
--- /dev/null
+++ b/chrome/browser/lifetime/browser_keep_alive.h
@@ -0,0 +1,45 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_LIFETIME_BROWSER_KEEP_ALIVE_H_
+#define CHROME_BROWSER_LIFETIME_BROWSER_KEEP_ALIVE_H_
+
+#include "base/macros.h"
+
+namespace browser_lifetime {
+
+// A class that can be put in a scoped_ptr to represent a "keep alive" resource.
+// Prefer this over IncrementKeepAliveCount() / DecrementKeepAliveCount()
+// whenever possible.
+class ScopedKeepAlive {
+ public:
+ ScopedKeepAlive();
+ ~ScopedKeepAlive();
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ScopedKeepAlive);
+};
+
+// Tells the BrowserList to keep the application alive after the last Browser
+// closes. This is implemented as a count, so callers should pair their calls
+// to IncrementKeepAliveCount() with matching calls to DecrementKeepAliveCount()
+// when they no
+// longer need to keep the application running.
+void IncrementKeepAliveCount();
+
+// Stops keeping the application alive after the last Browser is closed.
+// Should match a previous call to IncrementKeepAliveCount().
+void DecrementKeepAliveCount();
+
+// Returns true if application will continue running after the last Browser
+// closes.
+bool WillKeepAlive();
+
+// Disable browser shutdown for unit tests.
+void DisableShutdownForTesting(bool disable_shutdown_for_testing);
+
+} // namespace browser_lifetime
+
+#endif // CHROME_BROWSER_LIFETIME_BROWSER_KEEP_ALIVE_H_
+
« no previous file with comments | « chrome/browser/lifetime/browser_close_manager_browsertest.cc ('k') | chrome/browser/lifetime/browser_keep_alive.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698