1 // Copyright (c) 2015 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 COMPONENTS_PASSWORD_MANAGER_SYNC_BROWSER_PASSWORD_MODEL_WORKER_H_
6 #define COMPONENTS_PASSWORD_MANAGER_SYNC_BROWSER_PASSWORD_MODEL_WORKER_H_
8 #include "base/basictypes.h"
9 #include "base/callback_forward.h"
10 #include "base/compiler_specific.h"
11 #include "base/memory/ref_counted.h"
12 #include "sync/internal_api/public/engine/model_safe_worker.h"
18 namespace password_manager
{
22 namespace browser_sync
{
24 // A syncer::ModelSafeWorker for password models that accepts requests
25 // from the syncapi that need to be fulfilled on the password thread,
26 // which is the DB thread on Linux and Windows.
27 class PasswordModelWorker
: public syncer::ModelSafeWorker
{
30 const scoped_refptr
<password_manager::PasswordStore
>& password_store
,
31 syncer::WorkerLoopDestructionObserver
* observer
);
33 // syncer::ModelSafeWorker implementation. Called on syncapi SyncerThread.
34 void RegisterForLoopDestruction() override
;
35 syncer::ModelSafeGroup
GetModelSafeGroup() override
;
36 void RequestStop() override
;
39 syncer::SyncerError
DoWorkAndWaitUntilDoneImpl(
40 const syncer::WorkCallback
& work
) override
;
43 ~PasswordModelWorker() override
;
45 void CallDoWorkAndSignalTask(const syncer::WorkCallback
& work
,
46 base::WaitableEvent
* done
,
47 syncer::SyncerError
* error
);
49 // Called on password thread to add PasswordModelWorker as destruction
51 void RegisterForPasswordLoopDestruction();
53 // |password_store_| is used on password thread but released on UI thread.
54 // Protected by |password_store_lock_|.
55 base::Lock password_store_lock_
;
56 scoped_refptr
<password_manager::PasswordStore
> password_store_
;
57 DISALLOW_COPY_AND_ASSIGN(PasswordModelWorker
);
60 } // namespace browser_sync
62 #endif // COMPONENTS_PASSWORD_MANAGER_SYNC_BROWSER_PASSWORD_MODEL_WORKER_H_