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

Side by Side Diff: chrome/browser/history/chrome_history_client.cc

Issue 815983002: Topsites become keyedService based. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 6 years 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/history/chrome_history_client.h" 5 #include "chrome/browser/history/chrome_history_client.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/chrome_notification_types.h" 8 #include "chrome/browser/chrome_notification_types.h"
9 #include "chrome/browser/history/history_notifications.h" 9 #include "chrome/browser/history/history_notifications.h"
10 #include "chrome/browser/history/top_sites.h" 10 #include "chrome/browser/history/top_sites_provider.h"
11 #include "chrome/browser/ui/profile_error_dialog.h" 11 #include "chrome/browser/ui/profile_error_dialog.h"
12 #include "chrome/common/chrome_version_info.h" 12 #include "chrome/common/chrome_version_info.h"
13 #include "chrome/grit/chromium_strings.h" 13 #include "chrome/grit/chromium_strings.h"
14 #include "chrome/grit/generated_resources.h" 14 #include "chrome/grit/generated_resources.h"
15 #include "components/bookmarks/browser/bookmark_model.h" 15 #include "components/bookmarks/browser/bookmark_model.h"
16 #include "content/public/browser/notification_service.h" 16 #include "content/public/browser/notification_service.h"
17 17
18 ChromeHistoryClient::ChromeHistoryClient(BookmarkModel* bookmark_model, 18 ChromeHistoryClient::ChromeHistoryClient(
19 Profile* profile, 19 BookmarkModel* bookmark_model,
20 history::TopSites* top_sites) 20 Profile* profile,
21 history::TopSitesProvider* top_sites_provider)
21 : bookmark_model_(bookmark_model), 22 : bookmark_model_(bookmark_model),
22 profile_(profile), 23 profile_(profile),
23 top_sites_(top_sites) { 24 top_sites_provider_(top_sites_provider) {
24 DCHECK(bookmark_model_); 25 DCHECK(bookmark_model_);
25 if (top_sites_) 26 if (top_sites_provider_)
26 top_sites_->AddObserver(this); 27 top_sites_provider_->AddObserver(this);
27 } 28 }
28 29
29 ChromeHistoryClient::~ChromeHistoryClient() { 30 ChromeHistoryClient::~ChromeHistoryClient() {
30 if (top_sites_) 31 if (top_sites_provider_)
31 top_sites_->RemoveObserver(this); 32 top_sites_provider_->RemoveObserver(this);
32 } 33 }
33 34
34 void ChromeHistoryClient::BlockUntilBookmarksLoaded() { 35 void ChromeHistoryClient::BlockUntilBookmarksLoaded() {
35 bookmark_model_->BlockTillLoaded(); 36 bookmark_model_->BlockTillLoaded();
36 } 37 }
37 38
38 bool ChromeHistoryClient::IsBookmarked(const GURL& url) { 39 bool ChromeHistoryClient::IsBookmarked(const GURL& url) {
39 return bookmark_model_->IsBookmarked(url); 40 return bookmark_model_->IsBookmarked(url);
40 } 41 }
41 42
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 // It's possible that bookmarks haven't loaded and history is waiting for 75 // It's possible that bookmarks haven't loaded and history is waiting for
75 // bookmarks to complete loading. In such a situation history can't shutdown 76 // bookmarks to complete loading. In such a situation history can't shutdown
76 // (meaning if we invoked HistoryService::Cleanup now, we would deadlock). To 77 // (meaning if we invoked HistoryService::Cleanup now, we would deadlock). To
77 // break the deadlock we tell BookmarkModel it's about to be deleted so that 78 // break the deadlock we tell BookmarkModel it's about to be deleted so that
78 // it can release the signal history is waiting on, allowing history to 79 // it can release the signal history is waiting on, allowing history to
79 // shutdown (HistoryService::Cleanup to complete). In such a scenario history 80 // shutdown (HistoryService::Cleanup to complete). In such a scenario history
80 // sees an incorrect view of bookmarks, but it's better than a deadlock. 81 // sees an incorrect view of bookmarks, but it's better than a deadlock.
81 bookmark_model_->Shutdown(); 82 bookmark_model_->Shutdown();
82 } 83 }
83 84
84 void ChromeHistoryClient::TopSitesLoaded(history::TopSites* top_sites) { 85 void ChromeHistoryClient::TopSitesLoaded(
86 history::TopSitesProvider* top_sites_provider) {
85 content::NotificationService::current()->Notify( 87 content::NotificationService::current()->Notify(
86 chrome::NOTIFICATION_TOP_SITES_LOADED, 88 chrome::NOTIFICATION_TOP_SITES_LOADED, content::Source<Profile>(profile_),
87 content::Source<Profile>(profile_), 89 content::Details<history::TopSitesProvider>(top_sites_provider));
88 content::Details<history::TopSites>(top_sites));
89 } 90 }
90 91
91 void ChromeHistoryClient::TopSitesChanged(history::TopSites* top_sites) { 92 void ChromeHistoryClient::TopSitesChanged(
93 history::TopSitesProvider* top_sites_provider) {
92 content::NotificationService::current()->Notify( 94 content::NotificationService::current()->Notify(
93 chrome::NOTIFICATION_TOP_SITES_CHANGED, 95 chrome::NOTIFICATION_TOP_SITES_CHANGED,
94 content::Source<history::TopSites>(top_sites), 96 content::Source<history::TopSitesProvider>(top_sites_provider),
95 content::NotificationService::NoDetails()); 97 content::NotificationService::NoDetails());
96 } 98 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698