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

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

Issue 839193002: Move ServiceAccessType into //components/keyed_service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compilation on android Created 5 years, 11 months 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 #include "chrome/browser/sync/glue/bookmark_data_type_controller.h" 5 #include "chrome/browser/sync/glue/bookmark_data_type_controller.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 8 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
9 #include "chrome/browser/chrome_notification_types.h" 9 #include "chrome/browser/chrome_notification_types.h"
10 #include "chrome/browser/history/history_service.h" 10 #include "chrome/browser/history/history_service.h"
(...skipping 29 matching lines...) Expand all
40 40
41 BookmarkDataTypeController::~BookmarkDataTypeController() { 41 BookmarkDataTypeController::~BookmarkDataTypeController() {
42 } 42 }
43 43
44 bool BookmarkDataTypeController::StartModels() { 44 bool BookmarkDataTypeController::StartModels() {
45 if (!DependentsLoaded()) { 45 if (!DependentsLoaded()) {
46 BookmarkModel* bookmark_model = 46 BookmarkModel* bookmark_model =
47 BookmarkModelFactory::GetForProfile(profile_); 47 BookmarkModelFactory::GetForProfile(profile_);
48 bookmark_model_observer_.Add(bookmark_model); 48 bookmark_model_observer_.Add(bookmark_model);
49 HistoryService* history_service = HistoryServiceFactory::GetForProfile( 49 HistoryService* history_service = HistoryServiceFactory::GetForProfile(
50 profile_, Profile::EXPLICIT_ACCESS); 50 profile_, ServiceAccessType::EXPLICIT_ACCESS);
51 history_service_observer_.Add(history_service); 51 history_service_observer_.Add(history_service);
52 return false; 52 return false;
53 } 53 }
54 return true; 54 return true;
55 } 55 }
56 56
57 void BookmarkDataTypeController::CleanUpState() { 57 void BookmarkDataTypeController::CleanUpState() {
58 history_service_observer_.RemoveAll(); 58 history_service_observer_.RemoveAll();
59 bookmark_model_observer_.RemoveAll(); 59 bookmark_model_observer_.RemoveAll();
60 } 60 }
(...skipping 27 matching lines...) Expand all
88 } 88 }
89 89
90 // Check that both the bookmark model and the history service (for favicons) 90 // Check that both the bookmark model and the history service (for favicons)
91 // are loaded. 91 // are loaded.
92 bool BookmarkDataTypeController::DependentsLoaded() { 92 bool BookmarkDataTypeController::DependentsLoaded() {
93 BookmarkModel* bookmark_model = BookmarkModelFactory::GetForProfile(profile_); 93 BookmarkModel* bookmark_model = BookmarkModelFactory::GetForProfile(profile_);
94 if (!bookmark_model || !bookmark_model->loaded()) 94 if (!bookmark_model || !bookmark_model->loaded())
95 return false; 95 return false;
96 96
97 HistoryService* history = HistoryServiceFactory::GetForProfile( 97 HistoryService* history = HistoryServiceFactory::GetForProfile(
98 profile_, Profile::EXPLICIT_ACCESS); 98 profile_, ServiceAccessType::EXPLICIT_ACCESS);
99 if (!history || !history->BackendLoaded()) 99 if (!history || !history->BackendLoaded())
100 return false; 100 return false;
101 101
102 // All necessary services are loaded. 102 // All necessary services are loaded.
103 return true; 103 return true;
104 } 104 }
105 105
106 void BookmarkDataTypeController::OnHistoryServiceLoaded( 106 void BookmarkDataTypeController::OnHistoryServiceLoaded(
107 HistoryService* service) { 107 HistoryService* service) {
108 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 108 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
109 DCHECK_EQ(state_, MODEL_STARTING); 109 DCHECK_EQ(state_, MODEL_STARTING);
110 history_service_observer_.RemoveAll(); 110 history_service_observer_.RemoveAll();
111 111
112 if (!DependentsLoaded()) 112 if (!DependentsLoaded())
113 return; 113 return;
114 114
115 bookmark_model_observer_.RemoveAll(); 115 bookmark_model_observer_.RemoveAll();
116 OnModelLoaded(); 116 OnModelLoaded();
117 } 117 }
118 118
119 void BookmarkDataTypeController::HistoryServiceBeingDeleted( 119 void BookmarkDataTypeController::HistoryServiceBeingDeleted(
120 HistoryService* history_service) { 120 HistoryService* history_service) {
121 CleanUpState(); 121 CleanUpState();
122 } 122 }
123 123
124 } // namespace browser_sync 124 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/bookmark_change_processor.cc ('k') | chrome/browser/sync/glue/favicon_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698