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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_SYNC_GLUE_PASSWORD_MODEL_WORKER_H_
6 #define CHROME_BROWSER_SYNC_GLUE_PASSWORD_MODEL_WORKER_H_
8 #include "sync/internal_api/public/engine/model_safe_worker.h"
10 #include "base/basictypes.h"
11 #include "base/callback_forward.h"
12 #include "base/compiler_specific.h"
13 #include "base/memory/ref_counted.h"
19 namespace password_manager
{
23 namespace browser_sync
{
25 // A syncer::ModelSafeWorker for password models that accepts requests
26 // from the syncapi that need to be fulfilled on the password thread,
27 // which is the DB thread on Linux and Windows.
28 class PasswordModelWorker
: public syncer::ModelSafeWorker
{
31 const scoped_refptr
<password_manager::PasswordStore
>& password_store
,
32 syncer::WorkerLoopDestructionObserver
* observer
);
34 // syncer::ModelSafeWorker implementation. Called on syncapi SyncerThread.
35 void RegisterForLoopDestruction() override
;
36 syncer::ModelSafeGroup
GetModelSafeGroup() override
;
37 void RequestStop() override
;
40 syncer::SyncerError
DoWorkAndWaitUntilDoneImpl(
41 const syncer::WorkCallback
& work
) override
;
44 ~PasswordModelWorker() override
;
46 void CallDoWorkAndSignalTask(
47 const syncer::WorkCallback
& work
,
48 base::WaitableEvent
* done
,
49 syncer::SyncerError
* error
);
51 // Called on password thread to add PasswordModelWorker as destruction
53 void RegisterForPasswordLoopDestruction();
55 // |password_store_| is used on password thread but released on UI thread.
56 // Protected by |password_store_lock_|.
57 base::Lock password_store_lock_
;
58 scoped_refptr
<password_manager::PasswordStore
> password_store_
;
59 DISALLOW_COPY_AND_ASSIGN(PasswordModelWorker
);
62 } // namespace browser_sync
64 #endif // CHROME_BROWSER_SYNC_GLUE_PASSWORD_MODEL_WORKER_H_