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

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

Issue 531493002: Move encoding SkBitmaps to PNG out of FaviconService::SetFavicons() and onto the history thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
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 #ifndef CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ 5 #ifndef CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_
6 #define CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ 6 #define CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 15 matching lines...) Expand all
26 #include "components/visitedlink/browser/visitedlink_delegate.h" 26 #include "components/visitedlink/browser/visitedlink_delegate.h"
27 #include "sql/init_status.h" 27 #include "sql/init_status.h"
28 28
29 #if defined(OS_ANDROID) 29 #if defined(OS_ANDROID)
30 #include "chrome/browser/history/android/android_history_types.h" 30 #include "chrome/browser/history/android/android_history_types.h"
31 #endif 31 #endif
32 32
33 class HistoryURLProvider; 33 class HistoryURLProvider;
34 struct HistoryURLProviderParams; 34 struct HistoryURLProviderParams;
35 struct ImportedFaviconUsage; 35 struct ImportedFaviconUsage;
36 class SkBitmap;
36 class TestingProfile; 37 class TestingProfile;
37 struct ThumbnailScore; 38 struct ThumbnailScore;
38 39
39 namespace base { 40 namespace base {
40 class MessageLoop; 41 class MessageLoop;
41 class SingleThreadTaskRunner; 42 class SingleThreadTaskRunner;
42 } 43 }
43 44
44 namespace history { 45 namespace history {
45 #if defined(OS_ANDROID) 46 #if defined(OS_ANDROID)
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 int icon_types, 258 int icon_types,
258 const std::vector<int>& desired_sizes, 259 const std::vector<int>& desired_sizes,
259 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results); 260 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results);
260 261
261 void MergeFavicon(const GURL& page_url, 262 void MergeFavicon(const GURL& page_url,
262 const GURL& icon_url, 263 const GURL& icon_url,
263 favicon_base::IconType icon_type, 264 favicon_base::IconType icon_type,
264 scoped_refptr<base::RefCountedMemory> bitmap_data, 265 scoped_refptr<base::RefCountedMemory> bitmap_data,
265 const gfx::Size& pixel_size); 266 const gfx::Size& pixel_size);
266 267
267 void SetFavicons(const GURL& page_url, 268 void SetFavicon(const GURL& page_url,
268 favicon_base::IconType icon_type, 269 favicon_base::IconType icon_type,
269 const std::vector<favicon_base::FaviconRawBitmapData>& 270 const GURL& icon_url,
270 favicon_bitmap_data); 271 const std::vector<SkBitmap>& bitmaps);
271 272
272 void SetFaviconsOutOfDateForPage(const GURL& page_url); 273 void SetFaviconsOutOfDateForPage(const GURL& page_url);
273 274
274 void CloneFavicons(const GURL& old_page_url, const GURL& new_page_url); 275 void CloneFavicons(const GURL& old_page_url, const GURL& new_page_url);
275 276
276 void SetImportedFavicons( 277 void SetImportedFavicons(
277 const std::vector<ImportedFaviconUsage>& favicon_usage); 278 const std::vector<ImportedFaviconUsage>& favicon_usage);
278 279
279 // Downloads ----------------------------------------------------------------- 280 // Downloads -----------------------------------------------------------------
280 281
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, AddPageArgsSource); 520 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, AddPageArgsSource);
520 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, AddVisitsSource); 521 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, AddVisitsSource);
521 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetMostRecentVisits); 522 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetMostRecentVisits);
522 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, RemoveVisitsSource); 523 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, RemoveVisitsSource);
523 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, RemoveVisitsTransitions); 524 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, RemoveVisitsTransitions);
524 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, MigrationVisitSource); 525 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, MigrationVisitSource);
525 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, 526 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest,
526 SetFaviconMappingsForPageAndRedirects); 527 SetFaviconMappingsForPageAndRedirects);
527 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, 528 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest,
528 SetFaviconMappingsForPageDuplicates); 529 SetFaviconMappingsForPageDuplicates);
529 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, SetFaviconsDeleteBitmaps); 530 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, SetFaviconDeleteBitmaps);
530 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, SetFaviconsReplaceBitmapData); 531 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, SetFaviconReplaceBitmapData);
531 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, 532 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest,
532 SetFaviconsSameFaviconURLForTwoPages); 533 SetFaviconSameFaviconURLForTwoPages);
533 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, 534 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest,
534 UpdateFaviconMappingsAndFetchNoChange); 535 UpdateFaviconMappingsAndFetchNoChange);
535 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, MergeFaviconPageURLNotInDB); 536 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, MergeFaviconPageURLNotInDB);
536 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, MergeFaviconPageURLInDB); 537 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, MergeFaviconPageURLInDB);
537 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, MergeFaviconMaxFaviconsPerPage); 538 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, MergeFaviconMaxFaviconsPerPage);
538 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, 539 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest,
539 MergeFaviconIconURLMappedToDifferentPageURL); 540 MergeFaviconIconURLMappedToDifferentPageURL);
540 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, 541 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest,
541 MergeFaviconMaxFaviconBitmapsPerIconURL); 542 MergeFaviconMaxFaviconBitmapsPerIconURL);
542 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, 543 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest,
543 UpdateFaviconMappingsAndFetchMultipleIconTypes); 544 UpdateFaviconMappingsAndFetchMultipleIconTypes);
544 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDBEmpty); 545 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDBEmpty);
545 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, 546 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest,
546 GetFaviconsFromDBNoFaviconBitmaps); 547 GetFaviconsFromDBNoFaviconBitmaps);
547 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, 548 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest,
548 GetFaviconsFromDBSelectClosestMatch); 549 GetFaviconsFromDBSelectClosestMatch);
549 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDBSingleIconURL);
550 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDBIconType); 550 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDBIconType);
551 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDBExpired); 551 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDBExpired);
552 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, 552 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest,
553 UpdateFaviconMappingsAndFetchNoDB); 553 UpdateFaviconMappingsAndFetchNoDB);
554 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, 554 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest,
555 CloneFaviconIsRestrictedToSameDomain); 555 CloneFaviconIsRestrictedToSameDomain);
556 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, QueryFilteredURLs); 556 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, QueryFilteredURLs);
557 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, UpdateVisitDuration); 557 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, UpdateVisitDuration);
558 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, ExpireHistoryForTimes); 558 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, ExpireHistoryForTimes);
559 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteFTSIndexDatabases); 559 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteFTSIndexDatabases);
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 // If multiple icon types are specified, |page_url| will be mapped to the 682 // If multiple icon types are specified, |page_url| will be mapped to the
683 // icon URLs of the largest type available in the database. 683 // icon URLs of the largest type available in the database.
684 void UpdateFaviconMappingsAndFetchImpl( 684 void UpdateFaviconMappingsAndFetchImpl(
685 const GURL* page_url, 685 const GURL* page_url,
686 const std::vector<GURL>& icon_urls, 686 const std::vector<GURL>& icon_urls,
687 int icon_types, 687 int icon_types,
688 const std::vector<int>& desired_sizes, 688 const std::vector<int>& desired_sizes,
689 std::vector<favicon_base::FaviconRawBitmapResult>* results); 689 std::vector<favicon_base::FaviconRawBitmapResult>* results);
690 690
691 // Set the favicon bitmaps for |icon_id|. 691 // Set the favicon bitmaps for |icon_id|.
692 // For each entry in |favicon_bitmap_data|, if a favicon bitmap already 692 // For each entry in |bitmaps|, if a favicon bitmap already exists at the
693 // exists at the entry's pixel size, replace the favicon bitmap's data with 693 // entry's pixel size, replace the favicon bitmap's data with the entry's
694 // the entry's bitmap data. Otherwise add a new favicon bitmap. 694 // bitmap data. Otherwise add a new favicon bitmap.
695 // Any favicon bitmaps already mapped to |icon_id| whose pixel sizes are not 695 // Any favicon bitmaps already mapped to |icon_id| whose pixel size does not
696 // in |favicon_bitmap_data| are deleted. 696 // match the pixel size of one of |bitmaps| is deleted.
697 // If not NULL, |favicon_bitmaps_changed| is set to whether any of the bitmap 697 // If not NULL, |favicon_bitmaps_changed| is set to whether any of the bitmap
698 // data at |icon_id| is changed as a result of calling this method. 698 // data at |icon_id| is changed as a result of calling this method.
699 // Computing |favicon_bitmaps_changed| requires additional database queries 699 // Computing |favicon_bitmaps_changed| requires additional database queries
700 // so should be avoided if unnecessary. 700 // so should be avoided if unnecessary.
701 void SetFaviconBitmaps(favicon_base::FaviconID icon_id, 701 void SetFaviconBitmaps(favicon_base::FaviconID icon_id,
702 const std::vector<favicon_base::FaviconRawBitmapData>& 702 const std::vector<SkBitmap>& bitmaps,
703 favicon_bitmap_data,
704 bool* favicon_bitmaps_changed); 703 bool* favicon_bitmaps_changed);
705 704
706 // Returns true if |favicon_bitmap_data| passed to SetFavicons() is valid.
707 // Criteria:
708 // 1) |favicon_bitmap_data| contains no more than
709 // kMaxFaviconsPerPage unique icon URLs.
710 // kMaxFaviconBitmapsPerIconURL favicon bitmaps for each icon URL.
711 // 2) FaviconRawBitmapData::bitmap_data contains non NULL bitmap data.
712 bool ValidateSetFaviconsParams(const std::vector<
713 favicon_base::FaviconRawBitmapData>& favicon_bitmap_data) const;
714
715 // Returns true if the bitmap data at |bitmap_id| equals |new_bitmap_data|. 705 // Returns true if the bitmap data at |bitmap_id| equals |new_bitmap_data|.
716 bool IsFaviconBitmapDataEqual( 706 bool IsFaviconBitmapDataEqual(
717 FaviconBitmapID bitmap_id, 707 FaviconBitmapID bitmap_id,
718 const scoped_refptr<base::RefCountedMemory>& new_bitmap_data); 708 const scoped_refptr<base::RefCountedMemory>& new_bitmap_data);
719 709
720 // Returns true if there are favicons for |page_url| and one of the types in 710 // Returns true if there are favicons for |page_url| and one of the types in
721 // |icon_types|. 711 // |icon_types|.
722 // |favicon_bitmap_results| is set to the favicon bitmaps whose edge sizes 712 // |favicon_bitmap_results| is set to the favicon bitmaps whose edge sizes
723 // most closely match |desired_sizes|. If |desired_sizes| has a '0' entry, the 713 // most closely match |desired_sizes|. If |desired_sizes| has a '0' entry, the
724 // largest favicon bitmap with one of the icon types in |icon_types| is 714 // largest favicon bitmap with one of the icon types in |icon_types| is
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 891
902 // Listens for the system being under memory pressure. 892 // Listens for the system being under memory pressure.
903 scoped_ptr<base::MemoryPressureListener> memory_pressure_listener_; 893 scoped_ptr<base::MemoryPressureListener> memory_pressure_listener_;
904 894
905 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); 895 DISALLOW_COPY_AND_ASSIGN(HistoryBackend);
906 }; 896 };
907 897
908 } // namespace history 898 } // namespace history
909 899
910 #endif // CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ 900 #endif // CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698