Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #include "components/sync/engine/model_safe_worker.h" | 5 #include "components/sync/engine/model_safe_worker.h" |
| 6 | 6 |
| 7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 | 9 |
| 10 namespace syncer { | 10 namespace syncer { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 ModelSafeWorker::ModelSafeWorker() {} | 72 ModelSafeWorker::ModelSafeWorker() {} |
| 73 ModelSafeWorker::~ModelSafeWorker() {} | 73 ModelSafeWorker::~ModelSafeWorker() {} |
| 74 | 74 |
| 75 void ModelSafeWorker::RequestStop() { | 75 void ModelSafeWorker::RequestStop() { |
| 76 // Set stop flag. This prevents any *further* tasks from being posted to | 76 // Set stop flag. This prevents any *further* tasks from being posted to |
| 77 // worker threads (see DoWorkAndWaitUntilDone below), but note that one may | 77 // worker threads (see DoWorkAndWaitUntilDone below), but note that one may |
| 78 // already be posted. | 78 // already be posted. |
| 79 stopped_.Set(); | 79 stopped_.Set(); |
| 80 } | 80 } |
| 81 | 81 |
| 82 bool ModelSafeWorker::IsStopped() { | |
|
maxbogue
2016/11/18 18:26:51
IsStopped() is still below DoWorkAndWaitUntilDone
fdoray
2016/11/21 16:57:56
Done.
| |
| 83 return stopped_.IsSet(); | |
| 84 } | |
| 85 | |
| 82 SyncerError ModelSafeWorker::DoWorkAndWaitUntilDone(const WorkCallback& work) { | 86 SyncerError ModelSafeWorker::DoWorkAndWaitUntilDone(const WorkCallback& work) { |
| 83 if (stopped_.IsSet()) | 87 if (stopped_.IsSet()) |
| 84 return CANNOT_DO_WORK; | 88 return CANNOT_DO_WORK; |
| 85 return DoWorkAndWaitUntilDoneImpl(work); | 89 return DoWorkAndWaitUntilDoneImpl(work); |
| 86 } | 90 } |
| 87 | 91 |
| 88 bool ModelSafeWorker::IsStopped() { | |
| 89 return stopped_.IsSet(); | |
| 90 } | |
| 91 | |
| 92 } // namespace syncer | 92 } // namespace syncer |
| OLD | NEW |