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> | 8 #include <set> |
9 | 9 |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 }; | 43 }; |
44 | 44 |
45 // Callback with the result of a call to QueryHistory(). Currently, the | 45 // Callback with the result of a call to QueryHistory(). Currently, the |
46 // DictionaryValue is just the parsed JSON response from the server. | 46 // DictionaryValue is just the parsed JSON response from the server. |
47 // TODO(dubroy): Extract the DictionaryValue into a structured results object. | 47 // TODO(dubroy): Extract the DictionaryValue into a structured results object. |
48 typedef base::Callback<void(Request*, const base::DictionaryValue*)> | 48 typedef base::Callback<void(Request*, const base::DictionaryValue*)> |
49 QueryWebHistoryCallback; | 49 QueryWebHistoryCallback; |
50 | 50 |
51 typedef base::Callback<void(bool success)> ExpireWebHistoryCallback; | 51 typedef base::Callback<void(bool success)> ExpireWebHistoryCallback; |
52 | 52 |
| 53 typedef base::Callback<void(bool success, bool new_enabled_value)> |
| 54 AudioWebHistoryCallback; |
| 55 |
53 explicit WebHistoryService(Profile* profile); | 56 explicit WebHistoryService(Profile* profile); |
54 ~WebHistoryService() override; | 57 ~WebHistoryService() override; |
55 | 58 |
56 // Searches synced history for visits matching |text_query|. The timeframe to | 59 // Searches synced history for visits matching |text_query|. The timeframe to |
57 // search, along with other options, is specified in |options|. If | 60 // search, along with other options, is specified in |options|. If |
58 // |text_query| is empty, all visits in the timeframe will be returned. | 61 // |text_query| is empty, all visits in the timeframe will be returned. |
59 // This method is the equivalent of HistoryService::QueryHistory. | 62 // This method is the equivalent of HistoryService::QueryHistory. |
60 // The caller takes ownership of the returned Request. If it is destroyed, the | 63 // The caller takes ownership of the returned Request. If it is destroyed, the |
61 // request is cancelled. | 64 // request is cancelled. |
62 scoped_ptr<Request> QueryHistory( | 65 scoped_ptr<Request> QueryHistory( |
63 const base::string16& text_query, | 66 const base::string16& text_query, |
64 const QueryOptions& options, | 67 const QueryOptions& options, |
65 const QueryWebHistoryCallback& callback); | 68 const QueryWebHistoryCallback& callback); |
66 | 69 |
67 // Removes all visits to specified URLs in specific time ranges. | 70 // Removes all visits to specified URLs in specific time ranges. |
68 // This is the of equivalent HistoryService::ExpireHistory(). | 71 // This is the of equivalent HistoryService::ExpireHistory(). |
69 void ExpireHistory(const std::vector<ExpireHistoryArgs>& expire_list, | 72 void ExpireHistory(const std::vector<ExpireHistoryArgs>& expire_list, |
70 const ExpireWebHistoryCallback& callback); | 73 const ExpireWebHistoryCallback& callback); |
71 | 74 |
72 // Removes all visits to specified URLs in the given time range. | 75 // Removes all visits to specified URLs in the given time range. |
73 // This is the of equivalent HistoryService::ExpireHistoryBetween(). | 76 // This is the of equivalent HistoryService::ExpireHistoryBetween(). |
74 void ExpireHistoryBetween(const std::set<GURL>& restrict_urls, | 77 void ExpireHistoryBetween(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); |
78 | 81 |
| 82 // Requests whether audio history recording is enabled. |
| 83 void GetAudioHistoryEnabled(const AudioWebHistoryCallback& callback); |
| 84 |
| 85 // Sets the state of audio history recording to |new_enabled_value|. |
| 86 void SetAudioHistoryEnabled(bool new_enabled_value, |
| 87 const AudioWebHistoryCallback& callback); |
79 private: | 88 private: |
80 // Called by |request| when a web history query has completed. Unpacks the | 89 // Called by |request| when a web history query has completed. Unpacks the |
81 // response and calls |callback|, which is the original callback that was | 90 // response and calls |callback|, which is the original callback that was |
82 // passed to QueryHistory(). | 91 // passed to QueryHistory(). |
83 static void QueryHistoryCompletionCallback( | 92 static void QueryHistoryCompletionCallback( |
84 const WebHistoryService::QueryWebHistoryCallback& callback, | 93 const WebHistoryService::QueryWebHistoryCallback& callback, |
85 WebHistoryService::Request* request, | 94 WebHistoryService::Request* request, |
86 bool success); | 95 bool success); |
87 | 96 |
88 // Called by |request| when a request to delete history from the server has | 97 // Called by |request| when a request to delete history from the server has |
89 // completed. Unpacks the response and calls |callback|, which is the original | 98 // completed. Unpacks the response and calls |callback|, which is the original |
90 // callback that was passed to ExpireHistory(). | 99 // callback that was passed to ExpireHistory(). |
91 void ExpireHistoryCompletionCallback( | 100 void ExpireHistoryCompletionCallback( |
92 const WebHistoryService::ExpireWebHistoryCallback& callback, | 101 const WebHistoryService::ExpireWebHistoryCallback& callback, |
93 WebHistoryService::Request* request, | 102 WebHistoryService::Request* request, |
94 bool success); | 103 bool success); |
95 | 104 |
| 105 // Called by |request| when a request to get or set audio history from the |
| 106 // server has completed. Unpacks the response and calls |callback|, which is |
| 107 // the original callback that was passed to AudioHistory(). |
| 108 void AudioHistoryCompletionCallback( |
| 109 const WebHistoryService::AudioWebHistoryCallback& callback, |
| 110 WebHistoryService::Request* request, |
| 111 bool success); |
| 112 |
96 Profile* profile_; | 113 Profile* profile_; |
97 | 114 |
98 // Stores the version_info token received from the server in response to | 115 // Stores the version_info token received from the server in response to |
99 // a mutation operation (e.g., deleting history). This is used to ensure that | 116 // a mutation operation (e.g., deleting history). This is used to ensure that |
100 // subsequent reads see a version of the data that includes the mutation. | 117 // subsequent reads see a version of the data that includes the mutation. |
101 std::string server_version_info_; | 118 std::string server_version_info_; |
102 | 119 |
103 // Pending expiration requests to be canceled if not complete by profile | 120 // Pending expiration requests to be canceled if not complete by profile |
104 // shutdown. | 121 // shutdown. |
105 std::set<Request*> pending_expire_requests_; | 122 std::set<Request*> pending_expire_requests_; |
106 | 123 |
| 124 // Pending requests to be canceled if not complete by profile shutdown. |
| 125 std::set<Request*> pending_audio_history_requests_; |
| 126 |
107 base::WeakPtrFactory<WebHistoryService> weak_ptr_factory_; | 127 base::WeakPtrFactory<WebHistoryService> weak_ptr_factory_; |
108 | 128 |
109 DISALLOW_COPY_AND_ASSIGN(WebHistoryService); | 129 DISALLOW_COPY_AND_ASSIGN(WebHistoryService); |
110 }; | 130 }; |
111 | 131 |
112 } // namespace history | 132 } // namespace history |
113 | 133 |
114 #endif // CHROME_BROWSER_HISTORY_WEB_HISTORY_SERVICE_H_ | 134 #endif // CHROME_BROWSER_HISTORY_WEB_HISTORY_SERVICE_H_ |
OLD | NEW |