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

Unified Diff: chrome/browser/android/chrome_backup_watcher.cc

Issue 2511713002: Implement Android key/value backup (Closed)
Patch Set: Created 4 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/android/chrome_backup_watcher.h ('k') | chrome/browser/android/chrome_jni_registrar.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/chrome_backup_watcher.cc
diff --git a/chrome/browser/android/chrome_backup_watcher.cc b/chrome/browser/android/chrome_backup_watcher.cc
new file mode 100644
index 0000000000000000000000000000000000000000..da084fec68ea4f4a7644f90a155d08629de39c49
--- /dev/null
+++ b/chrome/browser/android/chrome_backup_watcher.cc
@@ -0,0 +1,38 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/android/chrome_backup_agent.h"
+#include "chrome/browser/android/chrome_backup_watcher.h"
+#include "chrome/browser/profiles/profile.h"
+#include "jni/ChromeBackupWatcher_jni.h"
+
+namespace chrome {
+namespace android {
+
+namespace {
+
+void BackupPrefsChanged(
+ const base::android::ScopedJavaGlobalRef<jobject>& java_watcher) {
+ Java_ChromeBackupWatcher_onBackupPrefsChanged(
+ base::android::AttachCurrentThread(), java_watcher);
+}
+}
+
+ChromeBackupWatcher::ChromeBackupWatcher(Profile* profile) {
+ JNIEnv* env = base::android::AttachCurrentThread();
+ // Create the Java class, and start watching the Android (Java) preferences
+ java_watcher_.Reset(Java_ChromeBackupWatcher_createChromeBackupWatcher(env));
+ // Now watch the Chrome C++ preferences
+ registrar_.Init(profile->GetPrefs());
+ base::RepeatingClosure callback =
+ base::BindRepeating(&BackupPrefsChanged, java_watcher_);
+ for (const std::string pref_name : GetBackupPrefNames()) {
+ registrar_.Add(pref_name, callback);
+ }
+}
+
+ChromeBackupWatcher::~ChromeBackupWatcher() {}
+
+} // namespace android
+} // namespace chrome
« no previous file with comments | « chrome/browser/android/chrome_backup_watcher.h ('k') | chrome/browser/android/chrome_jni_registrar.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698