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); |
}; |