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/password_model_worker.h" 6 7 #include "base/callback.h" 8 #include "base/memory/ref_counted.h" 9 #include "base/task.h" 10 #include "base/synchronization/waitable_event.h" 11 #include "chrome/browser/password_manager/password_store.h" 12 13 using base::WaitableEvent; 14 15 namespace browser_sync { 16 17 PasswordModelWorker::PasswordModelWorker(PasswordStore* password_store) 18 : password_store_(password_store) { 19 DCHECK(password_store); 20 } 21 22 PasswordModelWorker::~PasswordModelWorker() {} 23 24 void PasswordModelWorker::DoWorkAndWaitUntilDone(Callback0::Type* work) { 25 WaitableEvent done(false, false); 26 password_store_->ScheduleTask( 27 NewRunnableMethod(this, &PasswordModelWorker::CallDoWorkAndSignalTask, 28 work, &done)); 29 done.Wait(); 30 } 31 32 void PasswordModelWorker::CallDoWorkAndSignalTask(Callback0::Type* work, 33 WaitableEvent* done) { 34 work->Run(); 35 done->Signal(); 36 } 37 38 ModelSafeGroup PasswordModelWorker::GetModelSafeGroup() { 39 return GROUP_PASSWORD; 40 } 41 42 bool PasswordModelWorker::CurrentThreadIsWorkThread() { 43 // TODO(ncarter): How to determine this? 44 return true; 45 } 46 47 } // namespace browser_sync 48