| OLD | NEW |
| (Empty) |
| 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 #ifndef CHROME_BROWSER_SYNC_GLUE_EXTENSION_CHANGE_PROCESSOR_H_ | |
| 6 #define CHROME_BROWSER_SYNC_GLUE_EXTENSION_CHANGE_PROCESSOR_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include "base/basictypes.h" | |
| 10 #include "chrome/browser/sync/glue/change_processor.h" | |
| 11 #include "chrome/browser/sync/glue/extension_sync_traits.h" | |
| 12 #include "chrome/browser/sync/internal_api/sync_manager.h" | |
| 13 #include "content/common/content_notification_types.h" | |
| 14 #include "content/common/notification_observer.h" | |
| 15 #include "content/common/notification_registrar.h" | |
| 16 | |
| 17 class ExtensionServiceInterface; | |
| 18 | |
| 19 namespace browser_sync { | |
| 20 | |
| 21 class UnrecoverableErrorHandler; | |
| 22 | |
| 23 // This class is responsible for taking changes from the | |
| 24 // ExtensionService and applying them to the sync_api 'syncable' | |
| 25 // model, and vice versa. All operations and use of this class are | |
| 26 // from the UI thread. | |
| 27 class ExtensionChangeProcessor : public ChangeProcessor, | |
| 28 public NotificationObserver { | |
| 29 public: | |
| 30 // Does not take ownership of |error_handler|. | |
| 31 explicit ExtensionChangeProcessor(UnrecoverableErrorHandler* error_handler); | |
| 32 virtual ~ExtensionChangeProcessor(); | |
| 33 | |
| 34 // NotificationObserver implementation. | |
| 35 // BrowserExtensionProvider -> sync_api model change application. | |
| 36 virtual void Observe(int type, | |
| 37 const NotificationSource& source, | |
| 38 const NotificationDetails& details); | |
| 39 | |
| 40 // ChangeProcessor implementation. | |
| 41 // sync_api model -> BrowserExtensionProvider change application. | |
| 42 virtual void ApplyChangesFromSyncModel( | |
| 43 const sync_api::BaseTransaction* trans, | |
| 44 const sync_api::SyncManager::ChangeRecord* changes, | |
| 45 int change_count); | |
| 46 | |
| 47 protected: | |
| 48 // ChangeProcessor implementation. | |
| 49 virtual void StartImpl(Profile* profile); | |
| 50 virtual void StopImpl(); | |
| 51 | |
| 52 private: | |
| 53 void StartObserving(); | |
| 54 void StopObserving(); | |
| 55 | |
| 56 NotificationRegistrar notification_registrar_; | |
| 57 const ExtensionSyncTraits traits_; | |
| 58 | |
| 59 // Non-NULL iff |running()| is true. | |
| 60 Profile* profile_; | |
| 61 ExtensionServiceInterface* extension_service_; | |
| 62 | |
| 63 DISALLOW_COPY_AND_ASSIGN(ExtensionChangeProcessor); | |
| 64 }; | |
| 65 | |
| 66 } // namespace browser_sync | |
| 67 | |
| 68 #endif // CHROME_BROWSER_SYNC_GLUE_EXTENSION_CHANGE_PROCESSOR_H_ | |
| OLD | NEW |