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

Side by Side Diff: chrome/browser/background/background_mode_optimizer.h

Issue 1931503002: Add BackgroundModeOptimizer that can restart the browser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@PushKeepAlive
Patch Set: cleanup, enable by default (that's just to verify the tests) Created 4 years, 5 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 unified diff | Download patch
OLDNEW
(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_BACKGROUND_BACKGROUND_MODE_OPTIMIZER_H_
6 #define CHROME_BROWSER_BACKGROUND_BACKGROUND_MODE_OPTIMIZER_H_
7
8 #include <memory>
9
10 #include "base/macros.h"
11 #include "chrome/browser/lifetime/keep_alive_state_observer.h"
12 #include "chrome/browser/ui/browser_list_observer.h"
13
14 class Browser;
15
16 // BackgroundModeOptimizer is responsible for applying some optimizations to
17 // save resources (memory) when Chrome runs in background-only mode.
18 // It tries to restart the browser to release accumulated memory when it
19 // is considered non distruptive.
20 class BackgroundModeOptimizer : public KeepAliveStateObserver,
21 chrome::BrowserListObserver {
22 public:
23 ~BackgroundModeOptimizer() override;
24
25 // Creates a new BackgroundModeOptimizer. Can return null if optimizations
26 // are not supported.
27 static std::unique_ptr<BackgroundModeOptimizer> Create();
28
29 // KeepAliveStateObserver implementation
30 void OnKeepAliveStateChanged(bool is_keeping_alive) override;
31 void OnKeepAliveRestartStateChanged(bool can_restart) override;
32
33 // chrome::BrowserListObserver implementation.
34 void OnBrowserAdded(Browser* browser) override;
35
36 private:
37 BackgroundModeOptimizer();
38
39 // Attempt to stop the browser and restart it in the background.
40 void TryBrowserRestart();
41
42 bool browser_was_added_;
43
44 DISALLOW_COPY_AND_ASSIGN(BackgroundModeOptimizer);
45 };
46
47 #endif // CHROME_BROWSER_BACKGROUND_BACKGROUND_MODE_OPTIMIZER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698