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

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: Address comments 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"
18 #include "chrome/browser/history/history_database.h" 17 #include "chrome/browser/history/history_database.h"
19 #include "chrome/browser/history/history_notifications.h"
20 #include "chrome/browser/history/thumbnail_database.h" 18 #include "chrome/browser/history/thumbnail_database.h"
21 #include "components/history/core/browser/history_client.h" 19 #include "components/history/core/browser/history_client.h"
22 20
23 namespace history { 21 namespace history {
24 22
25 // Helpers -------------------------------------------------------------------- 23 // Helpers --------------------------------------------------------------------
26 24
27 namespace { 25 namespace {
28 26
29 // The number of days by which the expiration threshold is advanced for items 27 // 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() { 118 ExpireHistoryBackend::DeleteEffects::DeleteEffects() {
121 } 119 }
122 120
123 ExpireHistoryBackend::DeleteEffects::~DeleteEffects() { 121 ExpireHistoryBackend::DeleteEffects::~DeleteEffects() {
124 } 122 }
125 123
126 124
127 // ExpireHistoryBackend ------------------------------------------------------- 125 // ExpireHistoryBackend -------------------------------------------------------
128 126
129 ExpireHistoryBackend::ExpireHistoryBackend( 127 ExpireHistoryBackend::ExpireHistoryBackend(
130 BroadcastNotificationDelegate* delegate, 128 ExpireHistoryBackendDelegate* delegate,
131 HistoryClient* history_client) 129 HistoryClient* history_client)
132 : delegate_(delegate), 130 : delegate_(delegate),
133 main_db_(NULL), 131 main_db_(NULL),
134 thumb_db_(NULL), 132 thumb_db_(NULL),
135 history_client_(history_client), 133 history_client_(history_client),
136 weak_factory_(this) { 134 weak_factory_(this) {
137 } 135 }
138 136
139 ExpireHistoryBackend::~ExpireHistoryBackend() { 137 ExpireHistoryBackend::~ExpireHistoryBackend() {
140 } 138 }
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 thumb_db_->DeleteFavicon(*i)) { 308 thumb_db_->DeleteFavicon(*i)) {
311 effects->deleted_favicons.insert(icon_url); 309 effects->deleted_favicons.insert(icon_url);
312 } 310 }
313 } 311 }
314 } 312 }
315 } 313 }
316 314
317 void ExpireHistoryBackend::BroadcastNotifications(DeleteEffects* effects, 315 void ExpireHistoryBackend::BroadcastNotifications(DeleteEffects* effects,
318 DeletionType type) { 316 DeletionType type) {
319 if (!effects->modified_urls.empty()) { 317 if (!effects->modified_urls.empty()) {
320 scoped_ptr<URLsModifiedDetails> details(new URLsModifiedDetails); 318 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 } 319 }
326 if (!effects->deleted_urls.empty()) { 320 if (!effects->deleted_urls.empty()) {
327 scoped_ptr<URLsDeletedDetails> details(new URLsDeletedDetails); 321 delegate_->NotifyURLsDeleted(false,
328 details->all_history = false; 322 type == DELETION_EXPIRED,
329 details->expired = (type == DELETION_EXPIRED); 323 effects->deleted_urls,
330 details->rows = effects->deleted_urls; 324 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 } 325 }
337 } 326 }
338 327
339 void ExpireHistoryBackend::DeleteVisitRelatedInfo(const VisitVector& visits, 328 void ExpireHistoryBackend::DeleteVisitRelatedInfo(const VisitVector& visits,
340 DeleteEffects* effects) { 329 DeleteEffects* effects) {
341 for (size_t i = 0; i < visits.size(); i++) { 330 for (size_t i = 0; i < visits.size(); i++) {
342 // Delete the visit itself. 331 // Delete the visit itself.
343 main_db_->DeleteVisit(visits[i]); 332 main_db_->DeleteVisit(visits[i]);
344 333
345 // Add the URL row to the affected URL list. 334 // 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() { 504 HistoryClient* ExpireHistoryBackend::GetHistoryClient() {
516 // We use the history client to determine if a URL is bookmarked. The data is 505 // 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. 506 // 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. 507 // We therefore block until the bookmarks have finished loading.
519 if (history_client_) 508 if (history_client_)
520 history_client_->BlockUntilBookmarksLoaded(); 509 history_client_->BlockUntilBookmarksLoaded();
521 return history_client_; 510 return history_client_;
522 } 511 }
523 512
524 } // namespace history 513 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/expire_history_backend.h ('k') | chrome/browser/history/expire_history_backend_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698