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

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

Issue 934083003: Cleanup HistoryService and HistoryBackend interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@android-backend-provider
Patch Set: Created 5 years, 10 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
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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 // base::WeakPtrFactory which will handle everything automatically (like we do 125 // base::WeakPtrFactory which will handle everything automatically (like we do
126 // in ExpireHistoryBackend). 126 // in ExpireHistoryBackend).
127 class CommitLaterTask : public base::RefCounted<CommitLaterTask> { 127 class CommitLaterTask : public base::RefCounted<CommitLaterTask> {
128 public: 128 public:
129 explicit CommitLaterTask(HistoryBackend* history_backend) 129 explicit CommitLaterTask(HistoryBackend* history_backend)
130 : history_backend_(history_backend) { 130 : history_backend_(history_backend) {
131 } 131 }
132 132
133 // The backend will call this function if it is being destroyed so that we 133 // The backend will call this function if it is being destroyed so that we
134 // release our reference. 134 // release our reference.
135 void Cancel() { 135 void Cancel() { history_backend_ = nullptr; }
136 history_backend_ = NULL;
137 }
138 136
139 void RunCommit() { 137 void RunCommit() {
140 if (history_backend_.get()) 138 if (history_backend_.get())
141 history_backend_->Commit(); 139 history_backend_->Commit();
142 } 140 }
143 141
144 private: 142 private:
145 friend class base::RefCounted<CommitLaterTask>; 143 friend class base::RefCounted<CommitLaterTask>;
146 144
147 ~CommitLaterTask() {} 145 ~CommitLaterTask() {}
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 origin_loop_->PostTask( 178 origin_loop_->PostTask(
181 FROM_HERE, 179 FROM_HERE,
182 base::Bind(&RunUnlessCanceled, 180 base::Bind(&RunUnlessCanceled,
183 base::Bind(&HistoryDBTask::DoneRunOnMainThread, 181 base::Bind(&HistoryDBTask::DoneRunOnMainThread,
184 base::Unretained(task_.get())), 182 base::Unretained(task_.get())),
185 is_canceled_)); 183 is_canceled_));
186 } 184 }
187 185
188 // HistoryBackend -------------------------------------------------------------- 186 // HistoryBackend --------------------------------------------------------------
189 187
190 HistoryBackend::HistoryBackend(const base::FilePath& history_dir, 188 HistoryBackend::HistoryBackend(Delegate* delegate,
191 Delegate* delegate,
192 HistoryClient* history_client) 189 HistoryClient* history_client)
193 : delegate_(delegate), 190 : delegate_(delegate),
194 history_dir_(history_dir),
195 scheduled_kill_db_(false), 191 scheduled_kill_db_(false),
196 expirer_(this, history_client), 192 expirer_(this, history_client),
197 recent_redirects_(kMaxRedirectCount), 193 recent_redirects_(kMaxRedirectCount),
198 backend_destroy_message_loop_(NULL), 194 backend_destroy_message_loop_(nullptr),
199 segment_queried_(false), 195 segment_queried_(false),
200 history_client_(history_client) { 196 history_client_(history_client) {
201 } 197 }
202 198
203 HistoryBackend::~HistoryBackend() { 199 HistoryBackend::~HistoryBackend() {
204 DCHECK(!scheduled_commit_.get()) << "Deleting without cleanup"; 200 DCHECK(!scheduled_commit_.get()) << "Deleting without cleanup";
205 STLDeleteContainerPointers(queued_history_db_tasks_.begin(), 201 STLDeleteContainerPointers(queued_history_db_tasks_.begin(),
206 queued_history_db_tasks_.end()); 202 queued_history_db_tasks_.end());
207 queued_history_db_tasks_.clear(); 203 queued_history_db_tasks_.clear();
208 204
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 // a segment for that one as well. So we end up with google.net and google.com 325 // a segment for that one as well. So we end up with google.net and google.com
330 // in the segment table, showing as 2 entries in the NTP. 326 // in the segment table, showing as 2 entries in the NTP.
331 // Note also that we should still be updating the visit count for that segment 327 // Note also that we should still be updating the visit count for that segment
332 // which we are not doing now. It should be addressed when 328 // which we are not doing now. It should be addressed when
333 // http://crbug.com/96860 is fixed. 329 // http://crbug.com/96860 is fixed.
334 if ((t == ui::PAGE_TRANSITION_TYPED || 330 if ((t == ui::PAGE_TRANSITION_TYPED ||
335 t == ui::PAGE_TRANSITION_AUTO_BOOKMARK) && 331 t == ui::PAGE_TRANSITION_AUTO_BOOKMARK) &&
336 (transition_type & ui::PAGE_TRANSITION_FORWARD_BACK) == 0) { 332 (transition_type & ui::PAGE_TRANSITION_FORWARD_BACK) == 0) {
337 // If so, create or get the segment. 333 // If so, create or get the segment.
338 std::string segment_name = db_->ComputeSegmentName(url); 334 std::string segment_name = db_->ComputeSegmentName(url);
339 URLID url_id = db_->GetRowForURL(url, NULL); 335 URLID url_id = db_->GetRowForURL(url, nullptr);
340 if (!url_id) 336 if (!url_id)
341 return 0; 337 return 0;
342 338
343 segment_id = db_->GetSegmentNamed(segment_name); 339 segment_id = db_->GetSegmentNamed(segment_name);
344 if (!segment_id) { 340 if (!segment_id) {
345 segment_id = db_->CreateSegment(url_id, segment_name); 341 segment_id = db_->CreateSegment(url_id, segment_name);
346 if (!segment_id) { 342 if (!segment_id) {
347 NOTREACHED(); 343 NOTREACHED();
348 return 0; 344 return 0;
349 } 345 }
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 ScheduleCommit(); 572 ScheduleCommit();
577 } 573 }
578 574
579 void HistoryBackend::InitImpl( 575 void HistoryBackend::InitImpl(
580 const std::string& languages, 576 const std::string& languages,
581 const HistoryDatabaseParams& history_database_params) { 577 const HistoryDatabaseParams& history_database_params) {
582 DCHECK(!db_) << "Initializing HistoryBackend twice"; 578 DCHECK(!db_) << "Initializing HistoryBackend twice";
583 // In the rare case where the db fails to initialize a dialog may get shown 579 // In the rare case where the db fails to initialize a dialog may get shown
584 // the blocks the caller, yet allows other messages through. For this reason 580 // the blocks the caller, yet allows other messages through. For this reason
585 // we only set db_ to the created database if creation is successful. That 581 // we only set db_ to the created database if creation is successful. That
586 // way other methods won't do anything as db_ is still NULL. 582 // way other methods won't do anything as db_ is still null.
587 583
588 TimeTicks beginning_time = TimeTicks::Now(); 584 TimeTicks beginning_time = TimeTicks::Now();
589 585
590 // Compute the file names. 586 // Compute the file names.
591 DCHECK(history_dir_ == history_database_params.history_dir); 587 history_dir_ = history_database_params.history_dir;
592 base::FilePath history_name = 588 base::FilePath history_name = history_dir_.Append(history::kHistoryFilename);
593 history_database_params.history_dir.Append(history::kHistoryFilename);
594 base::FilePath thumbnail_name = GetFaviconsFileName(); 589 base::FilePath thumbnail_name = GetFaviconsFileName();
595 base::FilePath archived_name = GetArchivedFileName(); 590 base::FilePath archived_name = GetArchivedFileName();
596 591
597 // Delete the old index database files which are no longer used. 592 // Delete the old index database files which are no longer used.
598 DeleteFTSIndexDatabases(); 593 DeleteFTSIndexDatabases();
599 594
600 // History database. 595 // History database.
601 db_.reset(new HistoryDatabase( 596 db_.reset(new HistoryDatabase(
602 history_database_params.download_interrupt_reason_none, 597 history_database_params.download_interrupt_reason_none,
603 history_database_params.download_interrupt_reason_crash)); 598 history_database_params.download_interrupt_reason_crash));
604 599
605 // Unretained to avoid a ref loop with db_. 600 // Unretained to avoid a ref loop with db_.
606 db_->set_error_callback( 601 db_->set_error_callback(
607 base::Bind(&HistoryBackend::DatabaseErrorCallback, 602 base::Bind(&HistoryBackend::DatabaseErrorCallback,
608 base::Unretained(this))); 603 base::Unretained(this)));
609 604
610 sql::InitStatus status = db_->Init(history_name); 605 sql::InitStatus status = db_->Init(history_name);
611 switch (status) { 606 switch (status) {
612 case sql::INIT_OK: 607 case sql::INIT_OK:
613 break; 608 break;
614 case sql::INIT_FAILURE: { 609 case sql::INIT_FAILURE: {
615 // A NULL db_ will cause all calls on this object to notice this error 610 // A null db_ will cause all calls on this object to notice this error
616 // and to not continue. If the error callback scheduled killing the 611 // and to not continue. If the error callback scheduled killing the
617 // database, the task it posted has not executed yet. Try killing the 612 // database, the task it posted has not executed yet. Try killing the
618 // database now before we close it. 613 // database now before we close it.
619 bool kill_db = scheduled_kill_db_; 614 bool kill_db = scheduled_kill_db_;
620 if (kill_db) 615 if (kill_db)
621 KillHistoryDatabase(); 616 KillHistoryDatabase();
622 UMA_HISTOGRAM_BOOLEAN("History.AttemptedToFixProfileError", kill_db); 617 UMA_HISTOGRAM_BOOLEAN("History.AttemptedToFixProfileError", kill_db);
623 delegate_->NotifyProfileError(status); 618 delegate_->NotifyProfileError(status);
624 db_.reset(); 619 db_.reset();
625 return; 620 return;
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
1049 return; 1044 return;
1050 1045
1051 db_->DeleteAllSearchTermsForKeyword(keyword_id); 1046 db_->DeleteAllSearchTermsForKeyword(keyword_id);
1052 ScheduleCommit(); 1047 ScheduleCommit();
1053 } 1048 }
1054 1049
1055 void HistoryBackend::DeleteKeywordSearchTermForURL(const GURL& url) { 1050 void HistoryBackend::DeleteKeywordSearchTermForURL(const GURL& url) {
1056 if (!db_) 1051 if (!db_)
1057 return; 1052 return;
1058 1053
1059 URLID url_id = db_->GetRowForURL(url, NULL); 1054 URLID url_id = db_->GetRowForURL(url, nullptr);
1060 if (!url_id) 1055 if (!url_id)
1061 return; 1056 return;
1062 db_->DeleteKeywordSearchTermForURL(url_id); 1057 db_->DeleteKeywordSearchTermForURL(url_id);
1063 1058
1064 if (delegate_) 1059 if (delegate_)
1065 delegate_->NotifyKeywordSearchTermDeleted(url_id); 1060 delegate_->NotifyKeywordSearchTermDeleted(url_id);
1066 1061
1067 ScheduleCommit(); 1062 ScheduleCommit();
1068 } 1063 }
1069 1064
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1252 options.begin_time <= first_recorded_time_) 1247 options.begin_time <= first_recorded_time_)
1253 result->set_reached_beginning(true); 1248 result->set_reached_beginning(true);
1254 } 1249 }
1255 1250
1256 void HistoryBackend::QueryRedirectsFrom(const GURL& from_url, 1251 void HistoryBackend::QueryRedirectsFrom(const GURL& from_url,
1257 RedirectList* redirects) { 1252 RedirectList* redirects) {
1258 redirects->clear(); 1253 redirects->clear();
1259 if (!db_) 1254 if (!db_)
1260 return; 1255 return;
1261 1256
1262 URLID from_url_id = db_->GetRowForURL(from_url, NULL); 1257 URLID from_url_id = db_->GetRowForURL(from_url, nullptr);
1263 VisitID cur_visit = db_->GetMostRecentVisitForURL(from_url_id, NULL); 1258 VisitID cur_visit = db_->GetMostRecentVisitForURL(from_url_id, nullptr);
1264 if (!cur_visit) 1259 if (!cur_visit)
1265 return; // No visits for URL. 1260 return; // No visits for URL.
1266 1261
1267 GetRedirectsFromSpecificVisit(cur_visit, redirects); 1262 GetRedirectsFromSpecificVisit(cur_visit, redirects);
1268 } 1263 }
1269 1264
1270 void HistoryBackend::QueryRedirectsTo(const GURL& to_url, 1265 void HistoryBackend::QueryRedirectsTo(const GURL& to_url,
1271 RedirectList* redirects) { 1266 RedirectList* redirects) {
1272 redirects->clear(); 1267 redirects->clear();
1273 if (!db_) 1268 if (!db_)
1274 return; 1269 return;
1275 1270
1276 URLID to_url_id = db_->GetRowForURL(to_url, NULL); 1271 URLID to_url_id = db_->GetRowForURL(to_url, nullptr);
1277 VisitID cur_visit = db_->GetMostRecentVisitForURL(to_url_id, NULL); 1272 VisitID cur_visit = db_->GetMostRecentVisitForURL(to_url_id, nullptr);
1278 if (!cur_visit) 1273 if (!cur_visit)
1279 return; // No visits for URL. 1274 return; // No visits for URL.
1280 1275
1281 GetRedirectsToSpecificVisit(cur_visit, redirects); 1276 GetRedirectsToSpecificVisit(cur_visit, redirects);
1282 } 1277 }
1283 1278
1284 void HistoryBackend::GetVisibleVisitCountToHost( 1279 void HistoryBackend::GetVisibleVisitCountToHost(
1285 const GURL& url, 1280 const GURL& url,
1286 VisibleVisitCountToHostResult* result) { 1281 VisibleVisitCountToHostResult* result) {
1287 result->count = 0; 1282 result->count = 0;
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1448 } 1443 }
1449 UMA_HISTOGRAM_COUNTS("History.DeleteFTSIndexDatabases", 1444 UMA_HISTOGRAM_COUNTS("History.DeleteFTSIndexDatabases",
1450 num_databases_deleted); 1445 num_databases_deleted);
1451 } 1446 }
1452 1447
1453 void HistoryBackend::GetFavicons( 1448 void HistoryBackend::GetFavicons(
1454 const std::vector<GURL>& icon_urls, 1449 const std::vector<GURL>& icon_urls,
1455 int icon_types, 1450 int icon_types,
1456 const std::vector<int>& desired_sizes, 1451 const std::vector<int>& desired_sizes,
1457 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results) { 1452 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results) {
1458 UpdateFaviconMappingsAndFetchImpl(NULL, icon_urls, icon_types, desired_sizes, 1453 UpdateFaviconMappingsAndFetchImpl(nullptr, icon_urls, icon_types,
1459 bitmap_results); 1454 desired_sizes, bitmap_results);
1460 } 1455 }
1461 1456
1462 void HistoryBackend::GetLargestFaviconForURL( 1457 void HistoryBackend::GetLargestFaviconForURL(
1463 const GURL& page_url, 1458 const GURL& page_url,
1464 const std::vector<int>& icon_types, 1459 const std::vector<int>& icon_types,
1465 int minimum_size_in_pixels, 1460 int minimum_size_in_pixels,
1466 favicon_base::FaviconRawBitmapResult* favicon_bitmap_result) { 1461 favicon_base::FaviconRawBitmapResult* favicon_bitmap_result) {
1467 DCHECK(favicon_bitmap_result); 1462 DCHECK(favicon_bitmap_result);
1468 1463
1469 if (!db_ || !thumbnail_db_) 1464 if (!db_ || !thumbnail_db_)
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1591 void HistoryBackend::MergeFavicon( 1586 void HistoryBackend::MergeFavicon(
1592 const GURL& page_url, 1587 const GURL& page_url,
1593 const GURL& icon_url, 1588 const GURL& icon_url,
1594 favicon_base::IconType icon_type, 1589 favicon_base::IconType icon_type,
1595 scoped_refptr<base::RefCountedMemory> bitmap_data, 1590 scoped_refptr<base::RefCountedMemory> bitmap_data,
1596 const gfx::Size& pixel_size) { 1591 const gfx::Size& pixel_size) {
1597 if (!thumbnail_db_ || !db_) 1592 if (!thumbnail_db_ || !db_)
1598 return; 1593 return;
1599 1594
1600 favicon_base::FaviconID favicon_id = 1595 favicon_base::FaviconID favicon_id =
1601 thumbnail_db_->GetFaviconIDForFaviconURL(icon_url, icon_type, NULL); 1596 thumbnail_db_->GetFaviconIDForFaviconURL(icon_url, icon_type, nullptr);
1602 1597
1603 if (!favicon_id) { 1598 if (!favicon_id) {
1604 // There is no favicon at |icon_url|, create it. 1599 // There is no favicon at |icon_url|, create it.
1605 favicon_id = thumbnail_db_->AddFavicon(icon_url, icon_type); 1600 favicon_id = thumbnail_db_->AddFavicon(icon_url, icon_type);
1606 } 1601 }
1607 1602
1608 std::vector<FaviconBitmapIDSize> bitmap_id_sizes; 1603 std::vector<FaviconBitmapIDSize> bitmap_id_sizes;
1609 thumbnail_db_->GetFaviconBitmapIDSizes(favicon_id, &bitmap_id_sizes); 1604 thumbnail_db_->GetFaviconBitmapIDSizes(favicon_id, &bitmap_id_sizes);
1610 1605
1611 // If there is already a favicon bitmap of |pixel_size| at |icon_url|, 1606 // If there is already a favicon bitmap of |pixel_size| at |icon_url|,
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1736 if (!thumbnail_db_ || !db_) 1731 if (!thumbnail_db_ || !db_)
1737 return; 1732 return;
1738 1733
1739 DCHECK_GE(kMaxFaviconBitmapsPerIconURL, bitmaps.size()); 1734 DCHECK_GE(kMaxFaviconBitmapsPerIconURL, bitmaps.size());
1740 1735
1741 // Track whether the method modifies or creates any favicon bitmaps, favicons 1736 // Track whether the method modifies or creates any favicon bitmaps, favicons
1742 // or icon mappings. 1737 // or icon mappings.
1743 bool data_modified = false; 1738 bool data_modified = false;
1744 1739
1745 favicon_base::FaviconID icon_id = 1740 favicon_base::FaviconID icon_id =
1746 thumbnail_db_->GetFaviconIDForFaviconURL(icon_url, icon_type, NULL); 1741 thumbnail_db_->GetFaviconIDForFaviconURL(icon_url, icon_type, nullptr);
1747 1742
1748 if (!icon_id) { 1743 if (!icon_id) {
1749 icon_id = thumbnail_db_->AddFavicon(icon_url, icon_type); 1744 icon_id = thumbnail_db_->AddFavicon(icon_url, icon_type);
1750 data_modified = true; 1745 data_modified = true;
1751 } 1746 }
1752 1747
1753 data_modified |= SetFaviconBitmaps(icon_id, bitmaps); 1748 data_modified |= SetFaviconBitmaps(icon_id, bitmaps);
1754 1749
1755 std::vector<favicon_base::FaviconID> icon_ids(1u, icon_id); 1750 std::vector<favicon_base::FaviconID> icon_ids(1u, icon_id);
1756 data_modified |= 1751 data_modified |=
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1798 return; 1793 return;
1799 1794
1800 Time now = Time::Now(); 1795 Time now = Time::Now();
1801 1796
1802 // Track all URLs that had their favicons set or updated. 1797 // Track all URLs that had their favicons set or updated.
1803 std::set<GURL> favicons_changed; 1798 std::set<GURL> favicons_changed;
1804 1799
1805 for (size_t i = 0; i < favicon_usage.size(); i++) { 1800 for (size_t i = 0; i < favicon_usage.size(); i++) {
1806 favicon_base::FaviconID favicon_id = 1801 favicon_base::FaviconID favicon_id =
1807 thumbnail_db_->GetFaviconIDForFaviconURL( 1802 thumbnail_db_->GetFaviconIDForFaviconURL(
1808 favicon_usage[i].favicon_url, favicon_base::FAVICON, NULL); 1803 favicon_usage[i].favicon_url, favicon_base::FAVICON, nullptr);
1809 if (!favicon_id) { 1804 if (!favicon_id) {
1810 // This favicon doesn't exist yet, so we create it using the given data. 1805 // This favicon doesn't exist yet, so we create it using the given data.
1811 // TODO(pkotwicz): Pass in real pixel size. 1806 // TODO(pkotwicz): Pass in real pixel size.
1812 favicon_id = thumbnail_db_->AddFavicon( 1807 favicon_id = thumbnail_db_->AddFavicon(
1813 favicon_usage[i].favicon_url, 1808 favicon_usage[i].favicon_url,
1814 favicon_base::FAVICON, 1809 favicon_base::FAVICON,
1815 new base::RefCountedBytes(favicon_usage[i].png_data), 1810 new base::RefCountedBytes(favicon_usage[i].png_data),
1816 now, 1811 now,
1817 gfx::Size()); 1812 gfx::Size());
1818 } 1813 }
(...skipping 14 matching lines...) Expand all
1833 url_info.set_visit_count(0); 1828 url_info.set_visit_count(0);
1834 url_info.set_typed_count(0); 1829 url_info.set_typed_count(0);
1835 url_info.set_last_visit(base::Time()); 1830 url_info.set_last_visit(base::Time());
1836 url_info.set_hidden(false); 1831 url_info.set_hidden(false);
1837 db_->AddURL(url_info); 1832 db_->AddURL(url_info);
1838 thumbnail_db_->AddIconMapping(*url, favicon_id); 1833 thumbnail_db_->AddIconMapping(*url, favicon_id);
1839 favicons_changed.insert(*url); 1834 favicons_changed.insert(*url);
1840 } 1835 }
1841 } else { 1836 } else {
1842 if (!thumbnail_db_->GetIconMappingsForPageURL( 1837 if (!thumbnail_db_->GetIconMappingsForPageURL(
1843 *url, favicon_base::FAVICON, NULL)) { 1838 *url, favicon_base::FAVICON, nullptr)) {
1844 // URL is present in history, update the favicon *only* if it is not 1839 // URL is present in history, update the favicon *only* if it is not
1845 // set already. 1840 // set already.
1846 thumbnail_db_->AddIconMapping(*url, favicon_id); 1841 thumbnail_db_->AddIconMapping(*url, favicon_id);
1847 favicons_changed.insert(*url); 1842 favicons_changed.insert(*url);
1848 } 1843 }
1849 } 1844 }
1850 } 1845 }
1851 } 1846 }
1852 1847
1853 if (!favicons_changed.empty()) { 1848 if (!favicons_changed.empty()) {
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1975 return favicon_bitmaps_changed; 1970 return favicon_bitmaps_changed;
1976 } 1971 }
1977 1972
1978 bool HistoryBackend::IsFaviconBitmapDataEqual( 1973 bool HistoryBackend::IsFaviconBitmapDataEqual(
1979 FaviconBitmapID bitmap_id, 1974 FaviconBitmapID bitmap_id,
1980 const scoped_refptr<base::RefCountedMemory>& new_bitmap_data) { 1975 const scoped_refptr<base::RefCountedMemory>& new_bitmap_data) {
1981 if (!new_bitmap_data.get()) 1976 if (!new_bitmap_data.get())
1982 return false; 1977 return false;
1983 1978
1984 scoped_refptr<base::RefCountedMemory> original_bitmap_data; 1979 scoped_refptr<base::RefCountedMemory> original_bitmap_data;
1985 thumbnail_db_->GetFaviconBitmap(bitmap_id, 1980 thumbnail_db_->GetFaviconBitmap(bitmap_id, nullptr, &original_bitmap_data,
1986 NULL, 1981 nullptr);
1987 &original_bitmap_data,
1988 NULL);
1989 return new_bitmap_data->Equals(original_bitmap_data); 1982 return new_bitmap_data->Equals(original_bitmap_data);
1990 } 1983 }
1991 1984
1992 bool HistoryBackend::GetFaviconsFromDB( 1985 bool HistoryBackend::GetFaviconsFromDB(
1993 const GURL& page_url, 1986 const GURL& page_url,
1994 int icon_types, 1987 int icon_types,
1995 const std::vector<int>& desired_sizes, 1988 const std::vector<int>& desired_sizes,
1996 std::vector<favicon_base::FaviconRawBitmapResult>* favicon_bitmap_results) { 1989 std::vector<favicon_base::FaviconRawBitmapResult>* favicon_bitmap_results) {
1997 DCHECK(favicon_bitmap_results); 1990 DCHECK(favicon_bitmap_results);
1998 favicon_bitmap_results->clear(); 1991 favicon_bitmap_results->clear();
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
2227 scheduled_commit_ = new CommitLaterTask(this); 2220 scheduled_commit_ = new CommitLaterTask(this);
2228 base::MessageLoop::current()->PostDelayedTask( 2221 base::MessageLoop::current()->PostDelayedTask(
2229 FROM_HERE, 2222 FROM_HERE,
2230 base::Bind(&CommitLaterTask::RunCommit, scheduled_commit_.get()), 2223 base::Bind(&CommitLaterTask::RunCommit, scheduled_commit_.get()),
2231 base::TimeDelta::FromSeconds(kCommitIntervalSeconds)); 2224 base::TimeDelta::FromSeconds(kCommitIntervalSeconds));
2232 } 2225 }
2233 2226
2234 void HistoryBackend::CancelScheduledCommit() { 2227 void HistoryBackend::CancelScheduledCommit() {
2235 if (scheduled_commit_.get()) { 2228 if (scheduled_commit_.get()) {
2236 scheduled_commit_->Cancel(); 2229 scheduled_commit_->Cancel();
2237 scheduled_commit_ = NULL; 2230 scheduled_commit_ = nullptr;
2238 } 2231 }
2239 } 2232 }
2240 2233
2241 void HistoryBackend::ProcessDBTaskImpl() { 2234 void HistoryBackend::ProcessDBTaskImpl() {
2242 if (!db_) { 2235 if (!db_) {
2243 // db went away, release all the refs. 2236 // db went away, release all the refs.
2244 STLDeleteContainerPointers(queued_history_db_tasks_.begin(), 2237 STLDeleteContainerPointers(queued_history_db_tasks_.begin(),
2245 queued_history_db_tasks_.end()); 2238 queued_history_db_tasks_.end());
2246 queued_history_db_tasks_.clear(); 2239 queued_history_db_tasks_.clear();
2247 return; 2240 return;
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
2439 bool success = db_->Raze(); 2432 bool success = db_->Raze();
2440 UMA_HISTOGRAM_BOOLEAN("History.KillHistoryDatabaseResult", success); 2433 UMA_HISTOGRAM_BOOLEAN("History.KillHistoryDatabaseResult", success);
2441 2434
2442 #if defined(OS_ANDROID) 2435 #if defined(OS_ANDROID)
2443 // Release AndroidProviderBackend before other objects. 2436 // Release AndroidProviderBackend before other objects.
2444 android_provider_backend_.reset(); 2437 android_provider_backend_.reset();
2445 #endif 2438 #endif
2446 2439
2447 // The expirer keeps tabs on the active databases. Tell it about the 2440 // The expirer keeps tabs on the active databases. Tell it about the
2448 // databases which will be closed. 2441 // databases which will be closed.
2449 expirer_.SetDatabases(NULL, NULL); 2442 expirer_.SetDatabases(nullptr, nullptr);
2450 2443
2451 // Reopen a new transaction for |db_| for the sake of CloseAllDatabases(). 2444 // Reopen a new transaction for |db_| for the sake of CloseAllDatabases().
2452 db_->BeginTransaction(); 2445 db_->BeginTransaction();
2453 CloseAllDatabases(); 2446 CloseAllDatabases();
2454 } 2447 }
2455 2448
2456 void HistoryBackend::ProcessDBTask( 2449 void HistoryBackend::ProcessDBTask(
2457 scoped_ptr<HistoryDBTask> task, 2450 scoped_ptr<HistoryDBTask> task,
2458 scoped_refptr<base::SingleThreadTaskRunner> origin_loop, 2451 scoped_refptr<base::SingleThreadTaskRunner> origin_loop,
2459 const base::CancelableTaskTracker::IsCanceledCallback& is_canceled) { 2452 const base::CancelableTaskTracker::IsCanceledCallback& is_canceled) {
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
2670 info.url_id = visit.url_id; 2663 info.url_id = visit.url_id;
2671 info.time = visit.visit_time; 2664 info.time = visit.visit_time;
2672 info.transition = visit.transition; 2665 info.transition = visit.transition;
2673 // If we don't have a delegate yet during setup or shutdown, we will drop 2666 // If we don't have a delegate yet during setup or shutdown, we will drop
2674 // these notifications. 2667 // these notifications.
2675 if (delegate_) 2668 if (delegate_)
2676 delegate_->NotifyAddVisit(info); 2669 delegate_->NotifyAddVisit(info);
2677 } 2670 }
2678 2671
2679 } // namespace history 2672 } // namespace history
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698