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

Unified Diff: components/history/core/browser/history_model_worker.h

Issue 2757193003: [Sync] Do not deadlock when joining sync thread with a pending HistoryModelWorker task. (Closed)
Patch Set: fix comment Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/history/core/browser/BUILD.gn ('k') | components/history/core/browser/history_model_worker.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/history/core/browser/history_model_worker.h
diff --git a/components/history/core/browser/history_model_worker.h b/components/history/core/browser/history_model_worker.h
index 6421c64d3a198d1080cc5ccb00a04d219dbcea03..5cdb545b03b6b376d6627ac43db7704b9baa7269 100644
--- a/components/history/core/browser/history_model_worker.h
+++ b/components/history/core/browser/history_model_worker.h
@@ -11,10 +11,13 @@
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/single_thread_task_runner.h"
+#include "base/synchronization/lock.h"
+#include "base/synchronization/waitable_event.h"
#include "base/task/cancelable_task_tracker.h"
#include "components/sync/engine/model_safe_worker.h"
namespace history {
+class HistoryDBTask;
class HistoryService;
}
@@ -29,6 +32,7 @@ class HistoryModelWorker : public syncer::ModelSafeWorker {
const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread);
// syncer::ModelSafeWorker implementation.
+ void RequestStop() override;
syncer::ModelSafeGroup GetModelSafeGroup() override;
bool IsOnModelThread() override;
@@ -39,15 +43,34 @@ class HistoryModelWorker : public syncer::ModelSafeWorker {
private:
~HistoryModelWorker() override;
+ void ScheduleHistoryDBTaskFromUIThread(
+ std::unique_ptr<history::HistoryDBTask> worker_task,
+ syncer::SyncerError* error);
+
const base::WeakPtr<history::HistoryService> history_service_;
// A reference to the UI thread's task runner.
const scoped_refptr<base::SingleThreadTaskRunner> ui_thread_;
+ // Signaled when a WorkCallback posted by DoWorkAndWaitUntilDoneImpl()
+ // finishes to run or is abandoned. Reset at the beginning of
+ // DoWorkAndWaitUntilDoneImpl().
+ base::WaitableEvent work_done_or_abandoned_;
+
+ // True if DoWorkAndWaitUntilDoneImpl() is blocked on a UI task.
+ bool ui_task_pending_ = false;
+
+ // Synchronizes accesses to |ui_task_pending_| and calls to RequestStop(),
+ // IsStopped() and work_done_or_abandoned_.Reset().
+ base::Lock lock_;
+
// Helper object to make sure we don't leave tasks running on the history
// thread.
std::unique_ptr<base::CancelableTaskTracker> cancelable_tracker_;
+ // Verifies that calls to DoWorkAndWaitUntilDoneImpl() are sequenced.
+ base::SequenceChecker sequence_checker_;
+
DISALLOW_COPY_AND_ASSIGN(HistoryModelWorker);
};
« no previous file with comments | « components/history/core/browser/BUILD.gn ('k') | components/history/core/browser/history_model_worker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698