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

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

Issue 690733002: Cleanup HistoryBackend and ExpireHistoryBackend interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@android-cleanup
Patch Set: Created 6 years, 1 month 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/expire_history_backend.h" 5 #include "chrome/browser/history/expire_history_backend.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <limits> 9 #include <limits>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/files/file_enumerator.h" 13 #include "base/files/file_enumerator.h"
14 #include "base/files/file_util.h" 14 #include "base/files/file_util.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/message_loop/message_loop.h" 16 #include "base/message_loop/message_loop.h"
17 #include "chrome/browser/chrome_notification_types.h" 17 #include "chrome/browser/chrome_notification_types.h"
droger 2014/10/29 17:55:11 Is this still needed?
sdefresne 2014/10/30 10:54:30 No, removed.
18 #include "chrome/browser/history/history_database.h" 18 #include "chrome/browser/history/history_database.h"
19 #include "chrome/browser/history/history_notifications.h" 19 #include "chrome/browser/history/history_notifications.h"
droger 2014/10/29 17:55:11 Is this still needed?
sdefresne 2014/10/30 10:54:30 No, removed.
20 #include "chrome/browser/history/thumbnail_database.h" 20 #include "chrome/browser/history/thumbnail_database.h"
21 #include "components/history/core/browser/history_client.h" 21 #include "components/history/core/browser/history_client.h"
22 22
23 namespace history { 23 namespace history {
24 24
25 // Helpers -------------------------------------------------------------------- 25 // Helpers --------------------------------------------------------------------
26 26
27 namespace { 27 namespace {
28 28
29 // The number of days by which the expiration threshold is advanced for items 29 // The number of days by which the expiration threshold is advanced for items
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 ExpireHistoryBackend::DeleteEffects::DeleteEffects() { 120 ExpireHistoryBackend::DeleteEffects::DeleteEffects() {
121 } 121 }
122 122
123 ExpireHistoryBackend::DeleteEffects::~DeleteEffects() { 123 ExpireHistoryBackend::DeleteEffects::~DeleteEffects() {
124 } 124 }
125 125
126 126
127 // ExpireHistoryBackend ------------------------------------------------------- 127 // ExpireHistoryBackend -------------------------------------------------------
128 128
129 ExpireHistoryBackend::ExpireHistoryBackend( 129 ExpireHistoryBackend::ExpireHistoryBackend(
130 BroadcastNotificationDelegate* delegate, 130 ExpireHistoryBackendDelegate* delegate,
131 HistoryClient* history_client) 131 HistoryClient* history_client)
132 : delegate_(delegate), 132 : delegate_(delegate),
133 main_db_(NULL), 133 main_db_(NULL),
134 thumb_db_(NULL), 134 thumb_db_(NULL),
135 history_client_(history_client), 135 history_client_(history_client),
136 weak_factory_(this) { 136 weak_factory_(this) {
137 } 137 }
138 138
139 ExpireHistoryBackend::~ExpireHistoryBackend() { 139 ExpireHistoryBackend::~ExpireHistoryBackend() {
140 } 140 }
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 thumb_db_->DeleteFavicon(*i)) { 310 thumb_db_->DeleteFavicon(*i)) {
311 effects->deleted_favicons.insert(icon_url); 311 effects->deleted_favicons.insert(icon_url);
312 } 312 }
313 } 313 }
314 } 314 }
315 } 315 }
316 316
317 void ExpireHistoryBackend::BroadcastNotifications(DeleteEffects* effects, 317 void ExpireHistoryBackend::BroadcastNotifications(DeleteEffects* effects,
318 DeletionType type) { 318 DeletionType type) {
319 if (!effects->modified_urls.empty()) { 319 if (!effects->modified_urls.empty()) {
320 scoped_ptr<URLsModifiedDetails> details(new URLsModifiedDetails); 320 delegate_->NotifyURLsModified(effects->modified_urls);
321 details->changed_urls = effects->modified_urls;
322 delegate_->NotifySyncURLsModified(&details->changed_urls);
323 delegate_->BroadcastNotifications(
324 chrome::NOTIFICATION_HISTORY_URLS_MODIFIED, details.Pass());
325 } 321 }
326 if (!effects->deleted_urls.empty()) { 322 if (!effects->deleted_urls.empty()) {
327 scoped_ptr<URLsDeletedDetails> details(new URLsDeletedDetails); 323 delegate_->NotifyURLsDeleted(false,
328 details->all_history = false; 324 type == DELETION_EXPIRED,
329 details->expired = (type == DELETION_EXPIRED); 325 effects->deleted_urls,
330 details->rows = effects->deleted_urls; 326 effects->deleted_favicons);
331 details->favicon_urls = effects->deleted_favicons;
332 delegate_->NotifySyncURLsDeleted(details->all_history, details->expired,
333 &details->rows);
334 delegate_->BroadcastNotifications(chrome::NOTIFICATION_HISTORY_URLS_DELETED,
335 details.Pass());
336 } 327 }
337 } 328 }
338 329
339 void ExpireHistoryBackend::DeleteVisitRelatedInfo(const VisitVector& visits, 330 void ExpireHistoryBackend::DeleteVisitRelatedInfo(const VisitVector& visits,
340 DeleteEffects* effects) { 331 DeleteEffects* effects) {
341 for (size_t i = 0; i < visits.size(); i++) { 332 for (size_t i = 0; i < visits.size(); i++) {
342 // Delete the visit itself. 333 // Delete the visit itself.
343 main_db_->DeleteVisit(visits[i]); 334 main_db_->DeleteVisit(visits[i]);
344 335
345 // Add the URL row to the affected URL list. 336 // Add the URL row to the affected URL list.
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 HistoryClient* ExpireHistoryBackend::GetHistoryClient() { 506 HistoryClient* ExpireHistoryBackend::GetHistoryClient() {
516 // We use the history client to determine if a URL is bookmarked. The data is 507 // We use the history client to determine if a URL is bookmarked. The data is
517 // loaded on a separate thread and may not be done by the time we get here. 508 // loaded on a separate thread and may not be done by the time we get here.
518 // We therefore block until the bookmarks have finished loading. 509 // We therefore block until the bookmarks have finished loading.
519 if (history_client_) 510 if (history_client_)
520 history_client_->BlockUntilBookmarksLoaded(); 511 history_client_->BlockUntilBookmarksLoaded();
521 return history_client_; 512 return history_client_;
522 } 513 }
523 514
524 } // namespace history 515 } // namespace history
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698