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

Side by Side Diff: components/history/core/browser/history_client.h

Issue 1198373002: Split HistoryClient in two objects (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@1192403002
Patch Set: Add comments in ChromeHistoryBackendClient Created 5 years, 6 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 COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_CLIENT_H_ 5 #ifndef COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_CLIENT_H_
6 #define COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_CLIENT_H_ 6 #define COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_CLIENT_H_
7 7
8 #include <vector> 8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "sql/init_status.h"
9 11
10 #include "base/macros.h" 12 class GURL;
11 #include "base/strings/string16.h"
12 #include "sql/init_status.h"
13 #include "url/gurl.h"
14 13
15 namespace base { 14 namespace base {
16 class FilePath; 15 class FilePath;
17 } 16 }
18 17
19 namespace history { 18 namespace history {
20 19
21 class HistoryBackend; 20 class HistoryBackend;
21 class HistoryBackendClient;
22 class HistoryDatabase; 22 class HistoryDatabase;
23 class ThumbnailDatabase; 23 class ThumbnailDatabase;
24 24
25 struct URLAndTitle {
26 GURL url;
27 base::string16 title;
28 };
29
30 // This class abstracts operations that depend on the embedder's environment, 25 // This class abstracts operations that depend on the embedder's environment,
31 // e.g. Chrome. 26 // e.g. Chrome.
32 class HistoryClient { 27 class HistoryClient {
33 public: 28 public:
34 HistoryClient(); 29 HistoryClient() {}
35 virtual ~HistoryClient(); 30 virtual ~HistoryClient() {}
36 31
37 // Called before HistoryService is shutdown. 32 // Called before HistoryService is shutdown.
38 virtual void Shutdown(); 33 virtual void Shutdown() = 0;
39
40 // Waits until the bookmarks have been loaded.
41 //
42 // Must not be called from the main thread.
43 virtual void BlockUntilBookmarksLoaded();
44
45 // Returns true if the specified URL is bookmarked.
46 //
47 // If not on the main thread, then BlockUntilBookmarksLoaded must be called.
48 virtual bool IsBookmarked(const GURL& url);
49
50 // Returns, by reference in |bookmarks|, the set of bookmarked urls and their
51 // titles. This returns the unique set of URLs. For example, if two bookmarks
52 // reference the same URL only one entry is added even if the title are not
53 // the same.
54 //
55 // If not on the main thread, then BlockUntilBookmarksLoaded must be called.
56 virtual void GetBookmarks(std::vector<URLAndTitle>* bookmarks);
57 34
58 // Returns true if this look like the type of URL that should be added to the 35 // Returns true if this look like the type of URL that should be added to the
59 // history. 36 // history.
60 virtual bool CanAddURL(const GURL& url); 37 virtual bool CanAddURL(const GURL& url) = 0;
61 38
62 // Notifies the embedder that there was a problem reading the database. 39 // Notifies the embedder that there was a problem reading the database.
63 // 40 virtual void NotifyProfileError(sql::InitStatus init_status) = 0;
64 // Must be called from the main thread.
65 virtual void NotifyProfileError(sql::InitStatus init_status);
66 41
67 // Returns whether database errors should be reported to the crash server. 42 // Returns a new HistoryBackendClient instance.
68 virtual bool ShouldReportDatabaseError(); 43 virtual scoped_ptr<HistoryBackendClient> CreateBackendClient() = 0;
69
70 // Called upon initialization of the HistoryBackend.
71 virtual void OnHistoryBackendInitialized(
72 HistoryBackend* history_backend,
73 HistoryDatabase* history_database,
74 ThumbnailDatabase* thumbnail_database,
75 const base::FilePath& history_dir);
76
77 // Called upon destruction of the HistoryBackend.
78 virtual void OnHistoryBackendDestroyed(HistoryBackend* history_backend,
79 const base::FilePath& history_dir);
80 44
81 private: 45 private:
82 DISALLOW_COPY_AND_ASSIGN(HistoryClient); 46 DISALLOW_COPY_AND_ASSIGN(HistoryClient);
83 }; 47 };
84 48
85 } // namespace history 49 } // namespace history
86 50
87 #endif // COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_CLIENT_H_ 51 #endif // COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_CLIENT_H_
OLDNEW
« no previous file with comments | « components/history/core/browser/history_backend_unittest.cc ('k') | components/history/core/browser/history_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698