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_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_HISTORY_HISTORY_SERVICE_H_ |
6 #define CHROME_BROWSER_HISTORY_HISTORY_SERVICE_H_ | 6 #define CHROME_BROWSER_HISTORY_HISTORY_SERVICE_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
46 class PageUsageRequest; | 46 class PageUsageRequest; |
47 class Profile; | 47 class Profile; |
48 struct ImportedFaviconUsage; | 48 struct ImportedFaviconUsage; |
49 class SkBitmap; | 49 class SkBitmap; |
50 | 50 |
51 namespace base { | 51 namespace base { |
52 class FilePath; | 52 class FilePath; |
53 class Thread; | 53 class Thread; |
54 } | 54 } |
55 | 55 |
56 namespace extensions { | |
57 class HistoryEventRouter; | |
58 } | |
59 | |
56 namespace safe_browsing { | 60 namespace safe_browsing { |
57 class LastDownloadFinder; | 61 class LastDownloadFinder; |
58 } | 62 } |
59 | 63 |
60 namespace visitedlink { | 64 namespace visitedlink { |
61 class VisitedLinkMaster; | 65 class VisitedLinkMaster; |
62 } | 66 } |
63 | 67 |
64 namespace history { | 68 namespace history { |
65 | 69 |
(...skipping 14 matching lines...) Expand all Loading... | |
80 struct HistoryDetails; | 84 struct HistoryDetails; |
81 struct KeywordSearchTermVisit; | 85 struct KeywordSearchTermVisit; |
82 | 86 |
83 } // namespace history | 87 } // namespace history |
84 | 88 |
85 // The history service records page titles, and visit times, as well as | 89 // The history service records page titles, and visit times, as well as |
86 // (eventually) information about autocomplete. | 90 // (eventually) information about autocomplete. |
87 // | 91 // |
88 // This service is thread safe. Each request callback is invoked in the | 92 // This service is thread safe. Each request callback is invoked in the |
89 // thread that made the request. | 93 // thread that made the request. |
90 class HistoryService : public content::NotificationObserver, | 94 class HistoryService : public syncer::SyncableService, |
91 public syncer::SyncableService, | |
92 public KeyedService, | 95 public KeyedService, |
93 public visitedlink::VisitedLinkDelegate { | 96 public visitedlink::VisitedLinkDelegate { |
94 public: | 97 public: |
95 // Miscellaneous commonly-used types. | 98 // Miscellaneous commonly-used types. |
96 typedef std::vector<PageUsageData*> PageUsageDataList; | 99 typedef std::vector<PageUsageData*> PageUsageDataList; |
97 | 100 |
98 // Must call Init after construction. The |history::HistoryClient| object | 101 // Must call Init after construction. The |history::HistoryClient| object |
99 // must be valid for the whole lifetime of |HistoryService|. | 102 // must be valid for the whole lifetime of |HistoryService|. |
100 explicit HistoryService(history::HistoryClient* client, Profile* profile); | 103 explicit HistoryService(history::HistoryClient* client, Profile* profile); |
101 // The empty constructor is provided only for testing. | 104 // The empty constructor is provided only for testing. |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
526 PRIORITY_LOW, // Low priority things like indexing or expiration. | 529 PRIORITY_LOW, // Low priority things like indexing or expiration. |
527 }; | 530 }; |
528 | 531 |
529 private: | 532 private: |
530 class BackendDelegate; | 533 class BackendDelegate; |
531 #if defined(OS_ANDROID) | 534 #if defined(OS_ANDROID) |
532 friend class AndroidHistoryProviderService; | 535 friend class AndroidHistoryProviderService; |
533 #endif | 536 #endif |
534 friend class base::RefCountedThreadSafe<HistoryService>; | 537 friend class base::RefCountedThreadSafe<HistoryService>; |
535 friend class BackendDelegate; | 538 friend class BackendDelegate; |
539 friend class extensions::HistoryEventRouter; | |
sdefresne
2014/12/04 17:21:13
Please remove, we do not want a dependency (even i
nshaik
2014/12/07 09:34:50
Done.
| |
536 friend class FaviconService; | 540 friend class FaviconService; |
537 friend class history::HistoryBackend; | 541 friend class history::HistoryBackend; |
538 friend class history::HistoryQueryTest; | 542 friend class history::HistoryQueryTest; |
539 friend class HistoryOperation; | 543 friend class HistoryOperation; |
540 friend class HistoryQuickProviderTest; | 544 friend class HistoryQuickProviderTest; |
541 friend class history::HistoryTest; | 545 friend class history::HistoryTest; |
542 friend class HistoryURLProvider; | 546 friend class HistoryURLProvider; |
543 friend class HistoryURLProviderTest; | 547 friend class HistoryURLProviderTest; |
544 friend class history::InMemoryURLIndexTest; | 548 friend class history::InMemoryURLIndexTest; |
545 template<typename Info, typename Callback> friend class DownloadRequest; | 549 template<typename Info, typename Callback> friend class DownloadRequest; |
546 friend class safe_browsing::LastDownloadFinder; | 550 friend class safe_browsing::LastDownloadFinder; |
547 friend class PageUsageRequest; | 551 friend class PageUsageRequest; |
548 friend class RedirectRequest; | 552 friend class RedirectRequest; |
549 friend class SyncBookmarkDataTypeControllerTest; | 553 friend class SyncBookmarkDataTypeControllerTest; |
550 friend class TestingProfile; | 554 friend class TestingProfile; |
551 | 555 |
552 // Called on shutdown, this will tell the history backend to complete and | 556 // Called on shutdown, this will tell the history backend to complete and |
553 // will release pointers to it. No other functions should be called once | 557 // will release pointers to it. No other functions should be called once |
554 // cleanup has happened that may dispatch to the history thread (because it | 558 // cleanup has happened that may dispatch to the history thread (because it |
555 // will be NULL). | 559 // will be NULL). |
556 // | 560 // |
557 // In practice, this will be called by the service manager (BrowserProcess) | 561 // In practice, this will be called by the service manager (BrowserProcess) |
558 // when it is being destroyed. Because that reference is being destroyed, it | 562 // when it is being destroyed. Because that reference is being destroyed, it |
559 // should be impossible for anybody else to call the service, even if it is | 563 // should be impossible for anybody else to call the service, even if it is |
560 // still in memory (pending requests may be holding a reference to us). | 564 // still in memory (pending requests may be holding a reference to us). |
561 void Cleanup(); | 565 void Cleanup(); |
562 | 566 |
563 // Implementation of content::NotificationObserver. | |
564 void Observe(int type, | |
565 const content::NotificationSource& source, | |
566 const content::NotificationDetails& details) override; | |
567 | |
568 // Implementation of visitedlink::VisitedLinkDelegate. | 567 // Implementation of visitedlink::VisitedLinkDelegate. |
569 void RebuildTable(const scoped_refptr<URLEnumerator>& enumerator) override; | 568 void RebuildTable(const scoped_refptr<URLEnumerator>& enumerator) override; |
570 | 569 |
571 // Low-level Init(). Same as the public version, but adds a |no_db| parameter | 570 // Low-level Init(). Same as the public version, but adds a |no_db| parameter |
572 // that is only set by unittests which causes the backend to not init its DB. | 571 // that is only set by unittests which causes the backend to not init its DB. |
573 bool Init(const base::FilePath& history_dir, bool no_db); | 572 bool Init(const base::FilePath& history_dir, bool no_db); |
574 | 573 |
575 // Called by the HistoryURLProvider class to schedule an autocomplete, it | 574 // Called by the HistoryURLProvider class to schedule an autocomplete, it |
576 // will be called back on the internal history thread with the history | 575 // will be called back on the internal history thread with the history |
577 // database so it can query. See history_autocomplete.cc for a diagram. | 576 // database so it can query. See history_autocomplete.cc for a diagram. |
(...skipping 28 matching lines...) Expand all Loading... | |
606 // |redirects| is an empty vector. | 605 // |redirects| is an empty vector. |
607 void NotifyURLVisited(ui::PageTransition transition, | 606 void NotifyURLVisited(ui::PageTransition transition, |
608 const history::URLRow& row, | 607 const history::URLRow& row, |
609 const history::RedirectList& redirects, | 608 const history::RedirectList& redirects, |
610 base::Time visit_time); | 609 base::Time visit_time); |
611 | 610 |
612 // Notify all HistoryServiceObservers registered that URLs have been added or | 611 // Notify all HistoryServiceObservers registered that URLs have been added or |
613 // modified. |changed_urls| contains the list of affects URLs. | 612 // modified. |changed_urls| contains the list of affects URLs. |
614 void NotifyURLsModified(const history::URLRows& changed_urls); | 613 void NotifyURLsModified(const history::URLRows& changed_urls); |
615 | 614 |
615 // Notify all HistoryServiceObservers registered that URLs have been deleted. | |
616 // |deleted_details| contains the list of deleted URLs. | |
617 void NotifyURLsDeleted(const history::URLsDeletedDetails& deleted_details); | |
sdefresne
2014/12/04 17:21:13
I'd like to also remove URLsDeletedDetails by decl
nshaik
2014/12/07 09:34:50
Done.
| |
618 | |
616 // Notify all HistoryServiceObservers registered that the | 619 // Notify all HistoryServiceObservers registered that the |
617 // HistoryService has finished loading. | 620 // HistoryService has finished loading. |
618 void NotifyHistoryServiceLoaded(); | 621 void NotifyHistoryServiceLoaded(); |
619 | 622 |
620 // HistoryService is being deleted. | 623 // Notify all HistoryServiceObservers regigstered that HistoryService is being |
sdefresne
2014/12/04 17:21:13
nit: registered
nshaik
2014/12/07 09:34:50
Done.
| |
624 // deleted. | |
621 void NotifyHistoryServiceBeingDeleted(); | 625 void NotifyHistoryServiceBeingDeleted(); |
622 | 626 |
623 // Favicon ------------------------------------------------------------------- | 627 // Favicon ------------------------------------------------------------------- |
624 | 628 |
625 // These favicon methods are exposed to the FaviconService. Instead of calling | 629 // These favicon methods are exposed to the FaviconService. Instead of calling |
626 // these methods directly you should call the respective method on the | 630 // these methods directly you should call the respective method on the |
627 // FaviconService. | 631 // FaviconService. |
628 | 632 |
629 // Used by FaviconService to get the favicon bitmaps from the history backend | 633 // Used by FaviconService to get the favicon bitmaps from the history backend |
630 // whose edge sizes most closely match |desired_sizes| for |icon_types|. If | 634 // whose edge sizes most closely match |desired_sizes| for |icon_types|. If |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
856 DCHECK(thread_checker_.CalledOnValidThread()); | 860 DCHECK(thread_checker_.CalledOnValidThread()); |
857 ScheduleTask(priority, base::Bind(func, history_backend_.get(), | 861 ScheduleTask(priority, base::Bind(func, history_backend_.get(), |
858 a, b, c, d, e)); | 862 a, b, c, d, e)); |
859 } | 863 } |
860 | 864 |
861 // TODO(sdefresne): http://crbug.com/430070 remove this method. | 865 // TODO(sdefresne): http://crbug.com/430070 remove this method. |
862 Profile* profile() { return profile_; } | 866 Profile* profile() { return profile_; } |
863 | 867 |
864 base::ThreadChecker thread_checker_; | 868 base::ThreadChecker thread_checker_; |
865 | 869 |
866 content::NotificationRegistrar registrar_; | |
867 | |
868 // The thread used by the history service to run complicated operations. | 870 // The thread used by the history service to run complicated operations. |
869 // |thread_| is NULL once |Cleanup| is NULL. | 871 // |thread_| is NULL once |Cleanup| is NULL. |
870 base::Thread* thread_; | 872 base::Thread* thread_; |
871 | 873 |
872 // This class has most of the implementation and runs on the 'thread_'. | 874 // This class has most of the implementation and runs on the 'thread_'. |
873 // You MUST communicate with this class ONLY through the thread_'s | 875 // You MUST communicate with this class ONLY through the thread_'s |
874 // message_loop(). | 876 // message_loop(). |
875 // | 877 // |
876 // This pointer will be NULL once Cleanup() has been called, meaning no | 878 // This pointer will be NULL once Cleanup() has been called, meaning no |
877 // more calls should be made to the history thread. | 879 // more calls should be made to the history thread. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
913 | 915 |
914 history::DeleteDirectiveHandler delete_directive_handler_; | 916 history::DeleteDirectiveHandler delete_directive_handler_; |
915 | 917 |
916 // All vended weak pointers are invalidated in Cleanup(). | 918 // All vended weak pointers are invalidated in Cleanup(). |
917 base::WeakPtrFactory<HistoryService> weak_ptr_factory_; | 919 base::WeakPtrFactory<HistoryService> weak_ptr_factory_; |
918 | 920 |
919 DISALLOW_COPY_AND_ASSIGN(HistoryService); | 921 DISALLOW_COPY_AND_ASSIGN(HistoryService); |
920 }; | 922 }; |
921 | 923 |
922 #endif // CHROME_BROWSER_HISTORY_HISTORY_SERVICE_H_ | 924 #endif // CHROME_BROWSER_HISTORY_HISTORY_SERVICE_H_ |
OLD | NEW |