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