| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/sync/glue/ui_model_worker.h" | 5 #include "chrome/browser/sync/glue/ui_model_worker.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 } | 61 } |
| 62 | 62 |
| 63 // Create an unsignaled event to wait on. | 63 // Create an unsignaled event to wait on. |
| 64 base::WaitableEvent work_done(false, false); | 64 base::WaitableEvent work_done(false, false); |
| 65 { | 65 { |
| 66 // We lock only to avoid PostTask'ing a NULL pending_work_ (because it | 66 // We lock only to avoid PostTask'ing a NULL pending_work_ (because it |
| 67 // could get Run() in Stop() and call OnTaskCompleted before we post). | 67 // could get Run() in Stop() and call OnTaskCompleted before we post). |
| 68 // The task is owned by the message loop as per usual. | 68 // The task is owned by the message loop as per usual. |
| 69 base::AutoLock lock(lock_); | 69 base::AutoLock lock(lock_); |
| 70 DCHECK(pending_work_.is_null()); | 70 DCHECK(pending_work_.is_null()); |
| 71 UnrecoverableErrorInfo error_info; | |
| 72 pending_work_ = base::Bind(&CallDoWorkAndSignalCallback, work, &work_done, | 71 pending_work_ = base::Bind(&CallDoWorkAndSignalCallback, work, &work_done, |
| 73 base::Unretained(this), &error_info); | 72 base::Unretained(this), &error_info); |
| 74 if (!BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, pending_work_)) { | 73 if (!BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, pending_work_)) { |
| 75 LOG(WARNING) << "Could not post work to UI loop."; | 74 LOG(WARNING) << "Could not post work to UI loop."; |
| 76 pending_work_.Reset(); | 75 pending_work_.Reset(); |
| 77 syncapi_event_.Signal(); | 76 syncapi_event_.Signal(); |
| 78 return error_info; | 77 return error_info; |
| 79 } | 78 } |
| 80 } | 79 } |
| 81 syncapi_event_.Signal(); // Notify that the syncapi produced work for us. | 80 syncapi_event_.Signal(); // Notify that the syncapi produced work for us. |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 } | 126 } |
| 128 | 127 |
| 129 state_ = STOPPED; | 128 state_ = STOPPED; |
| 130 } | 129 } |
| 131 | 130 |
| 132 ModelSafeGroup UIModelWorker::GetModelSafeGroup() { | 131 ModelSafeGroup UIModelWorker::GetModelSafeGroup() { |
| 133 return GROUP_UI; | 132 return GROUP_UI; |
| 134 } | 133 } |
| 135 | 134 |
| 136 } // namespace browser_sync | 135 } // namespace browser_sync |
| OLD | NEW |