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

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

Issue 441623002: Eliminate sending NOTIFICATION_TOP_SITES_* from TopSites (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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 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"
9 #include "chrome/browser/history/history_notifications.h"
10 #include "chrome/browser/history/top_sites.h"
8 #include "chrome/browser/ui/profile_error_dialog.h" 11 #include "chrome/browser/ui/profile_error_dialog.h"
9 #include "chrome/common/chrome_version_info.h" 12 #include "chrome/common/chrome_version_info.h"
10 #include "components/bookmarks/browser/bookmark_model.h" 13 #include "components/bookmarks/browser/bookmark_model.h"
14 #include "content/public/browser/notification_service.h"
11 #include "grit/chromium_strings.h" 15 #include "grit/chromium_strings.h"
12 #include "grit/generated_resources.h" 16 #include "grit/generated_resources.h"
13 17
14 ChromeHistoryClient::ChromeHistoryClient(BookmarkModel* bookmark_model) 18 class Profile;
sdefresne 2014/08/04 08:47:17 Remove, this is un-necessary.
nshaik 2014/08/05 06:38:03 Done.
15 : bookmark_model_(bookmark_model) { 19
20 ChromeHistoryClient::ChromeHistoryClient(BookmarkModel* bookmark_model,
sdefresne 2014/08/04 08:47:18 Receive Profile* as an additional parameter and st
nshaik 2014/08/05 06:38:02 Done.
21 history::TopSites* top_sites)
22 : bookmark_model_(bookmark_model), top_sites_(top_sites) {
16 DCHECK(bookmark_model_); 23 DCHECK(bookmark_model_);
24 if (top_sites_)
25 top_sites_->AddObserver(this);
26 }
27
28 ChromeHistoryClient::~ChromeHistoryClient() {
29 if (top_sites_)
30 top_sites_->RemoveObserver(this);
17 } 31 }
18 32
19 void ChromeHistoryClient::BlockUntilBookmarksLoaded() { 33 void ChromeHistoryClient::BlockUntilBookmarksLoaded() {
20 bookmark_model_->BlockTillLoaded(); 34 bookmark_model_->BlockTillLoaded();
21 } 35 }
22 36
23 bool ChromeHistoryClient::IsBookmarked(const GURL& url) { 37 bool ChromeHistoryClient::IsBookmarked(const GURL& url) {
24 return bookmark_model_->IsBookmarked(url); 38 return bookmark_model_->IsBookmarked(url);
25 } 39 }
26 40
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 void ChromeHistoryClient::Shutdown() { 72 void ChromeHistoryClient::Shutdown() {
59 // It's possible that bookmarks haven't loaded and history is waiting for 73 // It's possible that bookmarks haven't loaded and history is waiting for
60 // bookmarks to complete loading. In such a situation history can't shutdown 74 // bookmarks to complete loading. In such a situation history can't shutdown
61 // (meaning if we invoked HistoryService::Cleanup now, we would deadlock). To 75 // (meaning if we invoked HistoryService::Cleanup now, we would deadlock). To
62 // break the deadlock we tell BookmarkModel it's about to be deleted so that 76 // break the deadlock we tell BookmarkModel it's about to be deleted so that
63 // it can release the signal history is waiting on, allowing history to 77 // it can release the signal history is waiting on, allowing history to
64 // shutdown (HistoryService::Cleanup to complete). In such a scenario history 78 // shutdown (HistoryService::Cleanup to complete). In such a scenario history
65 // sees an incorrect view of bookmarks, but it's better than a deadlock. 79 // sees an incorrect view of bookmarks, but it's better than a deadlock.
66 bookmark_model_->Shutdown(); 80 bookmark_model_->Shutdown();
67 } 81 }
82
83 void ChromeHistoryClient::TopSitesLoaded(history::TopSites* top_sites) {
84 content::NotificationService::current()->Notify(
85 chrome::NOTIFICATION_TOP_SITES_LOADED,
86 content::Source<Profile>(top_sites->GetProfile()),
sdefresne 2014/08/04 08:47:18 Use saved pointer to the Profile*.
nshaik 2014/08/05 06:38:02 Done.
87 content::Details<history::TopSites>(top_sites));
88 }
89
90 void ChromeHistoryClient::TopSitesChanged(history::TopSites* top_sites) {
91 content::NotificationService::current()->Notify(
92 chrome::NOTIFICATION_TOP_SITES_CHANGED,
93 content::Source<Profile>(top_sites->GetProfile()),
sdefresne 2014/08/04 08:47:17 Same.
nshaik 2014/08/05 06:38:02 Done.
94 content::NotificationService::NoDetails());
95 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698