| OLD | NEW |
| 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 // The history system runs on a background thread so that potentially slow | 5 // The history system runs on a background thread so that potentially slow |
| 6 // database operations don't delay the browser. This backend processing is | 6 // database operations don't delay the browser. This backend processing is |
| 7 // represented by HistoryBackend. The HistoryService's job is to dispatch to | 7 // represented by HistoryBackend. The HistoryService's job is to dispatch to |
| 8 // that thread. | 8 // that thread. |
| 9 // | 9 // |
| 10 // Main thread History thread | 10 // Main thread History thread |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 } | 484 } |
| 485 | 485 |
| 486 HistoryService::Handle HistoryService::GetPageThumbnail( | 486 HistoryService::Handle HistoryService::GetPageThumbnail( |
| 487 const GURL& page_url, | 487 const GURL& page_url, |
| 488 CancelableRequestConsumerBase* consumer, | 488 CancelableRequestConsumerBase* consumer, |
| 489 const ThumbnailDataCallback& callback) { | 489 const ThumbnailDataCallback& callback) { |
| 490 return Schedule(PRIORITY_NORMAL, &HistoryBackend::GetPageThumbnail, consumer, | 490 return Schedule(PRIORITY_NORMAL, &HistoryBackend::GetPageThumbnail, consumer, |
| 491 new history::GetPageThumbnailRequest(callback), page_url); | 491 new history::GetPageThumbnailRequest(callback), page_url); |
| 492 } | 492 } |
| 493 | 493 |
| 494 void HistoryService::GetFavicon(FaviconService::GetFaviconRequest* request, | 494 void HistoryService::GetFaviconClosestToSize( |
| 495 const GURL& icon_url, | 495 FaviconService::GetFaviconRequest* request, |
| 496 history::IconType icon_type) { | 496 const GURL& icon_url, |
| 497 Schedule(PRIORITY_NORMAL, &HistoryBackend::GetFavicon, NULL, request, | 497 history::IconType icon_type, |
| 498 icon_url, icon_type); | 498 const gfx::Size& pixel_size) { |
| 499 Schedule(PRIORITY_NORMAL, &HistoryBackend::GetFaviconClosestToSize, NULL, |
| 500 request, icon_url, icon_type, pixel_size); |
| 499 } | 501 } |
| 500 | 502 |
| 501 void HistoryService::UpdateFaviconMappingAndFetch( | 503 void HistoryService::GetFavicons( |
| 504 FaviconService::GetFaviconRequest* request, |
| 505 const std::vector<GURL>& icon_urls, |
| 506 history::IconType icon_type) { |
| 507 Schedule(PRIORITY_NORMAL, &HistoryBackend::GetFavicons, NULL, request, |
| 508 icon_urls, icon_type); |
| 509 } |
| 510 |
| 511 void HistoryService::GetFaviconForURLClosestToSize( |
| 502 FaviconService::GetFaviconRequest* request, | 512 FaviconService::GetFaviconRequest* request, |
| 503 const GURL& page_url, | 513 const GURL& page_url, |
| 504 const GURL& icon_url, | 514 int icon_types, |
| 505 history::IconType icon_type) { | 515 const gfx::Size& pixel_size) { |
| 506 Schedule(PRIORITY_NORMAL, &HistoryBackend::UpdateFaviconMappingAndFetch, NULL, | 516 Schedule(PRIORITY_NORMAL, &HistoryBackend::GetFaviconForURLClosestToSize, |
| 507 request, page_url, icon_url, history::FAVICON); | 517 NULL, request, page_url, icon_types, pixel_size); |
| 508 } | 518 } |
| 509 | 519 |
| 510 void HistoryService::GetFaviconForURL( | 520 void HistoryService::GetFaviconsForURL( |
| 511 FaviconService::GetFaviconRequest* request, | 521 FaviconService::GetFaviconRequest* request, |
| 512 const GURL& page_url, | 522 const GURL& page_url, |
| 513 int icon_types) { | 523 int icon_types) { |
| 514 Schedule(PRIORITY_NORMAL, &HistoryBackend::GetFaviconForURL, NULL, request, | 524 Schedule(PRIORITY_NORMAL, &HistoryBackend::GetFaviconsForURL, NULL, request, |
| 515 page_url, icon_types); | 525 page_url, icon_types); |
| 516 } | 526 } |
| 517 | 527 |
| 518 void HistoryService::GetFaviconForID(FaviconService::GetFaviconRequest* request, | 528 void HistoryService::UpdateFaviconMappingsAndFetch( |
| 519 history::FaviconID id) { | 529 FaviconService::GetFaviconRequest* request, |
| 520 Schedule(PRIORITY_NORMAL, &HistoryBackend::GetFaviconForID, NULL, request, | 530 const GURL& page_url, |
| 521 id); | 531 const std::vector<GURL>& icon_urls, |
| 532 history::IconType icon_type) { |
| 533 Schedule(PRIORITY_NORMAL, &HistoryBackend::UpdateFaviconMappingsAndFetch, |
| 534 NULL, request, page_url, icon_urls, icon_type); |
| 522 } | 535 } |
| 523 | 536 |
| 524 void HistoryService::SetFavicon(const GURL& page_url, | 537 void HistoryService::AddFavicons( |
| 525 const GURL& icon_url, | 538 const GURL& page_url, |
| 526 const std::vector<unsigned char>& image_data, | 539 history::IconType icon_type, |
| 527 history::IconType icon_type) { | 540 const std::vector<history::FaviconDataElement>& elements) { |
| 528 if (!CanAddURL(page_url)) | 541 if (!CanAddURL(page_url)) |
| 529 return; | 542 return; |
| 530 | 543 |
| 531 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::SetFavicon, | 544 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::AddFavicons, page_url, |
| 532 page_url, icon_url, | 545 icon_type, elements); |
| 533 scoped_refptr<base::RefCountedMemory>( | |
| 534 new base::RefCountedBytes(image_data)), | |
| 535 icon_type); | |
| 536 } | 546 } |
| 537 | 547 |
| 538 void HistoryService::SetFaviconOutOfDateForPage(const GURL& page_url) { | 548 void HistoryService::SetFavicons( |
| 549 const GURL& page_url, |
| 550 history::IconType icon_type, |
| 551 const std::vector<history::FaviconDataElement>& elements, |
| 552 const history::IconURLSizesMap& icon_url_sizes) { |
| 553 if (!CanAddURL(page_url)) |
| 554 return; |
| 555 |
| 556 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::SetFavicons, page_url, |
| 557 icon_type, elements, icon_url_sizes); |
| 558 } |
| 559 |
| 560 void HistoryService::SetFaviconsOutOfDateForPage(const GURL& page_url) { |
| 539 ScheduleAndForget(PRIORITY_NORMAL, | 561 ScheduleAndForget(PRIORITY_NORMAL, |
| 540 &HistoryBackend::SetFaviconOutOfDateForPage, page_url); | 562 &HistoryBackend::SetFaviconsOutOfDateForPage, page_url); |
| 541 } | 563 } |
| 542 | 564 |
| 543 void HistoryService::CloneFavicon(const GURL& old_page_url, | 565 void HistoryService::CloneFavicon(const GURL& old_page_url, |
| 544 const GURL& new_page_url) { | 566 const GURL& new_page_url) { |
| 545 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::CloneFavicon, | 567 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::CloneFavicon, |
| 546 old_page_url, new_page_url); | 568 old_page_url, new_page_url); |
| 547 } | 569 } |
| 548 | 570 |
| 549 void HistoryService::SetImportedFavicons( | 571 void HistoryService::SetImportedFavicons( |
| 550 const std::vector<history::ImportedFaviconUsage>& favicon_usage) { | 572 const std::vector<history::ImportedFaviconUsage>& favicon_usage) { |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 939 void HistoryService::RemoveVisitDatabaseObserver( | 961 void HistoryService::RemoveVisitDatabaseObserver( |
| 940 history::VisitDatabaseObserver* observer) { | 962 history::VisitDatabaseObserver* observer) { |
| 941 visit_database_observers_->RemoveObserver(observer); | 963 visit_database_observers_->RemoveObserver(observer); |
| 942 } | 964 } |
| 943 | 965 |
| 944 void HistoryService::NotifyVisitDBObserversOnAddVisit( | 966 void HistoryService::NotifyVisitDBObserversOnAddVisit( |
| 945 const history::BriefVisitInfo& info) { | 967 const history::BriefVisitInfo& info) { |
| 946 visit_database_observers_->Notify( | 968 visit_database_observers_->Notify( |
| 947 &history::VisitDatabaseObserver::OnAddVisit, info); | 969 &history::VisitDatabaseObserver::OnAddVisit, info); |
| 948 } | 970 } |
| OLD | NEW |