| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_SYNC_GLUE_THEME_CHANGE_PROCESSOR_H_ | 5 #ifndef CHROME_BROWSER_SYNC_GLUE_THEME_CHANGE_PROCESSOR_H_ |
| 6 #define CHROME_BROWSER_SYNC_GLUE_THEME_CHANGE_PROCESSOR_H_ | 6 #define CHROME_BROWSER_SYNC_GLUE_THEME_CHANGE_PROCESSOR_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/compiler_specific.h" |
| 10 #include "chrome/browser/sync/glue/change_processor.h" | 11 #include "chrome/browser/sync/glue/change_processor.h" |
| 11 #include "chrome/browser/sync/internal_api/sync_manager.h" | |
| 12 #include "content/common/content_notification_types.h" | 12 #include "content/common/content_notification_types.h" |
| 13 #include "content/common/notification_observer.h" | 13 #include "content/common/notification_observer.h" |
| 14 #include "content/common/notification_registrar.h" | 14 #include "content/common/notification_registrar.h" |
| 15 | 15 |
| 16 class NotificationDetails; | 16 class NotificationDetails; |
| 17 class NotificationSource; | 17 class NotificationSource; |
| 18 class Profile; | 18 class Profile; |
| 19 | 19 |
| 20 namespace browser_sync { | 20 namespace browser_sync { |
| 21 | 21 |
| 22 class UnrecoverableErrorHandler; | 22 class UnrecoverableErrorHandler; |
| 23 | 23 |
| 24 // This class is responsible for taking changes from the | 24 // This class is responsible for taking changes from the |
| 25 // ThemeService and applying them to the sync_api 'syncable' | 25 // ThemeService and applying them to the sync_api 'syncable' |
| 26 // model, and vice versa. All operations and use of this class are | 26 // model, and vice versa. All operations and use of this class are |
| 27 // from the UI thread. | 27 // from the UI thread. |
| 28 class ThemeChangeProcessor : public ChangeProcessor, | 28 class ThemeChangeProcessor : public ChangeProcessor, |
| 29 public NotificationObserver { | 29 public NotificationObserver { |
| 30 public: | 30 public: |
| 31 explicit ThemeChangeProcessor(UnrecoverableErrorHandler* error_handler); | 31 explicit ThemeChangeProcessor(UnrecoverableErrorHandler* error_handler); |
| 32 virtual ~ThemeChangeProcessor(); | 32 virtual ~ThemeChangeProcessor(); |
| 33 | 33 |
| 34 // NotificationObserver implementation. | 34 // NotificationObserver implementation. |
| 35 // ThemeService -> sync_api model change application. | 35 // ThemeService -> sync_api model change application. |
| 36 virtual void Observe(int type, | 36 virtual void Observe(int type, |
| 37 const NotificationSource& source, | 37 const NotificationSource& source, |
| 38 const NotificationDetails& details); | 38 const NotificationDetails& details) OVERRIDE; |
| 39 | 39 |
| 40 // ChangeProcessor implementation. | 40 // ChangeProcessor implementation. |
| 41 // sync_api model -> ThemeService change application. | 41 // sync_api model -> ThemeService change application. |
| 42 virtual void ApplyChangesFromSyncModel( | 42 virtual void ApplyChangesFromSyncModel( |
| 43 const sync_api::BaseTransaction* trans, | 43 const sync_api::BaseTransaction* trans, |
| 44 const sync_api::SyncManager::ChangeRecord* changes, | 44 const sync_api::ImmutableChangeRecordList& changes) OVERRIDE; |
| 45 int change_count); | |
| 46 | 45 |
| 47 protected: | 46 protected: |
| 48 // ChangeProcessor implementation. | 47 // ChangeProcessor implementation. |
| 49 virtual void StartImpl(Profile* profile); | 48 virtual void StartImpl(Profile* profile) OVERRIDE; |
| 50 virtual void StopImpl(); | 49 virtual void StopImpl() OVERRIDE; |
| 51 | 50 |
| 52 private: | 51 private: |
| 53 void StartObserving(); | 52 void StartObserving(); |
| 54 void StopObserving(); | 53 void StopObserving(); |
| 55 | 54 |
| 56 NotificationRegistrar notification_registrar_; | 55 NotificationRegistrar notification_registrar_; |
| 57 // Profile associated with the ThemeService. Non-NULL iff |running()| is | 56 // Profile associated with the ThemeService. Non-NULL iff |running()| is |
| 58 // true. | 57 // true. |
| 59 Profile* profile_; | 58 Profile* profile_; |
| 60 | 59 |
| 61 DISALLOW_COPY_AND_ASSIGN(ThemeChangeProcessor); | 60 DISALLOW_COPY_AND_ASSIGN(ThemeChangeProcessor); |
| 62 }; | 61 }; |
| 63 | 62 |
| 64 } // namespace browser_sync | 63 } // namespace browser_sync |
| 65 | 64 |
| 66 #endif // CHROME_BROWSER_SYNC_GLUE_THEME_CHANGE_PROCESSOR_H_ | 65 #endif // CHROME_BROWSER_SYNC_GLUE_THEME_CHANGE_PROCESSOR_H_ |
| OLD | NEW |