OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/sync/glue/file_model_worker.h" |
| 6 |
| 7 #include "base/synchronization/waitable_event.h" |
| 8 #include "content/browser/browser_thread.h" |
| 9 |
| 10 using base::WaitableEvent; |
| 11 |
| 12 namespace browser_sync { |
| 13 |
| 14 void FileModelWorker::DoWorkAndWaitUntilDone(Callback0::Type* work) { |
| 15 if (BrowserThread::CurrentlyOn(BrowserThread::FILE)) { |
| 16 DLOG(WARNING) << "DoWorkAndWaitUntilDone called from the FILE thread."; |
| 17 work->Run(); |
| 18 return; |
| 19 } |
| 20 WaitableEvent done(false, false); |
| 21 if (!BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
| 22 NewRunnableMethod(this, &FileModelWorker::CallDoWorkAndSignalTask, |
| 23 work, &done))) { |
| 24 NOTREACHED() << "Failed to post task to the db thread."; |
| 25 return; |
| 26 } |
| 27 done.Wait(); |
| 28 } |
| 29 |
| 30 void FileModelWorker::CallDoWorkAndSignalTask(Callback0::Type* work, |
| 31 WaitableEvent* done) { |
| 32 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 33 work->Run(); |
| 34 done->Signal(); |
| 35 } |
| 36 |
| 37 ModelSafeGroup FileModelWorker::GetModelSafeGroup() { |
| 38 return GROUP_FILE; |
| 39 } |
| 40 |
| 41 } // namespace browser_sync |
OLD | NEW |