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

Unified Diff: chrome/browser/chromeos/power/freezer_cgroup_process_manager.cc

Issue 2575933002: chromeos: Avoid crash on thaw failure if freezing failed. (Closed)
Patch Set: Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/power/freezer_cgroup_process_manager.cc
diff --git a/chrome/browser/chromeos/power/freezer_cgroup_process_manager.cc b/chrome/browser/chromeos/power/freezer_cgroup_process_manager.cc
index af1fd7e8589d6bed83a2ca65360117ec241cde42..9c20edb7033948a1a224e0e3f3d0adb3bddcd7ab 100644
--- a/chrome/browser/chromeos/power/freezer_cgroup_process_manager.cc
+++ b/chrome/browser/chromeos/power/freezer_cgroup_process_manager.cc
@@ -34,7 +34,9 @@ class FreezerCgroupProcessManager::FileWorker {
explicit FileWorker(scoped_refptr<base::SequencedTaskRunner> file_thread)
: ui_thread_(content::BrowserThread::GetTaskRunnerForThread(
content::BrowserThread::UI)),
- file_thread_(file_thread) {
+ file_thread_(file_thread),
+ enabled_(false),
+ froze_successfully_(false) {
DCHECK(ui_thread_->RunsTasksOnCurrentThread());
}
@@ -78,7 +80,8 @@ class FreezerCgroupProcessManager::FileWorker {
return;
}
- WriteCommandToFile(kFreezeCommand, to_be_frozen_state_path_);
+ froze_successfully_ =
+ WriteCommandToFile(kFreezeCommand, to_be_frozen_state_path_);
}
void ThawRenderers(ResultCallback callback) {
@@ -91,6 +94,13 @@ class FreezerCgroupProcessManager::FileWorker {
}
bool result = WriteCommandToFile(kThawCommand, to_be_frozen_state_path_);
+
+ // TODO(derat): For now, lie and report success if thawing failed but
+ // freezing also failed previously. Remove after weird EBADF and ENOENT
+ // problems tracked at http://crbug.com/661310 are fixed.
+ if (!result && !froze_successfully_)
+ result = true;
+
ui_thread_->PostTask(FROM_HERE, base::Bind(callback, result));
}
@@ -128,6 +138,10 @@ class FreezerCgroupProcessManager::FileWorker {
bool enabled_;
+ // True iff FreezeRenderers() wrote its command successfully the last time it
+ // was called.
+ bool froze_successfully_;
+
DISALLOW_COPY_AND_ASSIGN(FileWorker);
};
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698