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

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

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
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/history/chrome_history_backend_client.h"
6
7 #include "chrome/common/chrome_version_info.h"
8 #include "components/bookmarks/browser/bookmark_model.h"
9 #include "url/gurl.h"
10
11 #if defined(OS_ANDROID)
12 #include "base/files/file_path.h"
13 #include "base/logging.h"
14 #include "chrome/browser/history/android/android_provider_backend.h"
15 #include "components/history/core/browser/history_backend.h"
16 #endif
17
18 #if defined(OS_ANDROID)
19 namespace {
20 const base::FilePath::CharType kAndroidCacheFilename[] =
21 FILE_PATH_LITERAL("AndroidCache");
22 }
23 #endif // defined(OS_IOS)
24
25 ChromeHistoryBackendClient::ChromeHistoryBackendClient(
26 bookmarks::BookmarkModel* bookmark_model)
27 : bookmark_model_(bookmark_model) {
28 }
29
30 ChromeHistoryBackendClient::~ChromeHistoryBackendClient() {
31 }
32
33 bool ChromeHistoryBackendClient::IsBookmarked(const GURL& url) {
34 if (!bookmark_model_)
35 return false;
36
37 // HistoryBackendClient is used to determine if an URL is bookmarked. The data
38 // is loaded on a separate thread and may not be done when this method is
39 // called, therefore blocks until the bookmarks have finished loading.
40 bookmark_model_->BlockTillLoaded();
41 return bookmark_model_->IsBookmarked(url);
42 }
43
44 void ChromeHistoryBackendClient::GetBookmarks(
45 std::vector<history::URLAndTitle>* bookmarks) {
46 if (!bookmark_model_)
47 return;
48
49 // HistoryBackendClient is used to determine the set of bookmarked URLs. The
50 // data is loaded on a separate thread and may not be done when this method is
51 // called, therefore blocks until the bookmarks have finished loading.
52 std::vector<bookmarks::BookmarkModel::URLAndTitle> url_and_titles;
53 bookmark_model_->BlockTillLoaded();
54 bookmark_model_->GetBookmarks(&url_and_titles);
55
56 bookmarks->reserve(bookmarks->size() + url_and_titles.size());
57 for (const auto& url_and_title : url_and_titles) {
58 history::URLAndTitle value = { url_and_title.url, url_and_title.title };
59 bookmarks->push_back(value);
60 }
61 }
62
63 bool ChromeHistoryBackendClient::ShouldReportDatabaseError() {
64 // TODO(shess): For now, don't report on beta or stable so as not to
65 // overwhelm the crash server. Once the big fish are fried,
66 // consider reporting at a reduced rate on the bigger channels.
67 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel();
68 return channel != chrome::VersionInfo::CHANNEL_STABLE &&
69 channel != chrome::VersionInfo::CHANNEL_BETA;
70 }
71
72 #if defined(OS_ANDROID)
73 void ChromeHistoryBackendClient::OnHistoryBackendInitialized(
74 history::HistoryBackend* history_backend,
75 history::HistoryDatabase* history_database,
76 history::ThumbnailDatabase* thumbnail_database,
77 const base::FilePath& history_dir) {
78 DCHECK(history_backend);
79 if (thumbnail_database) {
80 history_backend->SetUserData(
81 history::AndroidProviderBackend::GetUserDataKey(),
82 new history::AndroidProviderBackend(
83 history_dir.Append(kAndroidCacheFilename), history_database,
84 thumbnail_database, this, history_backend));
85 }
86 }
87
88 void ChromeHistoryBackendClient::OnHistoryBackendDestroyed(
89 history::HistoryBackend* history_backend,
90 const base::FilePath& history_dir) {
91 sql::Connection::Delete(history_dir.Append(kAndroidCacheFilename));
92 }
93 #endif // defined(OS_ANDROID)
OLDNEW
« no previous file with comments | « chrome/browser/history/chrome_history_backend_client.h ('k') | chrome/browser/history/chrome_history_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698