| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 cur_visit.url_id = main_id_to_archived_id[cur_visit.url_id]; | 409 cur_visit.url_id = main_id_to_archived_id[cur_visit.url_id]; |
| 410 cur_visit.referring_visit = 0; | 410 cur_visit.referring_visit = 0; |
| 411 archived_db_->AddVisit(&cur_visit); | 411 archived_db_->AddVisit(&cur_visit); |
| 412 // Ignore failures, we will delete it from the main DB no matter what. | 412 // Ignore failures, we will delete it from the main DB no matter what. |
| 413 } | 413 } |
| 414 } | 414 } |
| 415 | 415 |
| 416 void ExpireHistoryBackend::ScheduleArchive(TimeDelta delay) { | 416 void ExpireHistoryBackend::ScheduleArchive(TimeDelta delay) { |
| 417 factory_.RevokeAll(); | 417 factory_.RevokeAll(); |
| 418 MessageLoop::current()->PostDelayedTask(FROM_HERE, factory_.NewRunnableMethod( | 418 MessageLoop::current()->PostDelayedTask(FROM_HERE, factory_.NewRunnableMethod( |
| 419 &ExpireHistoryBackend::DoArchiveIteration), | 419 &ExpireHistoryBackend::DoArchiveIteration), delay.InMilliseconds()); |
| 420 static_cast<int>(delay.InMilliseconds())); | |
| 421 } | 420 } |
| 422 | 421 |
| 423 void ExpireHistoryBackend::DoArchiveIteration() { | 422 void ExpireHistoryBackend::DoArchiveIteration() { |
| 424 DCHECK(expiration_threshold_ != TimeDelta()) << "threshold should be set"; | 423 DCHECK(expiration_threshold_ != TimeDelta()) << "threshold should be set"; |
| 425 Time threshold = Time::Now() - expiration_threshold_; | 424 Time threshold = Time::Now() - expiration_threshold_; |
| 426 | 425 |
| 427 if (ArchiveSomeOldHistory(threshold, kNumExpirePerIteration)) { | 426 if (ArchiveSomeOldHistory(threshold, kNumExpirePerIteration)) { |
| 428 // Possibly more items to delete now, schedule it sooner to happen again. | 427 // Possibly more items to delete now, schedule it sooner to happen again. |
| 429 ScheduleArchive(TimeDelta::FromSeconds(kExpirationDelaySec)); | 428 ScheduleArchive(TimeDelta::FromSeconds(kExpirationDelaySec)); |
| 430 } else { | 429 } else { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 // We use the bookmark service to determine if a URL is bookmarked. The | 502 // We use the bookmark service to determine if a URL is bookmarked. The |
| 504 // bookmark service is loaded on a separate thread and may not be done by the | 503 // bookmark service is loaded on a separate thread and may not be done by the |
| 505 // time we get here. We therefor block until the bookmarks have finished | 504 // time we get here. We therefor block until the bookmarks have finished |
| 506 // loading. | 505 // loading. |
| 507 if (bookmark_service_) | 506 if (bookmark_service_) |
| 508 bookmark_service_->BlockTillLoaded(); | 507 bookmark_service_->BlockTillLoaded(); |
| 509 return bookmark_service_; | 508 return bookmark_service_; |
| 510 } | 509 } |
| 511 | 510 |
| 512 } // namespace history | 511 } // namespace history |
| OLD | NEW |