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

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

Issue 815983002: Topsites become keyedService based. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: For trybot 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 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 #ifndef CHROME_BROWSER_HISTORY_CHROME_HISTORY_CLIENT_H_ 5 #ifndef CHROME_BROWSER_HISTORY_CHROME_HISTORY_CLIENT_H_
6 #define CHROME_BROWSER_HISTORY_CHROME_HISTORY_CLIENT_H_ 6 #define CHROME_BROWSER_HISTORY_CHROME_HISTORY_CLIENT_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h"
9 #include "components/history/core/browser/history_client.h" 10 #include "components/history/core/browser/history_client.h"
10 #include "components/history/core/browser/top_sites_observer.h" 11 #include "components/history/core/browser/top_sites_observer.h"
11 12
12 class HistoryService; 13 class HistoryService;
13 class Profile; 14 class Profile;
14 15
15 namespace bookmarks { 16 namespace bookmarks {
16 class BookmarkModel; 17 class BookmarkModel;
17 } 18 }
18 19
19 namespace history { 20 namespace history {
20 class TopSites; 21 class TopSites;
21 } 22 }
22 23
23 // This class implements history::HistoryClient to abstract operations that 24 // This class implements history::HistoryClient to abstract operations that
24 // depend on Chrome environment. 25 // depend on Chrome environment.
25 class ChromeHistoryClient : public history::HistoryClient, 26 class ChromeHistoryClient : public history::HistoryClient,
26 public history::TopSitesObserver { 27 public history::TopSitesObserver {
27 public: 28 public:
28 explicit ChromeHistoryClient(bookmarks::BookmarkModel* bookmark_model, 29 ChromeHistoryClient(bookmarks::BookmarkModel* bookmark_model,
sdefresne 2015/01/21 17:57:23 Upstream code has been changed and no longer requi
29 Profile* profile, 30 Profile* profile,
30 history::TopSites* top_sites); 31 const scoped_refptr<history::TopSites>& top_sites);
31 ~ChromeHistoryClient() override; 32 ~ChromeHistoryClient() override;
32 33
33 // history::HistoryClient: 34 // history::HistoryClient:
34 void BlockUntilBookmarksLoaded() override; 35 void BlockUntilBookmarksLoaded() override;
35 bool IsBookmarked(const GURL& url) override; 36 bool IsBookmarked(const GURL& url) override;
36 void GetBookmarks(std::vector<history::URLAndTitle>* bookmarks) override; 37 void GetBookmarks(std::vector<history::URLAndTitle>* bookmarks) override;
37 void NotifyProfileError(sql::InitStatus init_status) override; 38 void NotifyProfileError(sql::InitStatus init_status) override;
38 bool ShouldReportDatabaseError() override; 39 bool ShouldReportDatabaseError() override;
39 40
40 // KeyedService: 41 // KeyedService:
41 void Shutdown() override; 42 void Shutdown() override;
42 43
43 // TopSitesObserver: 44 // TopSitesObserver:
44 void TopSitesLoaded(history::TopSites* top_sites) override; 45 void TopSitesLoaded(history::TopSites* top_sites) override;
45 void TopSitesChanged(history::TopSites* top_sites) override; 46 void TopSitesChanged(history::TopSites* top_sites) override;
46 47
47 private: 48 private:
48 // The BookmarkModel, this should outlive ChromeHistoryClient. 49 // The BookmarkModel, this should outlive ChromeHistoryClient.
49 bookmarks::BookmarkModel* bookmark_model_; 50 bookmarks::BookmarkModel* bookmark_model_;
50 Profile* profile_; 51 Profile* profile_;
51 // The TopSites object is owned by the Profile (see 52 scoped_refptr<history::TopSites> top_sites_;
52 // chrome/browser/profiles/profile_impl.h)
53 // and lazily constructed by the getter.
54 // ChromeHistoryClient is a KeyedService linked to the Profile lifetime by the
55 // ChromeHistoryClientFactory (which is a BrowserContextKeyedServiceFactory).
56 // Before the Profile is destroyed, all the KeyedService Shutdown methods are
57 // called, and the Profile is fully constructed before any of the KeyedService
58 // can be constructed. The TopSites does not use the HistoryService nor the
59 // HistoryClient during construction (it uses it later, but supports getting
60 // an NULL pointer).
61 history::TopSites* top_sites_;
62 53
63 DISALLOW_COPY_AND_ASSIGN(ChromeHistoryClient); 54 DISALLOW_COPY_AND_ASSIGN(ChromeHistoryClient);
64 }; 55 };
65 56
66 #endif // CHROME_BROWSER_HISTORY_CHROME_HISTORY_CLIENT_H_ 57 #endif // CHROME_BROWSER_HISTORY_CHROME_HISTORY_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698