| 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_WEB_HISTORY_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_HISTORY_WEB_HISTORY_SERVICE_H_ |
| 6 #define CHROME_BROWSER_HISTORY_WEB_HISTORY_SERVICE_H_ | 6 #define CHROME_BROWSER_HISTORY_WEB_HISTORY_SERVICE_H_ |
| 7 | 7 |
| 8 #include <set> |
| 9 |
| 8 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 9 #include "chrome/browser/history/history_types.h" | 11 #include "chrome/browser/history/history_types.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 11 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" | 13 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" |
| 12 | 14 |
| 13 namespace base { | 15 namespace base { |
| 14 class DictionaryValue; | 16 class DictionaryValue; |
| 15 } | 17 } |
| 16 | 18 |
| 17 namespace net { | 19 namespace net { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 39 protected: | 41 protected: |
| 40 Request(); | 42 Request(); |
| 41 }; | 43 }; |
| 42 | 44 |
| 43 // Callback with the result of a call to QueryHistory(). Currently, the | 45 // Callback with the result of a call to QueryHistory(). Currently, the |
| 44 // DictionaryValue is just the parsed JSON response from the server. | 46 // DictionaryValue is just the parsed JSON response from the server. |
| 45 // TODO(dubroy): Extract the DictionaryValue into a structured results object. | 47 // TODO(dubroy): Extract the DictionaryValue into a structured results object. |
| 46 typedef base::Callback<void(Request*, const base::DictionaryValue*)> | 48 typedef base::Callback<void(Request*, const base::DictionaryValue*)> |
| 47 QueryWebHistoryCallback; | 49 QueryWebHistoryCallback; |
| 48 | 50 |
| 49 typedef base::Callback<void(Request*, bool success)> | 51 typedef base::Callback<void(bool success)> ExpireWebHistoryCallback; |
| 50 ExpireWebHistoryCallback; | |
| 51 | 52 |
| 52 explicit WebHistoryService(Profile* profile); | 53 explicit WebHistoryService(Profile* profile); |
| 53 virtual ~WebHistoryService(); | 54 virtual ~WebHistoryService(); |
| 54 | 55 |
| 55 // Searches synced history for visits matching |text_query|. The timeframe to | 56 // Searches synced history for visits matching |text_query|. The timeframe to |
| 56 // search, along with other options, is specified in |options|. If | 57 // search, along with other options, is specified in |options|. If |
| 57 // |text_query| is empty, all visits in the timeframe will be returned. | 58 // |text_query| is empty, all visits in the timeframe will be returned. |
| 58 // This method is the equivalent of HistoryService::QueryHistory. | 59 // This method is the equivalent of HistoryService::QueryHistory. |
| 59 // The caller takes ownership of the returned Request. If it is destroyed, the | 60 // The caller takes ownership of the returned Request. If it is destroyed, the |
| 60 // request is cancelled. | 61 // request is cancelled. |
| 61 scoped_ptr<Request> QueryHistory( | 62 scoped_ptr<Request> QueryHistory( |
| 62 const base::string16& text_query, | 63 const base::string16& text_query, |
| 63 const QueryOptions& options, | 64 const QueryOptions& options, |
| 64 const QueryWebHistoryCallback& callback); | 65 const QueryWebHistoryCallback& callback); |
| 65 | 66 |
| 66 // Removes all visits to specified URLs in specific time ranges. | 67 // Removes all visits to specified URLs in specific time ranges. |
| 67 // This is the of equivalent HistoryService::ExpireHistory(). | 68 // This is the of equivalent HistoryService::ExpireHistory(). |
| 68 // The caller takes ownership of the returned Request. If it is destroyed, the | 69 void ExpireHistory(const std::vector<ExpireHistoryArgs>& expire_list, |
| 69 // request is cancelled. | 70 const ExpireWebHistoryCallback& callback); |
| 70 scoped_ptr<Request> ExpireHistory( | |
| 71 const std::vector<ExpireHistoryArgs>& expire_list, | |
| 72 const ExpireWebHistoryCallback& callback); | |
| 73 | 71 |
| 74 // Removes all visits to specified URLs in the given time range. | 72 // Removes all visits to specified URLs in the given time range. |
| 75 // This is the of equivalent HistoryService::ExpireHistoryBetween(). | 73 // This is the of equivalent HistoryService::ExpireHistoryBetween(). |
| 76 scoped_ptr<Request> ExpireHistoryBetween( | 74 void ExpireHistoryBetween(const std::set<GURL>& restrict_urls, |
| 77 const std::set<GURL>& restrict_urls, | 75 base::Time begin_time, |
| 78 base::Time begin_time, | 76 base::Time end_time, |
| 79 base::Time end_time, | 77 const ExpireWebHistoryCallback& callback); |
| 80 const ExpireWebHistoryCallback& callback); | |
| 81 | 78 |
| 82 private: | 79 private: |
| 83 // Called by |request| when a web history query has completed. Unpacks the | 80 // Called by |request| when a web history query has completed. Unpacks the |
| 84 // response and calls |callback|, which is the original callback that was | 81 // response and calls |callback|, which is the original callback that was |
| 85 // passed to QueryHistory(). | 82 // passed to QueryHistory(). |
| 86 static void QueryHistoryCompletionCallback( | 83 static void QueryHistoryCompletionCallback( |
| 87 const WebHistoryService::QueryWebHistoryCallback& callback, | 84 const WebHistoryService::QueryWebHistoryCallback& callback, |
| 88 WebHistoryService::Request* request, | 85 WebHistoryService::Request* request, |
| 89 bool success); | 86 bool success); |
| 90 | 87 |
| 91 // Called by |request| when a request to delete history from the server has | 88 // Called by |request| when a request to delete history from the server has |
| 92 // completed. Unpacks the response and calls |callback|, which is the original | 89 // completed. Unpacks the response and calls |callback|, which is the original |
| 93 // callback that was passed to ExpireHistory(). | 90 // callback that was passed to ExpireHistory(). |
| 94 void ExpireHistoryCompletionCallback( | 91 void ExpireHistoryCompletionCallback( |
| 95 const WebHistoryService::ExpireWebHistoryCallback& callback, | 92 const WebHistoryService::ExpireWebHistoryCallback& callback, |
| 96 WebHistoryService::Request* request, | 93 WebHistoryService::Request* request, |
| 97 bool success); | 94 bool success); |
| 98 | 95 |
| 99 Profile* profile_; | 96 Profile* profile_; |
| 100 | 97 |
| 101 // Stores the version_info token received from the server in response to | 98 // Stores the version_info token received from the server in response to |
| 102 // a mutation operation (e.g., deleting history). This is used to ensure that | 99 // a mutation operation (e.g., deleting history). This is used to ensure that |
| 103 // subsequent reads see a version of the data that includes the mutation. | 100 // subsequent reads see a version of the data that includes the mutation. |
| 104 std::string server_version_info_; | 101 std::string server_version_info_; |
| 105 | 102 |
| 103 // Pending expiration requests to be canceled if not complete by profile |
| 104 // shutdown. |
| 105 std::set<Request*> pending_expire_requests_; |
| 106 |
| 106 base::WeakPtrFactory<WebHistoryService> weak_ptr_factory_; | 107 base::WeakPtrFactory<WebHistoryService> weak_ptr_factory_; |
| 107 | 108 |
| 108 DISALLOW_COPY_AND_ASSIGN(WebHistoryService); | 109 DISALLOW_COPY_AND_ASSIGN(WebHistoryService); |
| 109 }; | 110 }; |
| 110 | 111 |
| 111 } // namespace history | 112 } // namespace history |
| 112 | 113 |
| 113 #endif // CHROME_BROWSER_HISTORY_WEB_HISTORY_SERVICE_H_ | 114 #endif // CHROME_BROWSER_HISTORY_WEB_HISTORY_SERVICE_H_ |
| OLD | NEW |