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

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

Issue 1708343002: Add ScopedKeepAlive to c/b/lifetime (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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/scoped_keep_alive.h
diff --git a/chrome/browser/lifetime/scoped_keep_alive.h b/chrome/browser/lifetime/scoped_keep_alive.h
new file mode 100644
index 0000000000000000000000000000000000000000..0f67ad5a293117814a440ad92fe5914ac9810299
--- /dev/null
+++ b/chrome/browser/lifetime/scoped_keep_alive.h
@@ -0,0 +1,37 @@
+// Copyright 2016 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_SCOPED_KEEP_ALIVE_H_
+#define CHROME_BROWSER_LIFETIME_SCOPED_KEEP_ALIVE_H_
+
+#include <string>
+
+#include "base/macros.h"
+#include "chrome/browser/lifetime/keep_alive_registry.h"
+
+// Registers tokens with KeepAliveRegistry on creation and unregisters them
+// on destruction.
+//
+// These tokens should be descriptive of what the KeepAlive's
+// lifetime is tied to, to help with debugging.
+//
+// TODO(dgn)
+// When registering a token, indictations of which kind of optimizations would
+// be allowed during the KeepAlive's lifetime should be provided. This allows
+// to take some liberties with the state of the browser to optimize the resource
+// consumption.
+//
+// Use these objects with a scoped_ptr for easy management of the tokens.
+class ScopedKeepAlive {
+ public:
+ explicit ScopedKeepAlive(const std::string& token);
+ ~ScopedKeepAlive();
+
+ private:
+ std::string token_;
sky 2016/02/19 21:02:49 const
dgn 2016/02/22 18:01:20 Done.
+
+ DISALLOW_COPY_AND_ASSIGN(ScopedKeepAlive);
+};
+
+#endif // CHROME_BROWSER_LIFETIME_SCOPED_KEEP_ALIVE_H_

Powered by Google App Engine
This is Rietveld 408576698