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

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

Issue 285233012: Abstract history dependencies on bookmarks through HistoryClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix android unit tests Created 6 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 #include "chrome/browser/history/chrome_history_client.h" 5 #include "chrome/browser/history/chrome_history_client.h"
6 6
7 ChromeHistoryClient::ChromeHistoryClient() { 7 #include "base/logging.h"
8 #include "components/bookmarks/browser/bookmark_model.h"
9
10 ChromeHistoryClient::ChromeHistoryClient(BookmarkModel* bookmark_model)
11 : bookmark_model_(bookmark_model) {
12 DCHECK(bookmark_model_);
8 } 13 }
14
15 void ChromeHistoryClient::BlockUntilBookmarksLoaded() {
16 bookmark_model_->BlockTillLoaded();
17 }
18
19 bool ChromeHistoryClient::IsBookmarked(const GURL& url) {
20 return bookmark_model_->IsBookmarked(url);
21 }
22
23 void ChromeHistoryClient::GetBookmarks(
24 std::vector<history::URLAndTitle>* bookmarks) {
25 std::vector<BookmarkModel::URLAndTitle> bookmarks_url_and_title;
26 bookmark_model_->GetBookmarks(&bookmarks_url_and_title);
27
28 bookmarks->reserve(bookmarks->size() + bookmarks_url_and_title.size());
29 for (size_t i = 0; i < bookmarks_url_and_title.size(); ++i) {
30 history::URLAndTitle value = {
31 bookmarks_url_and_title[i].url,
32 bookmarks_url_and_title[i].title,
33 };
34 bookmarks->push_back(value);
35 }
36 }
37
38 void ChromeHistoryClient::Shutdown() {
39 // It's possible that bookmarks haven't loaded and history is waiting for
40 // bookmarks to complete loading. In such a situation history can't shutdown
41 // (meaning if we invoked HistoryService::Cleanup now, we would deadlock). To
42 // break the deadlock we tell BookmarkModel it's about to be deleted so that
43 // it can release the signal history is waiting on, allowing history to
44 // shutdown (HistoryService::Cleanup to complete). In such a scenario history
45 // sees an incorrect view of bookmarks, but it's better than a deadlock.
46 bookmark_model_->Shutdown();
47 }
OLDNEW
« no previous file with comments | « chrome/browser/history/chrome_history_client.h ('k') | chrome/browser/history/chrome_history_client_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698