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); | |
51 SetWorkingLoopToCurrent(); | 50 SetWorkingLoopToCurrent(); |
52 } | 51 } |
53 | 52 |
54 syncer::SyncerError UIModelWorker::DoWorkAndWaitUntilDoneImpl( | 53 syncer::SyncerError UIModelWorker::DoWorkAndWaitUntilDoneImpl( |
55 const syncer::WorkCallback& work) { | 54 const syncer::WorkCallback& work) { |
56 syncer::SyncerError error_info; | 55 syncer::SyncerError error_info; |
57 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 56 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
58 DLOG(WARNING) << "DoWorkAndWaitUntilDone called from " | 57 DLOG(WARNING) << "DoWorkAndWaitUntilDone called from " |
59 << "ui_loop_. Probably a nested invocation?"; | 58 << "ui_loop_. Probably a nested invocation?"; |
60 return work.Run(); | 59 return work.Run(); |
(...skipping 13 matching lines...) Expand all Loading... |
74 } | 73 } |
75 | 74 |
76 syncer::ModelSafeGroup UIModelWorker::GetModelSafeGroup() { | 75 syncer::ModelSafeGroup UIModelWorker::GetModelSafeGroup() { |
77 return syncer::GROUP_UI; | 76 return syncer::GROUP_UI; |
78 } | 77 } |
79 | 78 |
80 UIModelWorker::~UIModelWorker() { | 79 UIModelWorker::~UIModelWorker() { |
81 } | 80 } |
82 | 81 |
83 } // namespace browser_sync | 82 } // namespace browser_sync |
OLD | NEW |