| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_POWER_FREEZER_CGROUP_PROCESS_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_POWER_FREEZER_CGROUP_PROCESS_MANAGER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_POWER_FREEZER_CGROUP_PROCESS_MANAGER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_POWER_FREEZER_CGROUP_PROCESS_MANAGER_H_ |
| 7 | 7 |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 11 #include "base/macros.h" | 9 #include "base/macros.h" |
| 12 #include "base/process/process_handle.h" | |
| 13 #include "chrome/browser/chromeos/power/renderer_freezer.h" | 10 #include "chrome/browser/chromeos/power/renderer_freezer.h" |
| 14 | 11 |
| 15 namespace chromeos { | 12 namespace chromeos { |
| 16 | 13 |
| 17 // Manages all the processes in the freezer cgroup on Chrome OS. | 14 // Manages all the processes in the freezer cgroup on Chrome OS. |
| 18 class FreezerCgroupProcessManager : public RendererFreezer::Delegate { | 15 class FreezerCgroupProcessManager : public RendererFreezer::Delegate { |
| 19 public: | 16 public: |
| 20 FreezerCgroupProcessManager(); | 17 FreezerCgroupProcessManager(); |
| 21 ~FreezerCgroupProcessManager() override; | 18 virtual ~FreezerCgroupProcessManager(); |
| 22 | 19 |
| 23 // RendererFreezer::Delegate overrides. | 20 // RendererFreezer::Delegate overrides. |
| 24 void SetShouldFreezeRenderer(base::ProcessHandle handle, | 21 virtual bool FreezeRenderers() override; |
| 25 bool frozen) override; | 22 virtual bool ThawRenderers() override; |
| 26 bool FreezeRenderers() override; | 23 virtual bool CanFreezeRenderers() override; |
| 27 bool ThawRenderers() override; | |
| 28 bool CanFreezeRenderers() override; | |
| 29 | 24 |
| 30 private: | 25 private: |
| 31 bool WriteCommandToFile(const std::string& command, | 26 bool WriteCommandToStateFile(const std::string& command); |
| 32 const base::FilePath& file); | |
| 33 | 27 |
| 34 // Control path for the cgroup that is not frozen. | 28 base::FilePath state_path_; |
| 35 base::FilePath default_control_path_; | |
| 36 | |
| 37 // Control and state paths for the cgroup whose processes will be frozen. | |
| 38 base::FilePath to_be_frozen_control_path_; | |
| 39 base::FilePath to_be_frozen_state_path_; | |
| 40 | |
| 41 bool enabled_; | 29 bool enabled_; |
| 42 | 30 |
| 43 DISALLOW_COPY_AND_ASSIGN(FreezerCgroupProcessManager); | 31 DISALLOW_COPY_AND_ASSIGN(FreezerCgroupProcessManager); |
| 44 }; | 32 }; |
| 45 | 33 |
| 46 } // namespace chromeos | 34 } // namespace chromeos |
| 47 | 35 |
| 48 #endif // CHROME_BROWSER_CHROMEOS_POWER_FREEZER_CGROUP_PROCESS_MANAGER_H_ | 36 #endif // CHROME_BROWSER_CHROMEOS_POWER_FREEZER_CGROUP_PROCESS_MANAGER_H_ |
| OLD | NEW |