Add ENABLE_MEDIA_ROUTER define to builds other than Android and iOS.
[chromium-blink-merge.git] / chrome / browser / sync / glue / password_model_worker.h
blobd296b02d3984cd26df446fc5962b789dcb2ed03d
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"
15 namespace base {
16 class WaitableEvent;
19 namespace password_manager {
20 class PasswordStore;
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 {
29 public:
30 PasswordModelWorker(
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;
39 protected:
40 syncer::SyncerError DoWorkAndWaitUntilDoneImpl(
41 const syncer::WorkCallback& work) override;
43 private:
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
52 // observer.
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_