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

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

Issue 23861005: Fix NULL deref in HistoryBackend::ExpireHistoryBetween. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/history_backend.h" 5 #include "chrome/browser/history/history_backend.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <list> 9 #include <list>
10 #include <map> 10 #include <map>
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 thumbnail_db_->TrimMemory(trim_aggressively); 703 thumbnail_db_->TrimMemory(trim_aggressively);
704 if (archived_db_) 704 if (archived_db_)
705 archived_db_->TrimMemory(trim_aggressively); 705 archived_db_->TrimMemory(trim_aggressively);
706 } 706 }
707 707
708 void HistoryBackend::CloseAllDatabases() { 708 void HistoryBackend::CloseAllDatabases() {
709 if (db_) { 709 if (db_) {
710 // Commit the long-running transaction. 710 // Commit the long-running transaction.
711 db_->CommitTransaction(); 711 db_->CommitTransaction();
712 db_.reset(); 712 db_.reset();
713 // Forget the first recorded time since the database is closed.
714 first_recorded_time_ = base::Time();
713 } 715 }
714 if (thumbnail_db_) { 716 if (thumbnail_db_) {
715 thumbnail_db_->CommitTransaction(); 717 thumbnail_db_->CommitTransaction();
716 thumbnail_db_.reset(); 718 thumbnail_db_.reset();
717 } 719 }
718 if (archived_db_) { 720 if (archived_db_) {
719 archived_db_->CommitTransaction(); 721 archived_db_->CommitTransaction();
720 archived_db_.reset(); 722 archived_db_.reset();
721 } 723 }
722 } 724 }
(...skipping 1755 matching lines...) Expand 10 before | Expand all | Expand 10 after
2478 db_->GetStartDate(&first_recorded_time_); 2480 db_->GetStartDate(&first_recorded_time_);
2479 // Force a commit, if the user is deleting something for privacy reasons, we 2481 // Force a commit, if the user is deleting something for privacy reasons, we
2480 // want to get it on disk ASAP. 2482 // want to get it on disk ASAP.
2481 Commit(); 2483 Commit();
2482 } 2484 }
2483 2485
2484 void HistoryBackend::ExpireHistoryBetween( 2486 void HistoryBackend::ExpireHistoryBetween(
2485 const std::set<GURL>& restrict_urls, 2487 const std::set<GURL>& restrict_urls,
2486 Time begin_time, 2488 Time begin_time,
2487 Time end_time) { 2489 Time end_time) {
2488 if (db_) { 2490 if (!db_)
2489 if (begin_time.is_null() && (end_time.is_null() || end_time.is_max()) && 2491 return;
2490 restrict_urls.empty()) {
2491 // Special case deleting all history so it can be faster and to reduce the
2492 // possibility of an information leak.
2493 DeleteAllHistory();
2494 } else {
2495 // Clearing parts of history, have the expirer do the depend
2496 expirer_.ExpireHistoryBetween(restrict_urls, begin_time, end_time);
2497 2492
2498 // Force a commit, if the user is deleting something for privacy reasons, 2493 if (begin_time.is_null() && (end_time.is_null() || end_time.is_max()) &&
2499 // we want to get it on disk ASAP. 2494 restrict_urls.empty()) {
2500 Commit(); 2495 // Special case deleting all history so it can be faster and to reduce the
2501 } 2496 // possibility of an information leak.
2497 DeleteAllHistory();
2498 } else {
2499 // Clearing parts of history, have the expirer do the depend
2500 expirer_.ExpireHistoryBetween(restrict_urls, begin_time, end_time);
2501
2502 // Force a commit, if the user is deleting something for privacy reasons,
2503 // we want to get it on disk ASAP.
2504 Commit();
2502 } 2505 }
2503 2506
2504 if (begin_time <= first_recorded_time_) 2507 if (begin_time <= first_recorded_time_)
2505 db_->GetStartDate(&first_recorded_time_); 2508 db_->GetStartDate(&first_recorded_time_);
2506 } 2509 }
2507 2510
2508 void HistoryBackend::ExpireHistoryForTimes( 2511 void HistoryBackend::ExpireHistoryForTimes(
2509 const std::set<base::Time>& times, 2512 const std::set<base::Time>& times,
2510 base::Time begin_time, base::Time end_time) { 2513 base::Time begin_time, base::Time end_time) {
2511 if (times.empty() || !db_) 2514 if (times.empty() || !db_)
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
2859 int rank = kPageVisitStatsMaxTopSites; 2862 int rank = kPageVisitStatsMaxTopSites;
2860 std::map<GURL, int>::const_iterator it = most_visited_urls_map_.find(url); 2863 std::map<GURL, int>::const_iterator it = most_visited_urls_map_.find(url);
2861 if (it != most_visited_urls_map_.end()) 2864 if (it != most_visited_urls_map_.end())
2862 rank = (*it).second; 2865 rank = (*it).second;
2863 UMA_HISTOGRAM_ENUMERATION("History.TopSitesVisitsByRank", 2866 UMA_HISTOGRAM_ENUMERATION("History.TopSitesVisitsByRank",
2864 rank, kPageVisitStatsMaxTopSites + 1); 2867 rank, kPageVisitStatsMaxTopSites + 1);
2865 } 2868 }
2866 #endif 2869 #endif
2867 2870
2868 } // namespace history 2871 } // namespace history
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698