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_BOOKMARK_DATA_TYPE_CONTROLLER_H__ | 5 #ifndef CHROME_BROWSER_SYNC_GLUE_BOOKMARK_DATA_TYPE_CONTROLLER_H__ |
6 #define CHROME_BROWSER_SYNC_GLUE_BOOKMARK_DATA_TYPE_CONTROLLER_H__ | 6 #define CHROME_BROWSER_SYNC_GLUE_BOOKMARK_DATA_TYPE_CONTROLLER_H__ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/scoped_observer.h" |
11 #include "chrome/browser/sync/glue/frontend_data_type_controller.h" | 12 #include "chrome/browser/sync/glue/frontend_data_type_controller.h" |
12 #include "components/bookmarks/browser/base_bookmark_model_observer.h" | 13 #include "components/bookmarks/browser/base_bookmark_model_observer.h" |
13 #include "content/public/browser/notification_observer.h" | 14 #include "components/history/core/browser/history_service_observer.h" |
14 #include "content/public/browser/notification_registrar.h" | |
15 | 15 |
16 namespace browser_sync { | 16 namespace browser_sync { |
17 | 17 |
18 // A class that manages the startup and shutdown of bookmark sync. | 18 // A class that manages the startup and shutdown of bookmark sync. |
19 class BookmarkDataTypeController : public FrontendDataTypeController, | 19 class BookmarkDataTypeController : public FrontendDataTypeController, |
20 public content::NotificationObserver, | 20 public BaseBookmarkModelObserver, |
21 public BaseBookmarkModelObserver { | 21 public history::HistoryServiceObserver { |
22 public: | 22 public: |
23 BookmarkDataTypeController(ProfileSyncComponentsFactory* profile_sync_factory, | 23 BookmarkDataTypeController(ProfileSyncComponentsFactory* profile_sync_factory, |
24 Profile* profile, | 24 Profile* profile, |
25 ProfileSyncService* sync_service); | 25 ProfileSyncService* sync_service); |
26 | 26 |
27 // FrontendDataTypeController interface. | 27 // FrontendDataTypeController interface. |
28 syncer::ModelType type() const override; | 28 syncer::ModelType type() const override; |
29 | 29 |
30 // content::NotificationObserver interface. | 30 // history::HistoryServiceObserver: |
31 void Observe(int type, | 31 void OnHistoryServiceLoaded(HistoryService* service) override; |
32 const content::NotificationSource& source, | |
33 const content::NotificationDetails& details) override; | |
34 | 32 |
35 private: | 33 private: |
36 ~BookmarkDataTypeController() override; | 34 ~BookmarkDataTypeController() override; |
37 | 35 |
38 // FrontendDataTypeController interface. | 36 // FrontendDataTypeController interface. |
39 bool StartModels() override; | 37 bool StartModels() override; |
40 void CleanUpState() override; | 38 void CleanUpState() override; |
41 void CreateSyncComponents() override; | 39 void CreateSyncComponents() override; |
42 | 40 |
43 // BaseBookmarkModelObserver interface. | 41 // BaseBookmarkModelObserver interface. |
44 void BookmarkModelChanged() override; | 42 void BookmarkModelChanged() override; |
45 void BookmarkModelLoaded(BookmarkModel* model, bool ids_reassigned) override; | 43 void BookmarkModelLoaded(BookmarkModel* model, bool ids_reassigned) override; |
46 void BookmarkModelBeingDeleted(BookmarkModel* model) override; | 44 void BookmarkModelBeingDeleted(BookmarkModel* model) override; |
47 | 45 |
48 // Helper that returns true iff both the bookmark model and the history | 46 // Helper that returns true iff both the bookmark model and the history |
49 // service have finished loading. | 47 // service have finished loading. |
50 bool DependentsLoaded(); | 48 bool DependentsLoaded(); |
51 | 49 |
52 content::NotificationRegistrar registrar_; | |
53 | |
54 BookmarkModel* bookmark_model_; | 50 BookmarkModel* bookmark_model_; |
55 | 51 |
56 // Have we installed ourselves as a BookmarkModel observer? | 52 // Have we installed ourselves as a BookmarkModel observer? |
57 bool installed_bookmark_observer_; | 53 bool installed_bookmark_observer_; |
58 | 54 |
59 DISALLOW_COPY_AND_ASSIGN(BookmarkDataTypeController); | 55 DISALLOW_COPY_AND_ASSIGN(BookmarkDataTypeController); |
60 }; | 56 }; |
61 | 57 |
62 } // namespace browser_sync | 58 } // namespace browser_sync |
63 | 59 |
64 #endif // CHROME_BROWSER_SYNC_GLUE_BOOKMARK_DATA_TYPE_CONTROLLER_H__ | 60 #endif // CHROME_BROWSER_SYNC_GLUE_BOOKMARK_DATA_TYPE_CONTROLLER_H__ |
OLD | NEW |