| Index: chrome/browser/history/chrome_history_client.cc
|
| diff --git a/chrome/browser/history/chrome_history_client.cc b/chrome/browser/history/chrome_history_client.cc
|
| index d6310c8877dba3a05ee40586620174f39d1d26c8..61f4b21fee0bb77b8623a0c7826202365e813f92 100644
|
| --- a/chrome/browser/history/chrome_history_client.cc
|
| +++ b/chrome/browser/history/chrome_history_client.cc
|
| @@ -4,5 +4,44 @@
|
|
|
| #include "chrome/browser/history/chrome_history_client.h"
|
|
|
| -ChromeHistoryClient::ChromeHistoryClient() {
|
| +#include "base/logging.h"
|
| +#include "components/bookmarks/browser/bookmark_model.h"
|
| +
|
| +ChromeHistoryClient::ChromeHistoryClient(BookmarkModel* bookmark_model)
|
| + : bookmark_model_(bookmark_model) {
|
| + DCHECK(bookmark_model_);
|
| +}
|
| +
|
| +void ChromeHistoryClient::BlockUntilBookmarksLoaded() {
|
| + bookmark_model_->BlockTillLoaded();
|
| +}
|
| +
|
| +bool ChromeHistoryClient::IsBookmarked(const GURL& url) {
|
| + return bookmark_model_->IsBookmarked(url);
|
| +}
|
| +
|
| +void ChromeHistoryClient::GetBookmarks(
|
| + std::vector<history::URLAndTitle>* bookmarks) {
|
| + std::vector<BookmarkModel::URLAndTitle> bookmarks_url_and_title;
|
| + bookmark_model_->GetBookmarks(&bookmarks_url_and_title);
|
| +
|
| + bookmarks->reserve(bookmarks->size() + bookmarks_url_and_title.size());
|
| + for (size_t i = 0; i < bookmarks_url_and_title.size(); ++i) {
|
| + history::URLAndTitle value = {
|
| + bookmarks_url_and_title[i].url,
|
| + bookmarks_url_and_title[i].title,
|
| + };
|
| + bookmarks->push_back(value);
|
| + }
|
| +}
|
| +
|
| +void ChromeHistoryClient::Shutdown() {
|
| + // It's possible that bookmarks haven't loaded and history is waiting for
|
| + // bookmarks to complete loading. In such a situation history can't shutdown
|
| + // (meaning if we invoked HistoryService::Cleanup now, we would deadlock). To
|
| + // break the deadlock we tell BookmarkModel it's about to be deleted so that
|
| + // it can release the signal history is waiting on, allowing history to
|
| + // shutdown (HistoryService::Cleanup to complete). In such a scenario history
|
| + // sees an incorrect view of bookmarks, but it's better than a deadlock.
|
| + bookmark_model_->Shutdown();
|
| }
|
|
|