Chromium Code Reviews| Index: chrome/browser/background/background_mode_optimizer.h |
| diff --git a/chrome/browser/background/background_mode_optimizer.h b/chrome/browser/background/background_mode_optimizer.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..bc41642d4a76599e18a6ebd127c566a9b656d507 |
| --- /dev/null |
| +++ b/chrome/browser/background/background_mode_optimizer.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_BACKGROUND_BACKGROUND_MODE_OPTIMIZER_H_ |
| +#define CHROME_BROWSER_BACKGROUND_BACKGROUND_MODE_OPTIMIZER_H_ |
| + |
| +#include <memory> |
| + |
| +#include "base/macros.h" |
| +#include "chrome/browser/lifetime/keep_alive_state_observer.h" |
| + |
| +class Browser; |
| + |
| +// BackgroundModeOptimizer is responsible for applying some optimizations to |
| +// save resources (memory) when Chrome runs in background-only mode. |
| +// It tries to restart the browser to release accumulated memory when it |
| +// is considered non distruptive. |
| +class BackgroundModeOptimizer : public KeepAliveStateObserver { |
| + public: |
| + // Creates a new BackgroundModeOptimizer. Can return null if optimizations |
| + // are not supported. |
| + static std::unique_ptr<BackgroundModeOptimizer> Create(); |
|
sky
2016/05/18 19:23:06
nit: constructor/destructor before other methods.
dgn
2016/06/20 17:45:18
Done.
|
| + ~BackgroundModeOptimizer() override; |
| + |
| + // KeepAliveStateObserver implementation |
| + void OnKeepAliveStateChanged(bool is_keeping_alive) override; |
| + void OnKeepAliveRestartStateChanged(bool can_restart) override; |
| + |
| + private: |
| + BackgroundModeOptimizer(); |
| + void TryBrowserRestart(); |
|
sky
2016/05/18 19:23:06
nit: newline between 31/32 and a description for T
dgn
2016/06/20 17:45:18
Done.
|
| + |
| + DISALLOW_COPY_AND_ASSIGN(BackgroundModeOptimizer); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_BACKGROUND_BACKGROUND_MODE_OPTIMIZER_H_ |