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

Unified Diff: chrome/browser/search/hotword_audio_history_handler.h

Issue 800523002: [Hotword] Sync Audio History pref every 24 hours, when opening chrome://settings and . . . (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Doing It Right Created 6 years 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
Index: chrome/browser/search/hotword_audio_history_handler.h
diff --git a/chrome/browser/search/hotword_audio_history_handler.h b/chrome/browser/search/hotword_audio_history_handler.h
index 2f1616b2ff62d59e975cb38f1e0219fb01babca2..13770800249397d5b750427fbc7228dc3363b6b6 100644
--- a/chrome/browser/search/hotword_audio_history_handler.h
+++ b/chrome/browser/search/hotword_audio_history_handler.h
@@ -5,12 +5,17 @@
#ifndef CHROME_BROWSER_SEARCH_HOTWORD_AUDIO_HISTORY_HANDLER_H_
#define CHROME_BROWSER_SEARCH_HOTWORD_AUDIO_HISTORY_HANDLER_H_
+#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/prefs/pref_change_registrar.h"
#include "content/public/browser/browser_context.h"
class Profile;
+namespace base {
+class SingleThreadTaskRunner;
+}
+
namespace history {
class WebHistoryService;
}
@@ -23,12 +28,19 @@ class HotwordAudioHistoryHandler {
typedef base::Callback<void(bool success, bool new_enabled_value)>
HotwordAudioHistoryCallback;
- explicit HotwordAudioHistoryHandler(content::BrowserContext* context);
+ HotwordAudioHistoryHandler(
+ content::BrowserContext* context,
+ const scoped_refptr<base::SingleThreadTaskRunner>& task_runner);
+
virtual ~HotwordAudioHistoryHandler();
+ // Initiates a call to get the updated audio history state.
+ void UpdateAudioHistoryState();
+
// Updates the current preference value based on the user's account info
// or false if the user is not signed in.
- void GetAudioHistoryEnabled(const HotwordAudioHistoryCallback& callback);
+ virtual void GetAudioHistoryEnabled(
+ const HotwordAudioHistoryCallback& callback);
// Sets the user's global pref value for enabling audio history.
void SetAudioHistoryEnabled(const bool enabled,
@@ -38,6 +50,9 @@ class HotwordAudioHistoryHandler {
virtual history::WebHistoryService* GetWebHistory();
private:
+ // Helper function used as a callback and to factor out common code.
+ void UpdateLocalPreference(bool success, bool new_enabled_value);
+
// Called upon completion of web history->GetAudioHistoryEnabled.
void GetAudioHistoryComplete(
const HotwordAudioHistoryCallback& callback,
@@ -53,6 +68,8 @@ class HotwordAudioHistoryHandler {
bool success,
bool callback_enabled_value);
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
+
Profile* profile_;
base::WeakPtrFactory<HotwordAudioHistoryHandler> weak_ptr_factory_;

Powered by Google App Engine
This is Rietveld 408576698