Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 5 #ifndef CHROME_BROWSER_LIFETIME_SCOPED_KEEP_ALIVE_H_ | |
| 6 #define CHROME_BROWSER_LIFETIME_SCOPED_KEEP_ALIVE_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/macros.h" | |
| 11 #include "chrome/browser/lifetime/keep_alive_registry.h" | |
| 12 | |
| 13 // Registers tokens with KeepAliveRegistry on creation and unregisters them | |
| 14 // on destruction. | |
| 15 // | |
| 16 // These tokens should be descriptive of what the KeepAlive's | |
| 17 // lifetime is tied to, to help with debugging. | |
| 18 // | |
| 19 // TODO(dgn) | |
| 20 // When registering a token, indictations of which kind of optimizations would | |
| 21 // be allowed during the KeepAlive's lifetime should be provided. This allows | |
| 22 // to take some liberties with the state of the browser to optimize the resource | |
| 23 // consumption. | |
| 24 // | |
| 25 // Use these objects with a scoped_ptr for easy management of the tokens. | |
| 26 class ScopedKeepAlive { | |
| 27 public: | |
| 28 explicit ScopedKeepAlive(const std::string& token); | |
| 29 ~ScopedKeepAlive(); | |
| 30 | |
| 31 private: | |
| 32 std::string token_; | |
|
sky
2016/02/19 21:02:49
const
dgn
2016/02/22 18:01:20
Done.
| |
| 33 | |
| 34 DISALLOW_COPY_AND_ASSIGN(ScopedKeepAlive); | |
| 35 }; | |
| 36 | |
| 37 #endif // CHROME_BROWSER_LIFETIME_SCOPED_KEEP_ALIVE_H_ | |
| OLD | NEW |