OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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_SESSION_CHANGE_PROCESSOR_H_ | 5 #ifndef CHROME_BROWSER_SYNC_GLUE_SESSION_CHANGE_PROCESSOR_H_ |
6 #define CHROME_BROWSER_SYNC_GLUE_SESSION_CHANGE_PROCESSOR_H_ | 6 #define CHROME_BROWSER_SYNC_GLUE_SESSION_CHANGE_PROCESSOR_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "chrome/browser/sessions/session_backend.h" | 10 #include "chrome/browser/sessions/session_backend.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 // SessionService and applying them to the sync_api 'syncable' | 28 // SessionService and applying them to the sync_api 'syncable' |
29 // model, and vice versa. All operations and use of this class are | 29 // model, and vice versa. All operations and use of this class are |
30 // from the UI thread. | 30 // from the UI thread. |
31 class SessionChangeProcessor : public ChangeProcessor, | 31 class SessionChangeProcessor : public ChangeProcessor, |
32 public NotificationObserver { | 32 public NotificationObserver { |
33 public: | 33 public: |
34 // Does not take ownership of either argument. | 34 // Does not take ownership of either argument. |
35 SessionChangeProcessor( | 35 SessionChangeProcessor( |
36 UnrecoverableErrorHandler* error_handler, | 36 UnrecoverableErrorHandler* error_handler, |
37 SessionModelAssociator* session_model_associator); | 37 SessionModelAssociator* session_model_associator); |
38 SessionChangeProcessor( | |
39 UnrecoverableErrorHandler* error_handler, | |
40 SessionModelAssociator* session_model_associator, | |
41 bool setup_for_test); | |
42 virtual ~SessionChangeProcessor(); | 38 virtual ~SessionChangeProcessor(); |
43 | 39 |
44 // NotificationObserver implementation. | 40 // NotificationObserver implementation. |
45 // BrowserSessionProvider -> sync_api model change application. | 41 // BrowserSessionProvider -> sync_api model change application. |
46 virtual void Observe(NotificationType type, | 42 virtual void Observe(NotificationType type, |
47 const NotificationSource& source, | 43 const NotificationSource& source, |
48 const NotificationDetails& details); | 44 const NotificationDetails& details); |
49 | 45 |
50 // ChangeProcessor implementation. | 46 // ChangeProcessor implementation. |
51 // sync_api model -> BrowserSessionProvider change application. | 47 // sync_api model -> BrowserSessionProvider change application. |
52 virtual void ApplyChangesFromSyncModel( | 48 virtual void ApplyChangesFromSyncModel( |
53 const sync_api::BaseTransaction* trans, | 49 const sync_api::BaseTransaction* trans, |
54 const sync_api::SyncManager::ChangeRecord* changes, | 50 const sync_api::SyncManager::ChangeRecord* changes, |
55 int change_count); | 51 int change_count); |
56 | 52 |
57 protected: | 53 protected: |
58 // ChangeProcessor implementation. | 54 // ChangeProcessor implementation. |
59 virtual void StartImpl(Profile* profile); | 55 virtual void StartImpl(Profile* profile); |
60 virtual void StopImpl(); | 56 virtual void StopImpl(); |
61 private: | 57 private: |
62 void StartObserving(); | 58 void StartObserving(); |
63 void StopObserving(); | 59 void StopObserving(); |
64 SessionModelAssociator* session_model_associator_; | 60 SessionModelAssociator* session_model_associator_; |
65 NotificationRegistrar notification_registrar_; | 61 NotificationRegistrar notification_registrar_; |
66 | 62 |
67 // Owner of the SessionService. Non-NULL iff |running()| is true. | 63 // Owner of the SessionService. Non-NULL iff |running()| is true. |
68 Profile* profile_; | 64 Profile* profile_; |
69 | 65 |
70 // To bypass some checks/codepaths not applicable in tests. | |
71 bool setup_for_test_; | |
72 | |
73 DISALLOW_COPY_AND_ASSIGN(SessionChangeProcessor); | 66 DISALLOW_COPY_AND_ASSIGN(SessionChangeProcessor); |
74 }; | 67 }; |
75 | 68 |
76 } // namespace browser_sync | 69 } // namespace browser_sync |
77 | 70 |
78 #endif // CHROME_BROWSER_SYNC_GLUE_SESSION_CHANGE_PROCESSOR_H_ | 71 #endif // CHROME_BROWSER_SYNC_GLUE_SESSION_CHANGE_PROCESSOR_H_ |
OLD | NEW |