| 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 #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 <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 } | 33 } |
| 34 | 34 |
| 35 namespace history { | 35 namespace history { |
| 36 #if defined(OS_ANDROID) | 36 #if defined(OS_ANDROID) |
| 37 class AndroidProviderBackend; | 37 class AndroidProviderBackend; |
| 38 #endif | 38 #endif |
| 39 class CommitLaterTask; | 39 class CommitLaterTask; |
| 40 class HistoryPublisher; | 40 class HistoryPublisher; |
| 41 class VisitFilter; | 41 class VisitFilter; |
| 42 | 42 |
| 43 // The maximum number of favicon bitmaps stored for a single page. |
| 44 // Exposed for use in unittests. |
| 45 extern const size_t kMaxFaviconsPerPage; |
| 46 |
| 43 // *See the .cc file for more information on the design.* | 47 // *See the .cc file for more information on the design.* |
| 44 // | 48 // |
| 45 // Internal history implementation which does most of the work of the history | 49 // Internal history implementation which does most of the work of the history |
| 46 // system. This runs on a background thread (to not block the browser when we | 50 // system. This runs on a background thread (to not block the browser when we |
| 47 // do expensive operations) and is NOT threadsafe, so it must only be called | 51 // do expensive operations) and is NOT threadsafe, so it must only be called |
| 48 // from message handlers on the background thread. Invoking on another thread | 52 // from message handlers on the background thread. Invoking on another thread |
| 49 // requires threadsafe refcounting. | 53 // requires threadsafe refcounting. |
| 50 // | 54 // |
| 51 // Most functions here are just the implementations of the corresponding | 55 // Most functions here are just the implementations of the corresponding |
| 52 // functions in the history service. These functions are not documented | 56 // functions in the history service. These functions are not documented |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 void GetPageThumbnailDirectly( | 247 void GetPageThumbnailDirectly( |
| 244 const GURL& page_url, | 248 const GURL& page_url, |
| 245 scoped_refptr<base::RefCountedBytes>* data); | 249 scoped_refptr<base::RefCountedBytes>* data); |
| 246 | 250 |
| 247 void MigrateThumbnailsDatabase(); | 251 void MigrateThumbnailsDatabase(); |
| 248 | 252 |
| 249 // Favicon ------------------------------------------------------------------- | 253 // Favicon ------------------------------------------------------------------- |
| 250 | 254 |
| 251 void GetFavicon(scoped_refptr<GetFaviconRequest> request, | 255 void GetFavicon(scoped_refptr<GetFaviconRequest> request, |
| 252 const GURL& icon_url, | 256 const GURL& icon_url, |
| 257 const gfx::Size& pixel_size, |
| 253 int icon_types); | 258 int icon_types); |
| 254 | 259 |
| 255 void GetFaviconForURL(scoped_refptr<GetFaviconRequest> request, | 260 void GetFaviconForURL(scoped_refptr<GetFaviconRequest> request, |
| 256 const GURL& page_url, | 261 const GURL& page_url, |
| 262 const gfx::Size& pixel_size, |
| 257 int icon_types); | 263 int icon_types); |
| 258 | 264 |
| 259 void GetFaviconForID(scoped_refptr<GetFaviconRequest> request, FaviconID id); | 265 void GetFaviconForID(scoped_refptr<GetFaviconRequest> request, FaviconID id); |
| 260 | 266 |
| 261 void SetFavicon(const GURL& page_url, | 267 void SetFavicon(const GURL& page_url, |
| 262 const GURL& icon_url, | 268 const GURL& icon_url, |
| 263 scoped_refptr<base::RefCountedMemory> data, | 269 scoped_refptr<base::RefCountedMemory> data, |
| 270 const gfx::Size& pixel_size, |
| 264 IconType icon_type); | 271 IconType icon_type); |
| 265 | 272 |
| 266 void UpdateFaviconMappingAndFetch(scoped_refptr<GetFaviconRequest> request, | 273 void UpdateFaviconMappingAndFetch(scoped_refptr<GetFaviconRequest> request, |
| 267 const GURL& page_url, | 274 const GURL& page_url, |
| 268 const GURL& icon_url, | 275 const GURL& icon_url, |
| 276 const gfx::Size& pixel_size, |
| 269 IconType icon_type); | 277 IconType icon_type); |
| 270 | 278 |
| 271 void SetFaviconOutOfDateForPage(const GURL& page_url); | 279 void SetFaviconOutOfDateForPage(const GURL& page_url); |
| 272 | 280 |
| 273 void CloneFavicon(const GURL& old_page_url, const GURL& new_page_url); | 281 void CloneFavicon(const GURL& old_page_url, const GURL& new_page_url); |
| 274 | 282 |
| 275 void SetImportedFavicons( | 283 void SetImportedFavicons( |
| 276 const std::vector<ImportedFaviconUsage>& favicon_usage); | 284 const std::vector<ImportedFaviconUsage>& favicon_usage); |
| 277 | 285 |
| 278 // Downloads ----------------------------------------------------------------- | 286 // Downloads ----------------------------------------------------------------- |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, StripUsernamePasswordTest); | 465 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, StripUsernamePasswordTest); |
| 458 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteThumbnailsDatabaseTest); | 466 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteThumbnailsDatabaseTest); |
| 459 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, AddPageVisitSource); | 467 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, AddPageVisitSource); |
| 460 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, AddPageArgsSource); | 468 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, AddPageArgsSource); |
| 461 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, AddVisitsSource); | 469 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, AddVisitsSource); |
| 462 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, RemoveVisitsSource); | 470 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, RemoveVisitsSource); |
| 463 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, RemoveVisitsTransitions); | 471 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, RemoveVisitsTransitions); |
| 464 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, MigrationVisitSource); | 472 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, MigrationVisitSource); |
| 465 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, MigrationIconMapping); | 473 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, MigrationIconMapping); |
| 466 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, SetFaviconMapping); | 474 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, SetFaviconMapping); |
| 475 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, ExceedPageFaviconLimit); |
| 467 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, AddOrUpdateIconMapping); | 476 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, AddOrUpdateIconMapping); |
| 468 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetMostRecentVisits); | 477 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetMostRecentVisits); |
| 469 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconForURL); | 478 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconForURL); |
| 470 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, | 479 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, |
| 471 CloneFaviconIsRestrictedToSameDomain); | 480 CloneFaviconIsRestrictedToSameDomain); |
| 472 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, QueryFilteredURLs); | 481 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, QueryFilteredURLs); |
| 473 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, UpdateVisitDuration); | 482 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, UpdateVisitDuration); |
| 474 | 483 |
| 475 friend class ::TestingProfile; | 484 friend class ::TestingProfile; |
| 476 | 485 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 | 589 |
| 581 // Used by both UpdateFaviconMappingAndFetch and GetFavicon. | 590 // Used by both UpdateFaviconMappingAndFetch and GetFavicon. |
| 582 // If page_url is non-null and SetFavicon has previously been invoked for | 591 // If page_url is non-null and SetFavicon has previously been invoked for |
| 583 // icon_url the favicon url for page_url (and all redirects) is set to | 592 // icon_url the favicon url for page_url (and all redirects) is set to |
| 584 // icon_url. | 593 // icon_url. |
| 585 // Only a single type can be given in icon_type when page_url is specified. | 594 // Only a single type can be given in icon_type when page_url is specified. |
| 586 void UpdateFaviconMappingAndFetchImpl( | 595 void UpdateFaviconMappingAndFetchImpl( |
| 587 const GURL* page_url, | 596 const GURL* page_url, |
| 588 const GURL& icon_url, | 597 const GURL& icon_url, |
| 589 scoped_refptr<GetFaviconRequest> request, | 598 scoped_refptr<GetFaviconRequest> request, |
| 599 const gfx::Size& requested_size, |
| 590 int icon_type); | 600 int icon_type); |
| 591 | 601 |
| 602 // Returns the FaviconID from |favicon_id_size_listing| whose size most |
| 603 // closely matches |desired_pixel_size|. |
| 604 FaviconID GetFaviconID( |
| 605 const std::vector<FaviconIDAndSize>& favicon_id_size_listing, |
| 606 const gfx::Size& desired_pixel_size) const; |
| 607 |
| 592 // Sets the favicon url id for page_url to id. This will also broadcast | 608 // Sets the favicon url id for page_url to id. This will also broadcast |
| 593 // notifications as necessary. | 609 // notifications as necessary. |
| 594 void SetFaviconMapping(const GURL& page_url, | 610 void SetFaviconMapping(const GURL& page_url, |
| 595 FaviconID id, | 611 FaviconID id, |
| 612 const gfx::Size& pixel_size, |
| 596 IconType icon_type); | 613 IconType icon_type); |
| 597 | 614 |
| 598 // Updates the FaviconID associated with the url of a page. If there is an | 615 // Updates the FaviconID associated with the url of a page. If there is an |
| 599 // existing mapping between |page_url| and |id| this does nothing and returns | 616 // existing mapping between |page_url| and |id| this does nothing and returns |
| 600 // false. If the mapping needs to be added or updated, true is returned. If | 617 // false. If the mapping needs to be added or updated, true is returned. If |
| 601 // there is an existing mapping but it does not map to |id|, then the |id| of | 618 // there is an existing mapping but it does not map to |id|, then the |id| of |
| 602 // the replaced FaviconID is set in |replaced_icon_id|. | 619 // the replaced FaviconID is set in |replaced_icon_id|. |
| 603 bool AddOrUpdateIconMapping(const GURL& page_url, | 620 bool AddOrUpdateIconMapping(const GURL& page_url, |
| 604 FaviconID id, | 621 FaviconID id, |
| 622 const gfx::Size& pixel_size, |
| 605 IconType icon_type, | 623 IconType icon_type, |
| 606 FaviconID* replaced_icon_id); | 624 FaviconID* replaced_icon_id); |
| 607 | 625 |
| 608 // Generic stuff ------------------------------------------------------------- | 626 // Generic stuff ------------------------------------------------------------- |
| 609 | 627 |
| 610 // Processes the next scheduled HistoryDBTask, scheduling this method | 628 // Processes the next scheduled HistoryDBTask, scheduling this method |
| 611 // to be invoked again if there are more tasks that need to run. | 629 // to be invoked again if there are more tasks that need to run. |
| 612 void ProcessDBTaskImpl(); | 630 void ProcessDBTaskImpl(); |
| 613 | 631 |
| 614 // Release all tasks in history_db_tasks_ and clears it. | 632 // Release all tasks in history_db_tasks_ and clears it. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 643 // The IDs of the URLs may change. | 661 // The IDs of the URLs may change. |
| 644 bool ClearAllMainHistory(const URLRows& kept_urls); | 662 bool ClearAllMainHistory(const URLRows& kept_urls); |
| 645 | 663 |
| 646 // Returns the BookmarkService, blocking until it is loaded. This may return | 664 // Returns the BookmarkService, blocking until it is loaded. This may return |
| 647 // NULL during testing. | 665 // NULL during testing. |
| 648 BookmarkService* GetBookmarkService(); | 666 BookmarkService* GetBookmarkService(); |
| 649 | 667 |
| 650 // If there is a favicon for |page_url| and one of the types in |icon_types|, | 668 // If there is a favicon for |page_url| and one of the types in |icon_types|, |
| 651 // |favicon| is set appropriately and true is returned. | 669 // |favicon| is set appropriately and true is returned. |
| 652 bool GetFaviconFromDB(const GURL& page_url, | 670 bool GetFaviconFromDB(const GURL& page_url, |
| 671 const gfx::Size& pixel_size, |
| 653 int icon_types, | 672 int icon_types, |
| 654 FaviconData* favicon); | 673 FaviconData* favicon); |
| 655 | 674 |
| 656 // Get favicon by the given |favicon_id|, the |favicon| is set appropriately | 675 // Get favicon by the given |favicon_id|. The |favicon| is set appropriately. |
| 657 // and true if returned on success, otherwise false is returned. | 676 // Returns true on success. |
| 658 bool GetFaviconFromDB(FaviconID favicon_id, FaviconData* favicon); | 677 bool GetFaviconFromDB(FaviconID favicon_id, FaviconData* favicon); |
| 659 | 678 |
| 660 // Notify any observers of an addition to the visit database. | 679 // Notify any observers of an addition to the visit database. |
| 661 void NotifyVisitObservers(const VisitRow& visit); | 680 void NotifyVisitObservers(const VisitRow& visit); |
| 662 | 681 |
| 663 // Data ---------------------------------------------------------------------- | 682 // Data ---------------------------------------------------------------------- |
| 664 | 683 |
| 665 // Delegate. See the class definition above for more information. This will | 684 // Delegate. See the class definition above for more information. This will |
| 666 // be NULL before Init is called and after Cleanup, but is guaranteed | 685 // be NULL before Init is called and after Cleanup, but is guaranteed |
| 667 // non-NULL in between. | 686 // non-NULL in between. |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 // Used to provide the Android ContentProvider APIs. | 774 // Used to provide the Android ContentProvider APIs. |
| 756 scoped_ptr<AndroidProviderBackend> android_provider_backend_; | 775 scoped_ptr<AndroidProviderBackend> android_provider_backend_; |
| 757 #endif | 776 #endif |
| 758 | 777 |
| 759 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); | 778 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); |
| 760 }; | 779 }; |
| 761 | 780 |
| 762 } // namespace history | 781 } // namespace history |
| 763 | 782 |
| 764 #endif // CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ | 783 #endif // CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ |
| OLD | NEW |