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

Side by Side Diff: components/sync/driver/glue/ui_model_worker.h

Issue 2496723003: [Sync] Signal UIModelWorker to abort on sync shutdown. (Closed)
Patch Set: Fix iOS hopefully. Created 4 years, 1 month 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
« no previous file with comments | « no previous file | components/sync/driver/glue/ui_model_worker.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 COMPONENTS_SYNC_DRIVER_GLUE_UI_MODEL_WORKER_H_ 5 #ifndef COMPONENTS_SYNC_DRIVER_GLUE_UI_MODEL_WORKER_H_
6 #define COMPONENTS_SYNC_DRIVER_GLUE_UI_MODEL_WORKER_H_ 6 #define COMPONENTS_SYNC_DRIVER_GLUE_UI_MODEL_WORKER_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
11 #include "base/synchronization/waitable_event.h"
11 #include "components/sync/engine/model_safe_worker.h" 12 #include "components/sync/engine/model_safe_worker.h"
12 13
13 namespace syncer { 14 namespace syncer {
14 15
15 // A ModelSafeWorker for UI models (e.g. bookmarks) that 16 // A ModelSafeWorker for UI models (e.g. bookmarks) that
16 // accepts work requests from the syncapi that need to be fulfilled 17 // accepts work requests from the syncapi that need to be fulfilled
17 // from the MessageLoop home to the native model. 18 // from the MessageLoop home to the native model.
18 class UIModelWorker : public ModelSafeWorker { 19 class UIModelWorker : public ModelSafeWorker {
19 public: 20 public:
20 explicit UIModelWorker(scoped_refptr<base::SingleThreadTaskRunner> ui_thread); 21 explicit UIModelWorker(scoped_refptr<base::SingleThreadTaskRunner> ui_thread);
21 22
22 // ModelSafeWorker implementation. Called on syncapi SyncerThread. 23 // ModelSafeWorker implementation.
24 void RequestStop() override;
23 ModelSafeGroup GetModelSafeGroup() override; 25 ModelSafeGroup GetModelSafeGroup() override;
24 bool IsOnModelThread() override; 26 bool IsOnModelThread() override;
25 27
26 protected: 28 protected:
27 SyncerError DoWorkAndWaitUntilDoneImpl(const WorkCallback& work) override; 29 SyncerError DoWorkAndWaitUntilDoneImpl(const WorkCallback& work) override;
28 30
29 private: 31 private:
30 ~UIModelWorker() override; 32 ~UIModelWorker() override;
31 33
32 // A reference to the UI thread's task runner. 34 // A reference to the UI thread's task runner.
33 const scoped_refptr<base::SingleThreadTaskRunner> ui_thread_; 35 const scoped_refptr<base::SingleThreadTaskRunner> ui_thread_;
34 36
37 // Signal set when work on native thread is done, aborted due to the thread
38 // being torn down, or aborted due to sync stopping. This is needed because
39 // the UI thread joins the sync thread at shutdown, which creates a deadlock
40 // if the sync thread is waiting on the UI thread. See crbug.com/663600.
41 base::WaitableEvent work_done_or_abandoned_;
42
35 DISALLOW_COPY_AND_ASSIGN(UIModelWorker); 43 DISALLOW_COPY_AND_ASSIGN(UIModelWorker);
36 }; 44 };
37 45
38 } // namespace syncer 46 } // namespace syncer
39 47
40 #endif // COMPONENTS_SYNC_DRIVER_GLUE_UI_MODEL_WORKER_H_ 48 #endif // COMPONENTS_SYNC_DRIVER_GLUE_UI_MODEL_WORKER_H_
OLDNEW
« no previous file with comments | « no previous file | components/sync/driver/glue/ui_model_worker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698