Index: chrome/browser/history/web_history_service.h |
diff --git a/chrome/browser/history/web_history_service.h b/chrome/browser/history/web_history_service.h |
index 692efbb0c0c4cc5ca84a34bcfb079b0d8b68ae20..421ec12bbcc94a8ca2c1d1de0cb22cefc58980a6 100644 |
--- a/chrome/browser/history/web_history_service.h |
+++ b/chrome/browser/history/web_history_service.h |
@@ -38,6 +38,18 @@ class WebHistoryService : public KeyedService { |
// is not yet been complete). |
virtual bool is_pending() = 0; |
+ // Returns the response code received from the server, which will only be |
+ // valid if the request succeeded. |
+ virtual int response_code() = 0; |
sky
2014/11/19 01:02:41
We don't use unix_hacker_style for virtual methods
rpetterson
2014/11/19 02:04:56
I was following the pre-existing style (see is_pen
sky
2014/11/19 16:02:43
Yes, but if you want to fix up the other feel free
|
+ |
+ // Returns the contents of the response body received from the server. |
+ virtual const std::string& response_body() = 0; |
+ |
+ virtual void set_post_data(const std::string& post_data) = 0; |
+ |
+ // Tells the request to begin. |
+ virtual void Start() = 0; |
+ |
protected: |
Request(); |
}; |
@@ -50,9 +62,24 @@ class WebHistoryService : public KeyedService { |
typedef base::Callback<void(bool success)> ExpireWebHistoryCallback; |
+ typedef base::Callback<void(bool success, bool new_enabled_value)> |
+ AudioWebHistoryCallback; |
+ |
+ typedef base::Callback<void(Request*, bool success)> CompletionCallback; |
+ |
explicit WebHistoryService(Profile* profile); |
~WebHistoryService() override; |
+ // This function is pulled out for testing purposes. Caller takes ownership of |
+ // the new Request. |
+ virtual Request* CreateRequest(const GURL& url, |
sky
2014/11/19 01:02:41
Can this and the next be protected?
rpetterson
2014/11/19 02:04:56
Done.
|
+ const CompletionCallback& callback); |
+ |
+ // Extracts a JSON-encoded HTTP response into a DictionaryValue. |
+ // If |request|'s HTTP response code indicates failure, or if the response |
+ // body is not JSON, a null pointer is returned. |
+ static scoped_ptr<base::DictionaryValue> ReadResponse(Request* request); |
+ |
// Searches synced history for visits matching |text_query|. The timeframe to |
// search, along with other options, is specified in |options|. If |
// |text_query| is empty, all visits in the timeframe will be returned. |
@@ -76,7 +103,15 @@ class WebHistoryService : public KeyedService { |
base::Time end_time, |
const ExpireWebHistoryCallback& callback); |
- private: |
+ // Requests whether audio history recording is enabled. |
+ void GetAudioHistoryEnabled(const AudioWebHistoryCallback& callback); |
+ |
+ // Sets the state of audio history recording to |new_enabled_value|. |
+ void SetAudioHistoryEnabled(bool new_enabled_value, |
+ const AudioWebHistoryCallback& callback); |
+ protected: |
+ friend class WebHistoryServiceTest; |
+ |
// Called by |request| when a web history query has completed. Unpacks the |
// response and calls |callback|, which is the original callback that was |
// passed to QueryHistory(). |
@@ -93,6 +128,14 @@ class WebHistoryService : public KeyedService { |
WebHistoryService::Request* request, |
bool success); |
+ // Called by |request| when a request to get or set audio history from the |
+ // server has completed. Unpacks the response and calls |callback|, which is |
+ // the original callback that was passed to AudioHistory(). |
+ void AudioHistoryCompletionCallback( |
+ const WebHistoryService::AudioWebHistoryCallback& callback, |
+ WebHistoryService::Request* request, |
+ bool success); |
+ |
Profile* profile_; |
sky
2014/11/19 01:02:41
Style guide says no protected fields.
rpetterson
2014/11/19 02:04:56
Done.
|
// Stores the version_info token received from the server in response to |
@@ -104,6 +147,9 @@ class WebHistoryService : public KeyedService { |
// shutdown. |
std::set<Request*> pending_expire_requests_; |
+ // Pending requests to be canceled if not complete by profile shutdown. |
+ std::set<Request*> pending_audio_history_requests_; |
+ |
base::WeakPtrFactory<WebHistoryService> weak_ptr_factory_; |
DISALLOW_COPY_AND_ASSIGN(WebHistoryService); |