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

Side by Side Diff: components/sync/engine/model_safe_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 | « components/sync/driver/glue/ui_model_worker_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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_ENGINE_MODEL_SAFE_WORKER_H_ 5 #ifndef COMPONENTS_SYNC_ENGINE_MODEL_SAFE_WORKER_H_
6 #define COMPONENTS_SYNC_ENGINE_MODEL_SAFE_WORKER_H_ 6 #define COMPONENTS_SYNC_ENGINE_MODEL_SAFE_WORKER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 60
61 // Soft stop worker by setting stopped_ flag. Called when sync is disabled 61 // Soft stop worker by setting stopped_ flag. Called when sync is disabled
62 // or browser is shutting down. Called on UI loop. 62 // or browser is shutting down. Called on UI loop.
63 virtual void RequestStop(); 63 virtual void RequestStop();
64 64
65 virtual ModelSafeGroup GetModelSafeGroup() = 0; 65 virtual ModelSafeGroup GetModelSafeGroup() = 0;
66 66
67 // Returns true if called on the thread this worker works on. 67 // Returns true if called on the thread this worker works on.
68 virtual bool IsOnModelThread() = 0; 68 virtual bool IsOnModelThread() = 0;
69 69
70 // Return true if the worker was stopped. Thread safe.
71 bool IsStopped();
72
70 protected: 73 protected:
71 ModelSafeWorker(); 74 ModelSafeWorker();
72 virtual ~ModelSafeWorker(); 75 virtual ~ModelSafeWorker();
73 76
74 // Any time the Syncer performs model modifications (e.g employing a 77 // Any time the Syncer performs model modifications (e.g employing a
75 // WriteTransaction), it should be done by this method to ensure it is done 78 // WriteTransaction), it should be done by this method to ensure it is done
76 // from a model-safe thread. 79 // from a model-safe thread.
77 virtual SyncerError DoWorkAndWaitUntilDoneImpl(const WorkCallback& work) = 0; 80 virtual SyncerError DoWorkAndWaitUntilDoneImpl(const WorkCallback& work) = 0;
78 81
79 // Return true if the worker was stopped. Thread safe.
80 bool IsStopped();
81
82 private: 82 private:
83 friend class base::RefCountedThreadSafe<ModelSafeWorker>; 83 friend class base::RefCountedThreadSafe<ModelSafeWorker>;
84 84
85 // Whether the worker should do more work. Set when sync is disabled. 85 // Whether the worker should do more work. Set when sync is disabled.
86 base::AtomicFlag stopped_; 86 base::AtomicFlag stopped_;
87 87
88 DISALLOW_COPY_AND_ASSIGN(ModelSafeWorker); 88 DISALLOW_COPY_AND_ASSIGN(ModelSafeWorker);
89 }; 89 };
90 90
91 // A map that details which ModelSafeGroup each ModelType 91 // A map that details which ModelSafeGroup each ModelType
92 // belongs to. Routing info can change in response to the user enabling / 92 // belongs to. Routing info can change in response to the user enabling /
93 // disabling sync for certain types, as well as model association completions. 93 // disabling sync for certain types, as well as model association completions.
94 typedef std::map<ModelType, ModelSafeGroup> ModelSafeRoutingInfo; 94 typedef std::map<ModelType, ModelSafeGroup> ModelSafeRoutingInfo;
95 95
96 // Caller takes ownership of return value. 96 // Caller takes ownership of return value.
97 std::unique_ptr<base::DictionaryValue> ModelSafeRoutingInfoToValue( 97 std::unique_ptr<base::DictionaryValue> ModelSafeRoutingInfoToValue(
98 const ModelSafeRoutingInfo& routing_info); 98 const ModelSafeRoutingInfo& routing_info);
99 99
100 std::string ModelSafeRoutingInfoToString( 100 std::string ModelSafeRoutingInfoToString(
101 const ModelSafeRoutingInfo& routing_info); 101 const ModelSafeRoutingInfo& routing_info);
102 102
103 ModelTypeSet GetRoutingInfoTypes(const ModelSafeRoutingInfo& routing_info); 103 ModelTypeSet GetRoutingInfoTypes(const ModelSafeRoutingInfo& routing_info);
104 104
105 ModelSafeGroup GetGroupForModelType(const ModelType type, 105 ModelSafeGroup GetGroupForModelType(const ModelType type,
106 const ModelSafeRoutingInfo& routes); 106 const ModelSafeRoutingInfo& routes);
107 107
108 } // namespace syncer 108 } // namespace syncer
109 109
110 #endif // COMPONENTS_SYNC_ENGINE_MODEL_SAFE_WORKER_H_ 110 #endif // COMPONENTS_SYNC_ENGINE_MODEL_SAFE_WORKER_H_
OLDNEW
« no previous file with comments | « components/sync/driver/glue/ui_model_worker_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698