| 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 COMPONENTS_SYNC_BOOKMARKS_BOOKMARK_DATA_TYPE_CONTROLLER_H__ | 5 #ifndef COMPONENTS_SYNC_BOOKMARKS_BOOKMARK_DATA_TYPE_CONTROLLER_H__ |
| 6 #define COMPONENTS_SYNC_BOOKMARKS_BOOKMARK_DATA_TYPE_CONTROLLER_H__ | 6 #define COMPONENTS_SYNC_BOOKMARKS_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/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/scoped_observer.h" | 12 #include "base/scoped_observer.h" |
| 13 #include "components/bookmarks/browser/base_bookmark_model_observer.h" | 13 #include "components/bookmarks/browser/base_bookmark_model_observer.h" |
| 14 #include "components/history/core/browser/history_service_observer.h" | 14 #include "components/history/core/browser/history_service_observer.h" |
| 15 #include "components/sync/driver/frontend_data_type_controller.h" | 15 #include "components/sync/driver/frontend_data_type_controller.h" |
| 16 | 16 |
| 17 namespace browser_sync { | 17 namespace sync_bookmarks { |
| 18 | 18 |
| 19 // A class that manages the startup and shutdown of bookmark sync. | 19 // A class that manages the startup and shutdown of bookmark sync. |
| 20 class BookmarkDataTypeController : public FrontendDataTypeController, | 20 class BookmarkDataTypeController |
| 21 public bookmarks::BaseBookmarkModelObserver, | 21 : public browser_sync::FrontendDataTypeController, |
| 22 public history::HistoryServiceObserver { | 22 public bookmarks::BaseBookmarkModelObserver, |
| 23 public history::HistoryServiceObserver { |
| 23 public: | 24 public: |
| 24 // |dump_stack| is called when an unrecoverable error occurs. | 25 // |dump_stack| is called when an unrecoverable error occurs. |
| 25 BookmarkDataTypeController(const base::Closure& dump_stack, | 26 BookmarkDataTypeController(const base::Closure& dump_stack, |
| 26 sync_driver::SyncClient* sync_client); | 27 sync_driver::SyncClient* sync_client); |
| 27 ~BookmarkDataTypeController() override; | 28 ~BookmarkDataTypeController() override; |
| 28 | 29 |
| 29 private: | 30 private: |
| 30 // FrontendDataTypeController: | 31 // browser_sync::FrontendDataTypeController: |
| 31 bool StartModels() override; | 32 bool StartModels() override; |
| 32 void CleanUpState() override; | 33 void CleanUpState() override; |
| 33 void CreateSyncComponents() override; | 34 void CreateSyncComponents() override; |
| 34 | 35 |
| 35 // bookmarks::BaseBookmarkModelObserver: | 36 // bookmarks::BaseBookmarkModelObserver: |
| 36 void BookmarkModelChanged() override; | 37 void BookmarkModelChanged() override; |
| 37 void BookmarkModelLoaded(bookmarks::BookmarkModel* model, | 38 void BookmarkModelLoaded(bookmarks::BookmarkModel* model, |
| 38 bool ids_reassigned) override; | 39 bool ids_reassigned) override; |
| 39 void BookmarkModelBeingDeleted(bookmarks::BookmarkModel* model) override; | 40 void BookmarkModelBeingDeleted(bookmarks::BookmarkModel* model) override; |
| 40 | 41 |
| 41 // Helper that returns true iff both the bookmark model and the history | 42 // Helper that returns true iff both the bookmark model and the history |
| 42 // service have finished loading. | 43 // service have finished loading. |
| 43 bool DependentsLoaded(); | 44 bool DependentsLoaded(); |
| 44 | 45 |
| 45 // history::HistoryServiceObserver: | 46 // history::HistoryServiceObserver: |
| 46 void OnHistoryServiceLoaded(history::HistoryService* service) override; | 47 void OnHistoryServiceLoaded(history::HistoryService* service) override; |
| 47 void HistoryServiceBeingDeleted( | 48 void HistoryServiceBeingDeleted( |
| 48 history::HistoryService* history_service) override; | 49 history::HistoryService* history_service) override; |
| 49 | 50 |
| 50 ScopedObserver<history::HistoryService, history::HistoryServiceObserver> | 51 ScopedObserver<history::HistoryService, history::HistoryServiceObserver> |
| 51 history_service_observer_; | 52 history_service_observer_; |
| 52 ScopedObserver<bookmarks::BookmarkModel, BaseBookmarkModelObserver> | 53 ScopedObserver<bookmarks::BookmarkModel, BaseBookmarkModelObserver> |
| 53 bookmark_model_observer_; | 54 bookmark_model_observer_; |
| 54 | 55 |
| 55 DISALLOW_COPY_AND_ASSIGN(BookmarkDataTypeController); | 56 DISALLOW_COPY_AND_ASSIGN(BookmarkDataTypeController); |
| 56 }; | 57 }; |
| 57 | 58 |
| 58 } // namespace browser_sync | 59 } // namespace sync_bookmarks |
| 59 | 60 |
| 60 #endif // COMPONENTS_SYNC_BOOKMARKS_BOOKMARK_DATA_TYPE_CONTROLLER_H__ | 61 #endif // COMPONENTS_SYNC_BOOKMARKS_BOOKMARK_DATA_TYPE_CONTROLLER_H__ |
| OLD | NEW |