| 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 "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/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 } | 40 } |
| 41 | 41 |
| 42 } // namespace | 42 } // namespace |
| 43 | 43 |
| 44 UIModelWorker::UIModelWorker(syncer::WorkerLoopDestructionObserver* observer) | 44 UIModelWorker::UIModelWorker(syncer::WorkerLoopDestructionObserver* observer) |
| 45 : syncer::ModelSafeWorker(observer) { | 45 : syncer::ModelSafeWorker(observer) { |
| 46 } | 46 } |
| 47 | 47 |
| 48 void UIModelWorker::RegisterForLoopDestruction() { | 48 void UIModelWorker::RegisterForLoopDestruction() { |
| 49 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 49 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 50 base::MessageLoop::current()->AddDestructionObserver(this); |
| 50 SetWorkingLoopToCurrent(); | 51 SetWorkingLoopToCurrent(); |
| 51 } | 52 } |
| 52 | 53 |
| 53 syncer::SyncerError UIModelWorker::DoWorkAndWaitUntilDoneImpl( | 54 syncer::SyncerError UIModelWorker::DoWorkAndWaitUntilDoneImpl( |
| 54 const syncer::WorkCallback& work) { | 55 const syncer::WorkCallback& work) { |
| 55 syncer::SyncerError error_info; | 56 syncer::SyncerError error_info; |
| 56 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 57 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| 57 DLOG(WARNING) << "DoWorkAndWaitUntilDone called from " | 58 DLOG(WARNING) << "DoWorkAndWaitUntilDone called from " |
| 58 << "ui_loop_. Probably a nested invocation?"; | 59 << "ui_loop_. Probably a nested invocation?"; |
| 59 return work.Run(); | 60 return work.Run(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 73 } | 74 } |
| 74 | 75 |
| 75 syncer::ModelSafeGroup UIModelWorker::GetModelSafeGroup() { | 76 syncer::ModelSafeGroup UIModelWorker::GetModelSafeGroup() { |
| 76 return syncer::GROUP_UI; | 77 return syncer::GROUP_UI; |
| 77 } | 78 } |
| 78 | 79 |
| 79 UIModelWorker::~UIModelWorker() { | 80 UIModelWorker::~UIModelWorker() { |
| 80 } | 81 } |
| 81 | 82 |
| 82 } // namespace browser_sync | 83 } // namespace browser_sync |
| OLD | NEW |