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

Side by Side Diff: components/history/core/browser/history_service.cc

Issue 2313563002: Reduce jank from favicon downscaling. (Closed)
Patch Set: Add description comment in header Created 4 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
« no previous file with comments | « components/history/core/browser/history_backend.cc ('k') | 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 // 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 using base::Time; 58 using base::Time;
59 59
60 namespace history { 60 namespace history {
61 namespace { 61 namespace {
62 62
63 static const char* kHistoryThreadName = "Chrome_HistoryThread"; 63 static const char* kHistoryThreadName = "Chrome_HistoryThread";
64 64
65 void RunWithFaviconResults( 65 void RunWithFaviconResults(
66 const favicon_base::FaviconResultsCallback& callback, 66 const favicon_base::FaviconResultsCallback& callback,
67 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results) { 67 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results) {
68 TRACE_EVENT0("browser", "RunWithFaviconResults");
68 callback.Run(*bitmap_results); 69 callback.Run(*bitmap_results);
69 } 70 }
70 71
71 void RunWithFaviconResult( 72 void RunWithFaviconResult(
72 const favicon_base::FaviconRawBitmapCallback& callback, 73 const favicon_base::FaviconRawBitmapCallback& callback,
73 favicon_base::FaviconRawBitmapResult* bitmap_result) { 74 favicon_base::FaviconRawBitmapResult* bitmap_result) {
74 callback.Run(*bitmap_result); 75 callback.Run(*bitmap_result);
75 } 76 }
76 77
77 void RunWithQueryURLResult(const HistoryService::QueryURLCallback& callback, 78 void RunWithQueryURLResult(const HistoryService::QueryURLCallback& callback,
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 base::Bind(&HistoryBackend::AddPagesWithDetails, 501 base::Bind(&HistoryBackend::AddPagesWithDetails,
501 history_backend_, info, visit_source)); 502 history_backend_, info, visit_source));
502 } 503 }
503 504
504 base::CancelableTaskTracker::TaskId HistoryService::GetFavicons( 505 base::CancelableTaskTracker::TaskId HistoryService::GetFavicons(
505 const std::vector<GURL>& icon_urls, 506 const std::vector<GURL>& icon_urls,
506 int icon_types, 507 int icon_types,
507 const std::vector<int>& desired_sizes, 508 const std::vector<int>& desired_sizes,
508 const favicon_base::FaviconResultsCallback& callback, 509 const favicon_base::FaviconResultsCallback& callback,
509 base::CancelableTaskTracker* tracker) { 510 base::CancelableTaskTracker* tracker) {
511 TRACE_EVENT0("browser", "HistoryService::GetFavicons");
510 DCHECK(thread_) << "History service being called after cleanup"; 512 DCHECK(thread_) << "History service being called after cleanup";
511 DCHECK(thread_checker_.CalledOnValidThread()); 513 DCHECK(thread_checker_.CalledOnValidThread());
512 std::vector<favicon_base::FaviconRawBitmapResult>* results = 514 std::vector<favicon_base::FaviconRawBitmapResult>* results =
513 new std::vector<favicon_base::FaviconRawBitmapResult>(); 515 new std::vector<favicon_base::FaviconRawBitmapResult>();
514 return tracker->PostTaskAndReply( 516 return tracker->PostTaskAndReply(
515 thread_->task_runner().get(), FROM_HERE, 517 thread_->task_runner().get(), FROM_HERE,
516 base::Bind(&HistoryBackend::GetFavicons, history_backend_, 518 base::Bind(&HistoryBackend::GetFavicons, history_backend_,
517 icon_urls, icon_types, desired_sizes, results), 519 icon_urls, icon_types, desired_sizes, results),
518 base::Bind(&RunWithFaviconResults, callback, base::Owned(results))); 520 base::Bind(&RunWithFaviconResults, callback, base::Owned(results)));
519 } 521 }
520 522
521 base::CancelableTaskTracker::TaskId HistoryService::GetFaviconsForURL( 523 base::CancelableTaskTracker::TaskId HistoryService::GetFaviconsForURL(
522 const GURL& page_url, 524 const GURL& page_url,
523 int icon_types, 525 int icon_types,
524 const std::vector<int>& desired_sizes, 526 const std::vector<int>& desired_sizes,
525 const favicon_base::FaviconResultsCallback& callback, 527 const favicon_base::FaviconResultsCallback& callback,
526 base::CancelableTaskTracker* tracker) { 528 base::CancelableTaskTracker* tracker) {
529 TRACE_EVENT0("browser", "HistoryService::GetFaviconsForURL");
527 DCHECK(thread_) << "History service being called after cleanup"; 530 DCHECK(thread_) << "History service being called after cleanup";
528 DCHECK(thread_checker_.CalledOnValidThread()); 531 DCHECK(thread_checker_.CalledOnValidThread());
529 std::vector<favicon_base::FaviconRawBitmapResult>* results = 532 std::vector<favicon_base::FaviconRawBitmapResult>* results =
530 new std::vector<favicon_base::FaviconRawBitmapResult>(); 533 new std::vector<favicon_base::FaviconRawBitmapResult>();
531 return tracker->PostTaskAndReply( 534 return tracker->PostTaskAndReply(
532 thread_->task_runner().get(), FROM_HERE, 535 thread_->task_runner().get(), FROM_HERE,
533 base::Bind(&HistoryBackend::GetFaviconsForURL, history_backend_, 536 base::Bind(&HistoryBackend::GetFaviconsForURL, history_backend_,
534 page_url, icon_types, desired_sizes, results), 537 page_url, icon_types, desired_sizes, results),
535 base::Bind(&RunWithFaviconResults, callback, base::Owned(results))); 538 base::Bind(&RunWithFaviconResults, callback, base::Owned(results)));
536 } 539 }
(...skipping 14 matching lines...) Expand all
551 history_backend_, page_url, icon_types, 554 history_backend_, page_url, icon_types,
552 minimum_size_in_pixels, result), 555 minimum_size_in_pixels, result),
553 base::Bind(&RunWithFaviconResult, callback, base::Owned(result))); 556 base::Bind(&RunWithFaviconResult, callback, base::Owned(result)));
554 } 557 }
555 558
556 base::CancelableTaskTracker::TaskId HistoryService::GetFaviconForID( 559 base::CancelableTaskTracker::TaskId HistoryService::GetFaviconForID(
557 favicon_base::FaviconID favicon_id, 560 favicon_base::FaviconID favicon_id,
558 int desired_size, 561 int desired_size,
559 const favicon_base::FaviconResultsCallback& callback, 562 const favicon_base::FaviconResultsCallback& callback,
560 base::CancelableTaskTracker* tracker) { 563 base::CancelableTaskTracker* tracker) {
564 TRACE_EVENT0("browser", "HistoryService::GetFaviconForID");
561 DCHECK(thread_) << "History service being called after cleanup"; 565 DCHECK(thread_) << "History service being called after cleanup";
562 DCHECK(thread_checker_.CalledOnValidThread()); 566 DCHECK(thread_checker_.CalledOnValidThread());
563 std::vector<favicon_base::FaviconRawBitmapResult>* results = 567 std::vector<favicon_base::FaviconRawBitmapResult>* results =
564 new std::vector<favicon_base::FaviconRawBitmapResult>(); 568 new std::vector<favicon_base::FaviconRawBitmapResult>();
565 return tracker->PostTaskAndReply( 569 return tracker->PostTaskAndReply(
566 thread_->task_runner().get(), FROM_HERE, 570 thread_->task_runner().get(), FROM_HERE,
567 base::Bind(&HistoryBackend::GetFaviconForID, history_backend_, 571 base::Bind(&HistoryBackend::GetFaviconForID, history_backend_,
568 favicon_id, desired_size, results), 572 favicon_id, desired_size, results),
569 base::Bind(&RunWithFaviconResults, callback, base::Owned(results))); 573 base::Bind(&RunWithFaviconResults, callback, base::Owned(results)));
570 } 574 }
571 575
572 base::CancelableTaskTracker::TaskId 576 base::CancelableTaskTracker::TaskId
573 HistoryService::UpdateFaviconMappingsAndFetch( 577 HistoryService::UpdateFaviconMappingsAndFetch(
574 const GURL& page_url, 578 const GURL& page_url,
575 const std::vector<GURL>& icon_urls, 579 const std::vector<GURL>& icon_urls,
576 int icon_types, 580 int icon_types,
577 const std::vector<int>& desired_sizes, 581 const std::vector<int>& desired_sizes,
578 const favicon_base::FaviconResultsCallback& callback, 582 const favicon_base::FaviconResultsCallback& callback,
579 base::CancelableTaskTracker* tracker) { 583 base::CancelableTaskTracker* tracker) {
584 TRACE_EVENT0("browser", "HistoryService::UpdateFaviconMappingsAndFetch");
580 DCHECK(thread_) << "History service being called after cleanup"; 585 DCHECK(thread_) << "History service being called after cleanup";
581 DCHECK(thread_checker_.CalledOnValidThread()); 586 DCHECK(thread_checker_.CalledOnValidThread());
582 std::vector<favicon_base::FaviconRawBitmapResult>* results = 587 std::vector<favicon_base::FaviconRawBitmapResult>* results =
583 new std::vector<favicon_base::FaviconRawBitmapResult>(); 588 new std::vector<favicon_base::FaviconRawBitmapResult>();
584 return tracker->PostTaskAndReply( 589 return tracker->PostTaskAndReply(
585 thread_->task_runner().get(), FROM_HERE, 590 thread_->task_runner().get(), FROM_HERE,
586 base::Bind(&HistoryBackend::UpdateFaviconMappingsAndFetch, 591 base::Bind(&HistoryBackend::UpdateFaviconMappingsAndFetch,
587 history_backend_, page_url, icon_urls, icon_types, 592 history_backend_, page_url, icon_urls, icon_types,
588 desired_sizes, results), 593 desired_sizes, results),
589 base::Bind(&RunWithFaviconResults, callback, base::Owned(results))); 594 base::Bind(&RunWithFaviconResults, callback, base::Owned(results)));
590 } 595 }
591 596
592 void HistoryService::MergeFavicon( 597 void HistoryService::MergeFavicon(
593 const GURL& page_url, 598 const GURL& page_url,
594 const GURL& icon_url, 599 const GURL& icon_url,
595 favicon_base::IconType icon_type, 600 favicon_base::IconType icon_type,
596 scoped_refptr<base::RefCountedMemory> bitmap_data, 601 scoped_refptr<base::RefCountedMemory> bitmap_data,
597 const gfx::Size& pixel_size) { 602 const gfx::Size& pixel_size) {
603 TRACE_EVENT0("browser", "HistoryService::MergeFavicon");
598 DCHECK(thread_) << "History service being called after cleanup"; 604 DCHECK(thread_) << "History service being called after cleanup";
599 DCHECK(thread_checker_.CalledOnValidThread()); 605 DCHECK(thread_checker_.CalledOnValidThread());
600 if (history_client_ && !history_client_->CanAddURL(page_url)) 606 if (history_client_ && !history_client_->CanAddURL(page_url))
601 return; 607 return;
602 608
603 ScheduleTask( 609 ScheduleTask(
604 PRIORITY_NORMAL, 610 PRIORITY_NORMAL,
605 base::Bind(&HistoryBackend::MergeFavicon, history_backend_, 611 base::Bind(&HistoryBackend::MergeFavicon, history_backend_,
606 page_url, icon_url, icon_type, bitmap_data, pixel_size)); 612 page_url, icon_url, icon_type, bitmap_data, pixel_size));
607 } 613 }
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
1134 return favicon_changed_callback_list_.Add(callback); 1140 return favicon_changed_callback_list_.Add(callback);
1135 } 1141 }
1136 1142
1137 void HistoryService::NotifyFaviconsChanged(const std::set<GURL>& page_urls, 1143 void HistoryService::NotifyFaviconsChanged(const std::set<GURL>& page_urls,
1138 const GURL& icon_url) { 1144 const GURL& icon_url) {
1139 DCHECK(thread_checker_.CalledOnValidThread()); 1145 DCHECK(thread_checker_.CalledOnValidThread());
1140 favicon_changed_callback_list_.Notify(page_urls, icon_url); 1146 favicon_changed_callback_list_.Notify(page_urls, icon_url);
1141 } 1147 }
1142 1148
1143 } // namespace history 1149 } // namespace history
OLDNEW
« no previous file with comments | « components/history/core/browser/history_backend.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698