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

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: Fixed the Review comments 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 BookmarkModel; 13 class BookmarkModel;
13 class HistoryService; 14 class HistoryService;
14 class Profile; 15 class Profile;
15 16
16 namespace history { 17 namespace history {
17 class TopSites; 18 class TopSites;
18 } 19 }
19 20
20 // This class implements history::HistoryClient to abstract operations that 21 // This class implements history::HistoryClient to abstract operations that
21 // depend on Chrome environment. 22 // depend on Chrome environment.
22 class ChromeHistoryClient : public history::HistoryClient, 23 class ChromeHistoryClient : public history::HistoryClient,
23 public history::TopSitesObserver { 24 public history::TopSitesObserver {
24 public: 25 public:
25 explicit ChromeHistoryClient(BookmarkModel* bookmark_model, 26 explicit ChromeHistoryClient(
Bernhard Bauer 2015/01/12 14:32:23 Could you remove the "explicit" here?
Jitu( very slow this week) 2015/01/12 14:55:15 Done.
26 Profile* profile, 27 BookmarkModel* bookmark_model,
27 history::TopSites* top_sites); 28 Profile* profile,
29 const scoped_refptr<history::TopSites>& top_sites);
28 ~ChromeHistoryClient() override; 30 ~ChromeHistoryClient() override;
29 31
30 // history::HistoryClient: 32 // history::HistoryClient:
31 void BlockUntilBookmarksLoaded() override; 33 void BlockUntilBookmarksLoaded() override;
32 bool IsBookmarked(const GURL& url) override; 34 bool IsBookmarked(const GURL& url) override;
33 void GetBookmarks(std::vector<history::URLAndTitle>* bookmarks) override; 35 void GetBookmarks(std::vector<history::URLAndTitle>* bookmarks) override;
34 void NotifyProfileError(sql::InitStatus init_status) override; 36 void NotifyProfileError(sql::InitStatus init_status) override;
35 bool ShouldReportDatabaseError() override; 37 bool ShouldReportDatabaseError() override;
36 38
37 // KeyedService: 39 // KeyedService:
38 void Shutdown() override; 40 void Shutdown() override;
39 41
40 // TopSitesObserver: 42 // TopSitesObserver:
41 void TopSitesLoaded(history::TopSites* top_sites) override; 43 void TopSitesLoaded(history::TopSites* top_sites) override;
42 void TopSitesChanged(history::TopSites* top_sites) override; 44 void TopSitesChanged(history::TopSites* top_sites) override;
43 45
44 private: 46 private:
45 // The BookmarkModel, this should outlive ChromeHistoryClient. 47 // The BookmarkModel, this should outlive ChromeHistoryClient.
46 BookmarkModel* bookmark_model_; 48 BookmarkModel* bookmark_model_;
47 Profile* profile_; 49 Profile* profile_;
48 // The TopSites object is owned by the Profile (see 50 scoped_refptr<history::TopSites> top_sites_;
49 // chrome/browser/profiles/profile_impl.h)
50 // and lazily constructed by the getter.
51 // ChromeHistoryClient is a KeyedService linked to the Profile lifetime by the
52 // ChromeHistoryClientFactory (which is a BrowserContextKeyedServiceFactory).
53 // Before the Profile is destroyed, all the KeyedService Shutdown methods are
54 // called, and the Profile is fully constructed before any of the KeyedService
55 // can be constructed. The TopSites does not use the HistoryService nor the
56 // HistoryClient during construction (it uses it later, but supports getting
57 // an NULL pointer).
58 history::TopSites* top_sites_;
59 51
60 DISALLOW_COPY_AND_ASSIGN(ChromeHistoryClient); 52 DISALLOW_COPY_AND_ASSIGN(ChromeHistoryClient);
61 }; 53 };
62 54
63 #endif // CHROME_BROWSER_HISTORY_CHROME_HISTORY_CLIENT_H_ 55 #endif // CHROME_BROWSER_HISTORY_CHROME_HISTORY_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698