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_ |