| 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 "sync/internal_api/public/engine/model_safe_worker.h" | 5 #include "components/sync/engine/model_safe_worker.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| 11 #include "base/threading/thread_task_runner_handle.h" | 11 #include "base/threading/thread_task_runner_handle.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 | 13 |
| 14 namespace syncer { | 14 namespace syncer { |
| 15 | 15 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 base::AutoLock al(stopped_lock_); | 114 base::AutoLock al(stopped_lock_); |
| 115 stopped_ = true; | 115 stopped_ = true; |
| 116 | 116 |
| 117 // Must signal to unblock syncer if it's waiting for a posted task to | 117 // Must signal to unblock syncer if it's waiting for a posted task to |
| 118 // finish. At this point, all pending tasks posted to the loop have been | 118 // finish. At this point, all pending tasks posted to the loop have been |
| 119 // destroyed (see MessageLoop::~MessageLoop). So syncer will be blocked | 119 // destroyed (see MessageLoop::~MessageLoop). So syncer will be blocked |
| 120 // indefinitely without signaling here. | 120 // indefinitely without signaling here. |
| 121 work_done_or_stopped_.Signal(); | 121 work_done_or_stopped_.Signal(); |
| 122 | 122 |
| 123 DVLOG(1) << ModelSafeGroupToString(GetModelSafeGroup()) | 123 DVLOG(1) << ModelSafeGroupToString(GetModelSafeGroup()) |
| 124 << " worker stops on destruction of its working thread."; | 124 << " worker stops on destruction of its working thread."; |
| 125 } | 125 } |
| 126 | 126 |
| 127 { | 127 { |
| 128 base::AutoLock l(working_task_runner_lock_); | 128 base::AutoLock l(working_task_runner_lock_); |
| 129 working_task_runner_ = NULL; | 129 working_task_runner_ = NULL; |
| 130 } | 130 } |
| 131 | 131 |
| 132 if (observer_) | 132 if (observer_) |
| 133 observer_->OnWorkerLoopDestroyed(GetModelSafeGroup()); | 133 observer_->OnWorkerLoopDestroyed(GetModelSafeGroup()); |
| 134 } | 134 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 return; | 191 return; |
| 192 DCHECK(working_task_runner_->BelongsToCurrentThread()); | 192 DCHECK(working_task_runner_->BelongsToCurrentThread()); |
| 193 } | 193 } |
| 194 | 194 |
| 195 DCHECK(stopped_); | 195 DCHECK(stopped_); |
| 196 base::MessageLoop::current()->RemoveDestructionObserver(this); | 196 base::MessageLoop::current()->RemoveDestructionObserver(this); |
| 197 unregister_done_callback.Run(GetModelSafeGroup()); | 197 unregister_done_callback.Run(GetModelSafeGroup()); |
| 198 } | 198 } |
| 199 | 199 |
| 200 } // namespace syncer | 200 } // namespace syncer |
| OLD | NEW |