Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Side by Side Diff: chrome/browser/sync/glue/bookmark_data_type_controller.h

Issue 573553004: Eliminate NOTIFICATION_HISTORY_LOADED notification (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Clean up state in bookmark_data_type_controller Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
14 #include "components/history/core/browser/history_service_observer.h"
13 #include "content/public/browser/notification_observer.h" 15 #include "content/public/browser/notification_observer.h"
14 #include "content/public/browser/notification_registrar.h" 16 #include "content/public/browser/notification_registrar.h"
15 17
16 namespace browser_sync { 18 namespace browser_sync {
17 19
18 // A class that manages the startup and shutdown of bookmark sync. 20 // A class that manages the startup and shutdown of bookmark sync.
19 class BookmarkDataTypeController : public FrontendDataTypeController, 21 class BookmarkDataTypeController : public FrontendDataTypeController,
20 public content::NotificationObserver, 22 public content::NotificationObserver,
21 public BaseBookmarkModelObserver { 23 public BaseBookmarkModelObserver,
24 public history::HistoryServiceObserver {
22 public: 25 public:
23 BookmarkDataTypeController(ProfileSyncComponentsFactory* profile_sync_factory, 26 BookmarkDataTypeController(ProfileSyncComponentsFactory* profile_sync_factory,
24 Profile* profile, 27 Profile* profile,
25 ProfileSyncService* sync_service); 28 ProfileSyncService* sync_service);
26 29
27 // FrontendDataTypeController interface. 30 // FrontendDataTypeController interface.
28 syncer::ModelType type() const override; 31 syncer::ModelType type() const override;
29 32
30 // content::NotificationObserver interface. 33 // content::NotificationObserver interface.
31 void Observe(int type, 34 void Observe(int type,
32 const content::NotificationSource& source, 35 const content::NotificationSource& source,
33 const content::NotificationDetails& details) override; 36 const content::NotificationDetails& details) override;
34 37
38 // history::HistoryServiceObserver:
39 void OnHistoryServiceLoaded(HistoryService* service) override;
40
35 private: 41 private:
36 ~BookmarkDataTypeController() override; 42 ~BookmarkDataTypeController() override;
37 43
38 // FrontendDataTypeController interface. 44 // FrontendDataTypeController interface.
39 bool StartModels() override; 45 bool StartModels() override;
40 void CleanUpState() override; 46 void CleanUpState() override;
41 void CreateSyncComponents() override; 47 void CreateSyncComponents() override;
42 48
43 // BaseBookmarkModelObserver interface. 49 // BaseBookmarkModelObserver interface.
44 void BookmarkModelChanged() override; 50 void BookmarkModelChanged() override;
45 void BookmarkModelLoaded(BookmarkModel* model, bool ids_reassigned) override; 51 void BookmarkModelLoaded(BookmarkModel* model, bool ids_reassigned) override;
46 void BookmarkModelBeingDeleted(BookmarkModel* model) override; 52 void BookmarkModelBeingDeleted(BookmarkModel* model) override;
47 53
48 // Helper that returns true iff both the bookmark model and the history 54 // Helper that returns true iff both the bookmark model and the history
49 // service have finished loading. 55 // service have finished loading.
50 bool DependentsLoaded(); 56 bool DependentsLoaded();
51 57
52 content::NotificationRegistrar registrar_; 58 content::NotificationRegistrar notification_registrar_;
53 59
54 BookmarkModel* bookmark_model_; 60 BookmarkModel* bookmark_model_;
55 61
56 // Have we installed ourselves as a BookmarkModel observer? 62 ScopedObserver<HistoryService, HistoryServiceObserver>
57 bool installed_bookmark_observer_; 63 history_service_observer_;
64 ScopedObserver<BookmarkModel, BaseBookmarkModelObserver>
65 bookmark_model_observer_;
58 66
59 DISALLOW_COPY_AND_ASSIGN(BookmarkDataTypeController); 67 DISALLOW_COPY_AND_ASSIGN(BookmarkDataTypeController);
60 }; 68 };
61 69
62 } // namespace browser_sync 70 } // namespace browser_sync
63 71
64 #endif // CHROME_BROWSER_SYNC_GLUE_BOOKMARK_DATA_TYPE_CONTROLLER_H__ 72 #endif // CHROME_BROWSER_SYNC_GLUE_BOOKMARK_DATA_TYPE_CONTROLLER_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698