| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "base/compiler_specific.h" |
| 11 #include "chrome/browser/sync/glue/change_processor.h" | 11 #include "chrome/browser/sync/glue/change_processor.h" |
| 12 #include "chrome/browser/sync/glue/data_type_error_handler.h" | 12 #include "chrome/browser/sync/glue/data_type_error_handler.h" |
| 13 #include "content/public/browser/notification_observer.h" | 13 #include "content/public/browser/notification_observer.h" |
| 14 #include "content/public/browser/notification_registrar.h" | 14 #include "content/public/browser/notification_registrar.h" |
| 15 #include "content/public/browser/notification_types.h" | 15 #include "content/public/browser/notification_types.h" |
| 16 | 16 |
| 17 class Profile; | 17 class Profile; |
| 18 | 18 |
| 19 namespace browser_sync { | 19 namespace browser_sync { |
| 20 | 20 |
| 21 class DataTypeErrorHandler; | 21 class DataTypeErrorHandler; |
| 22 | 22 |
| 23 // This class is responsible for taking changes from the | 23 // This class is responsible for taking changes from the |
| 24 // ThemeService and applying them to the csync 'syncable' | 24 // ThemeService and applying them to the sync API 'syncable' |
| 25 // model, and vice versa. All operations and use of this class are | 25 // model, and vice versa. All operations and use of this class are |
| 26 // from the UI thread. | 26 // from the UI thread. |
| 27 class ThemeChangeProcessor : public ChangeProcessor, | 27 class ThemeChangeProcessor : public ChangeProcessor, |
| 28 public content::NotificationObserver { | 28 public content::NotificationObserver { |
| 29 public: | 29 public: |
| 30 explicit ThemeChangeProcessor(DataTypeErrorHandler* error_handler); | 30 explicit ThemeChangeProcessor(DataTypeErrorHandler* error_handler); |
| 31 virtual ~ThemeChangeProcessor(); | 31 virtual ~ThemeChangeProcessor(); |
| 32 | 32 |
| 33 // content::NotificationObserver implementation. | 33 // content::NotificationObserver implementation. |
| 34 // ThemeService -> csync model change application. | 34 // ThemeService -> sync API model change application. |
| 35 virtual void Observe(int type, | 35 virtual void Observe(int type, |
| 36 const content::NotificationSource& source, | 36 const content::NotificationSource& source, |
| 37 const content::NotificationDetails& details) OVERRIDE; | 37 const content::NotificationDetails& details) OVERRIDE; |
| 38 | 38 |
| 39 // ChangeProcessor implementation. | 39 // ChangeProcessor implementation. |
| 40 // csync model -> ThemeService change application. | 40 // sync API model -> ThemeService change application. |
| 41 virtual void ApplyChangesFromSyncModel( | 41 virtual void ApplyChangesFromSyncModel( |
| 42 const csync::BaseTransaction* trans, | 42 const syncer::BaseTransaction* trans, |
| 43 const csync::ImmutableChangeRecordList& changes) OVERRIDE; | 43 const syncer::ImmutableChangeRecordList& changes) OVERRIDE; |
| 44 | 44 |
| 45 protected: | 45 protected: |
| 46 // ChangeProcessor implementation. | 46 // ChangeProcessor implementation. |
| 47 virtual void StartImpl(Profile* profile) OVERRIDE; | 47 virtual void StartImpl(Profile* profile) OVERRIDE; |
| 48 virtual void StopImpl() OVERRIDE; | 48 virtual void StopImpl() OVERRIDE; |
| 49 | 49 |
| 50 private: | 50 private: |
| 51 friend class ScopedStopObserving<ThemeChangeProcessor>; | 51 friend class ScopedStopObserving<ThemeChangeProcessor>; |
| 52 void StartObserving(); | 52 void StartObserving(); |
| 53 void StopObserving(); | 53 void StopObserving(); |
| 54 | 54 |
| 55 content::NotificationRegistrar notification_registrar_; | 55 content::NotificationRegistrar notification_registrar_; |
| 56 // Profile associated with the ThemeService. Non-NULL iff |running()| is | 56 // Profile associated with the ThemeService. Non-NULL iff |running()| is |
| 57 // true. | 57 // true. |
| 58 Profile* profile_; | 58 Profile* profile_; |
| 59 | 59 |
| 60 DISALLOW_COPY_AND_ASSIGN(ThemeChangeProcessor); | 60 DISALLOW_COPY_AND_ASSIGN(ThemeChangeProcessor); |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 } // namespace browser_sync | 63 } // namespace browser_sync |
| 64 | 64 |
| 65 #endif // CHROME_BROWSER_SYNC_GLUE_THEME_CHANGE_PROCESSOR_H_ | 65 #endif // CHROME_BROWSER_SYNC_GLUE_THEME_CHANGE_PROCESSOR_H_ |
| OLD | NEW |