OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_SYNC_GLUE_PASSWORD_CHANGE_PROCESSOR_H_ |
| 6 #define CHROME_BROWSER_SYNC_GLUE_PASSWORD_CHANGE_PROCESSOR_H_ |
| 7 |
| 8 #include "chrome/browser/sync/glue/change_processor.h" |
| 9 |
| 10 #include <vector> |
| 11 |
| 12 #include "base/basictypes.h" |
| 13 #include "base/scoped_ptr.h" |
| 14 #include "chrome/browser/sync/glue/sync_backend_host.h" |
| 15 #include "chrome/common/notification_observer.h" |
| 16 #include "chrome/common/notification_registrar.h" |
| 17 #include "chrome/common/notification_type.h" |
| 18 |
| 19 class PasswordStore; |
| 20 class MessageLoop; |
| 21 class NotificationService; |
| 22 |
| 23 namespace browser_sync { |
| 24 |
| 25 class PasswordModelAssociator; |
| 26 class UnrecoverableErrorHandler; |
| 27 |
| 28 // This class is responsible for taking changes from the password backend and |
| 29 // applying them to the sync_api 'syncable' model, and vice versa. All |
| 30 // operations and use of this class are from the DB thread on Windows and Linux, |
| 31 // or the password thread on Mac. |
| 32 class PasswordChangeProcessor : public ChangeProcessor, |
| 33 public NotificationObserver { |
| 34 public: |
| 35 PasswordChangeProcessor(PasswordModelAssociator* model_associator, |
| 36 PasswordStore* password_store, |
| 37 UnrecoverableErrorHandler* error_handler); |
| 38 virtual ~PasswordChangeProcessor(); |
| 39 |
| 40 // NotificationObserver implementation. |
| 41 // Passwords -> sync_api model change application. |
| 42 virtual void Observe(NotificationType type, |
| 43 const NotificationSource& source, |
| 44 const NotificationDetails& details); |
| 45 |
| 46 // sync_api model -> WebDataService change application. |
| 47 virtual void ApplyChangesFromSyncModel( |
| 48 const sync_api::BaseTransaction* trans, |
| 49 const sync_api::SyncManager::ChangeRecord* changes, |
| 50 int change_count); |
| 51 |
| 52 protected: |
| 53 virtual void StartImpl(Profile* profile); |
| 54 virtual void StopImpl(); |
| 55 |
| 56 private: |
| 57 void StartObserving(); |
| 58 void StopObserving(); |
| 59 |
| 60 // The two models should be associated according to this ModelAssociator. |
| 61 PasswordModelAssociator* model_associator_; |
| 62 |
| 63 // The model we are processing changes from. This is owned by the |
| 64 // WebDataService which is kept alive by our data type controller |
| 65 // holding a reference. |
| 66 PasswordStore* password_store_; |
| 67 |
| 68 NotificationRegistrar notification_registrar_; |
| 69 |
| 70 bool observing_; |
| 71 |
| 72 MessageLoop* expected_loop_; |
| 73 |
| 74 DISALLOW_COPY_AND_ASSIGN(PasswordChangeProcessor); |
| 75 }; |
| 76 |
| 77 } // namespace browser_sync |
| 78 |
| 79 #endif // CHROME_BROWSER_SYNC_GLUE_PASSWORD_CHANGE_PROCESSOR_H_ |
OLD | NEW |