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_H_ | 5 #ifndef CHROME_BROWSER_HISTORY_HISTORY_H_ |
6 #define CHROME_BROWSER_HISTORY_HISTORY_H_ | 6 #define CHROME_BROWSER_HISTORY_HISTORY_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... | |
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_provider_service.h" | 30 #include "chrome/browser/history/android/android_history_provider_service.h" |
31 #endif | 31 #endif |
32 | 32 |
33 class BookmarkService; | 33 class BookmarkService; |
34 class FilePath; | 34 class FilePath; |
35 class GURL; | 35 class GURL; |
36 class HistoryURLProvider; | 36 class HistoryURLProvider; |
37 struct HistoryURLProviderParams; | |
38 class PageUsageData; | 37 class PageUsageData; |
39 class PageUsageRequest; | 38 class PageUsageRequest; |
40 class Profile; | 39 class Profile; |
40 struct DownloadPersistentStoreInfo; | |
41 struct HistoryURLProviderParams; | |
41 | 42 |
42 namespace base { | 43 namespace base { |
43 class Thread; | 44 class Thread; |
44 class Time; | 45 class Time; |
45 } | 46 } |
46 | 47 |
47 namespace content { | |
48 struct DownloadPersistentStoreInfo; | |
49 } | |
50 | 48 |
51 namespace history { | 49 namespace history { |
52 class InMemoryHistoryBackend; | 50 class InMemoryHistoryBackend; |
53 class InMemoryURLIndex; | 51 class InMemoryURLIndex; |
54 class InMemoryURLIndexTest; | 52 class InMemoryURLIndexTest; |
55 class HistoryAddPageArgs; | 53 class HistoryAddPageArgs; |
56 class HistoryBackend; | 54 class HistoryBackend; |
57 class HistoryDatabase; | 55 class HistoryDatabase; |
58 struct HistoryDetails; | 56 struct HistoryDetails; |
59 class HistoryQueryTest; | 57 class HistoryQueryTest; |
(...skipping 26 matching lines...) Expand all Loading... | |
86 protected: | 84 protected: |
87 friend class base::RefCountedThreadSafe<HistoryDBTask>; | 85 friend class base::RefCountedThreadSafe<HistoryDBTask>; |
88 | 86 |
89 virtual ~HistoryDBTask() {} | 87 virtual ~HistoryDBTask() {} |
90 }; | 88 }; |
91 | 89 |
92 // The history service records page titles, and visit times, as well as | 90 // The history service records page titles, and visit times, as well as |
93 // (eventually) information about autocomplete. | 91 // (eventually) information about autocomplete. |
94 // | 92 // |
95 // This service is thread safe. Each request callback is invoked in the | 93 // This service is thread safe. Each request callback is invoked in the |
96 // thread that made the request. | 94 // thread that made the request. |
Randy Smith (Not in Mondays)
2012/08/27 19:28:19
I'd modify this comment to say "Each request callb
benjhayden
2012/09/10 19:02:56
Done.
| |
97 class HistoryService : public CancelableRequestProvider, | 95 class HistoryService : public CancelableRequestProvider, |
98 public content::NotificationObserver, | 96 public content::NotificationObserver, |
99 public RefcountedProfileKeyedService { | 97 public RefcountedProfileKeyedService { |
100 public: | 98 public: |
101 // Miscellaneous commonly-used types. | 99 // Miscellaneous commonly-used types. |
102 typedef std::vector<PageUsageData*> PageUsageDataList; | 100 typedef std::vector<PageUsageData*> PageUsageDataList; |
103 | 101 |
104 // Must call Init after construction. | 102 // Must call Init after construction. |
105 explicit HistoryService(Profile* profile); | 103 explicit HistoryService(Profile* profile); |
106 // The empty constructor is provided only for testing. | 104 // The empty constructor is provided only for testing. |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
433 // removed. | 431 // removed. |
434 void ExpireHistoryBetween(const std::set<GURL>& restrict_urls, | 432 void ExpireHistoryBetween(const std::set<GURL>& restrict_urls, |
435 base::Time begin_time, base::Time end_time, | 433 base::Time begin_time, base::Time end_time, |
436 CancelableRequestConsumerBase* consumer, | 434 CancelableRequestConsumerBase* consumer, |
437 const base::Closure& callback); | 435 const base::Closure& callback); |
438 | 436 |
439 // Downloads ----------------------------------------------------------------- | 437 // Downloads ----------------------------------------------------------------- |
440 | 438 |
441 // Implemented by the caller of 'CreateDownload' below, and is called when the | 439 // Implemented by the caller of 'CreateDownload' below, and is called when the |
442 // history service has created a new entry for a download in the history db. | 440 // history service has created a new entry for a download in the history db. |
443 typedef base::Callback<void(int32, int64)> DownloadCreateCallback; | 441 typedef base::Callback<void(int64)> DownloadCreateCallback; |
444 | 442 |
445 // Begins a history request to create a new persistent entry for a download. | 443 // Begins a history request to create a new persistent entry for a download. |
446 // 'info' contains all the download's creation state, and 'callback' runs | 444 // 'info' contains all the download's creation state, and 'callback' runs |
447 // when the history service request is complete. | 445 // when the history service request is complete. |
448 Handle CreateDownload(int32 id, | 446 void CreateDownload(const DownloadPersistentStoreInfo& info, |
449 const content::DownloadPersistentStoreInfo& info, | 447 const DownloadCreateCallback& callback); |
450 CancelableRequestConsumerBase* consumer, | 448 |
451 const DownloadCreateCallback& callback); | 449 typedef base::Callback< |
450 void(bool, // Were we able to determine the # of visits? | |
451 int, // Number of visits. | |
452 base::Time)> // Time of first visit. Only set if bool | |
453 // is true and int is > 0. | |
454 GetVisibleVisitCountToHostSimpleCallback; | |
455 void GetVisibleVisitCountToHostSimple( | |
456 const GURL& url, | |
457 const GetVisibleVisitCountToHostSimpleCallback& callback); | |
452 | 458 |
453 // Implemented by the caller of 'GetNextDownloadId' below. | 459 // Implemented by the caller of 'GetNextDownloadId' below. |
454 typedef base::Callback<void(int)> DownloadNextIdCallback; | 460 typedef base::Callback<void(int)> DownloadNextIdCallback; |
455 | 461 |
456 // Runs the callback with the next available download id. | 462 // Runs the callback with the next available download id. |
457 Handle GetNextDownloadId(CancelableRequestConsumerBase* consumer, | 463 Handle GetNextDownloadId(CancelableRequestConsumerBase* consumer, |
458 const DownloadNextIdCallback& callback); | 464 const DownloadNextIdCallback& callback); |
459 | 465 |
460 // Implemented by the caller of 'QueryDownloads' below, and is called when the | 466 // Implemented by the caller of 'QueryDownloads' below, and is called when the |
461 // history service has retrieved a list of all download state. The call | 467 // history service has retrieved a list of all download state. The call |
462 typedef base::Callback<void( | 468 typedef base::Callback<void( |
463 std::vector<content::DownloadPersistentStoreInfo>*)> | 469 scoped_ptr<std::vector<DownloadPersistentStoreInfo> >)> |
464 DownloadQueryCallback; | 470 DownloadQueryCallback; |
465 | 471 |
466 // Begins a history request to retrieve the state of all downloads in the | 472 // Begins a history request to retrieve the state of all downloads in the |
467 // history db. 'callback' runs when the history service request is complete, | 473 // history db. 'callback' runs when the history service request is complete, |
468 // at which point 'info' contains an array of DownloadPersistentStoreInfo, one | 474 // at which point 'info' contains an array of DownloadPersistentStoreInfo, one |
469 // per download. | 475 // per download. |
470 Handle QueryDownloads(CancelableRequestConsumerBase* consumer, | 476 void QueryDownloads(const DownloadQueryCallback& callback); |
471 const DownloadQueryCallback& callback); | |
472 | 477 |
473 // Begins a request to clean up entries that has been corrupted (because of | 478 // Begins a request to clean up entries that has been corrupted (because of |
474 // the crash, for example). | 479 // the crash, for example). |
475 void CleanUpInProgressEntries(); | 480 void CleanUpInProgressEntries(); |
476 | 481 |
477 // Called to update the history service about the current state of a download. | 482 // Called to update the history service about the current state of a download. |
478 // This is a 'fire and forget' query, so just pass the relevant state info to | 483 // This is a 'fire and forget' query, so just pass the relevant state info to |
479 // the database with no need for a callback. | 484 // the database with no need for a callback. |
480 void UpdateDownload(const content::DownloadPersistentStoreInfo& data); | 485 void UpdateDownload(const DownloadPersistentStoreInfo& data); |
481 | 486 |
482 // Called to update the history service about the path of a download. | 487 // Permanently remove a set of downloads from the history system. This is a |
483 // This is a 'fire and forget' query. | 488 // 'fire and forget' operation. |
484 void UpdateDownloadPath(const FilePath& path, int64 db_handle); | 489 void RemoveDownloads(const std::set<int64>& handles); |
485 | |
486 // Permanently remove a download from the history system. This is a 'fire and | |
487 // forget' operation. | |
488 void RemoveDownload(int64 db_handle); | |
489 | |
490 // Permanently removes all completed download from the history system within | |
491 // the specified range. This function does not delete downloads that are in | |
492 // progress or in the process of being cancelled. This is a 'fire and forget' | |
493 // operation. You can pass is_null times to get unbounded time in either or | |
494 // both directions. | |
495 void RemoveDownloadsBetween(base::Time remove_begin, base::Time remove_end); | |
496 | 490 |
497 // Visit Segments ------------------------------------------------------------ | 491 // Visit Segments ------------------------------------------------------------ |
498 | 492 |
499 typedef base::Callback<void(Handle, std::vector<PageUsageData*>*)> | 493 typedef base::Callback<void(Handle, std::vector<PageUsageData*>*)> |
500 SegmentQueryCallback; | 494 SegmentQueryCallback; |
501 | 495 |
502 // Query usage data for all visit segments since the provided time. | 496 // Query usage data for all visit segments since the provided time. |
503 // | 497 // |
504 // The request is performed asynchronously and can be cancelled by using the | 498 // The request is performed asynchronously and can be cancelled by using the |
505 // returned handle. | 499 // returned handle. |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
950 // The index used for quick history lookups. | 944 // The index used for quick history lookups. |
951 scoped_ptr<history::InMemoryURLIndex> in_memory_url_index_; | 945 scoped_ptr<history::InMemoryURLIndex> in_memory_url_index_; |
952 | 946 |
953 scoped_refptr<ObserverListThreadSafe<history::VisitDatabaseObserver> > | 947 scoped_refptr<ObserverListThreadSafe<history::VisitDatabaseObserver> > |
954 visit_database_observers_; | 948 visit_database_observers_; |
955 | 949 |
956 DISALLOW_COPY_AND_ASSIGN(HistoryService); | 950 DISALLOW_COPY_AND_ASSIGN(HistoryService); |
957 }; | 951 }; |
958 | 952 |
959 #endif // CHROME_BROWSER_HISTORY_HISTORY_H_ | 953 #endif // CHROME_BROWSER_HISTORY_HISTORY_H_ |
OLD | NEW |