Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6232)

Unified Diff: chrome/browser/history/web_history_service.h

Issue 687803004: [Hotword] Implement audio history pref accessing and setting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixing memory leak with scoped ptrs Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/history/DEPS ('k') | chrome/browser/history/web_history_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..a022178887462d2b324ebb0016ba5261135803e2 100644
--- a/chrome/browser/history/web_history_service.h
+++ b/chrome/browser/history/web_history_service.h
@@ -36,7 +36,19 @@ class WebHistoryService : public KeyedService {
// Returns true if the request is "pending" (i.e., it has been started, but
// is not yet been complete).
- virtual bool is_pending() = 0;
+ virtual bool IsPending() = 0;
+
+ // Returns the response code received from the server, which will only be
+ // valid if the request succeeded.
+ virtual int GetResponseCode() = 0;
+
+ // Returns the contents of the response body received from the server.
+ virtual const std::string& GetResponseBody() = 0;
+
+ virtual void SetPostData(const std::string& post_data) = 0;
+
+ // Tells the request to begin.
+ virtual void Start() = 0;
protected:
Request();
@@ -50,6 +62,11 @@ 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;
@@ -76,7 +93,27 @@ 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);
+
+ // Used for tests.
+ size_t GetNumberOfPendingAudioHistoryRequests();
+
+ protected:
+ // This function is pulled out for testing purposes. Caller takes ownership of
+ // the new Request.
+ virtual Request* CreateRequest(const GURL& url,
+ 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);
+
// 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 +130,17 @@ 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);
+
+ private:
+ friend class WebHistoryServiceTest;
+
Profile* profile_;
// Stores the version_info token received from the server in response to
@@ -104,6 +152,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);
« no previous file with comments | « chrome/browser/history/DEPS ('k') | chrome/browser/history/web_history_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698