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

Side by Side Diff: chrome/browser/android/chrome_backup_watcher.cc

Issue 2496693002: 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/android/chrome_backup_agent.h"
6 #include "chrome/browser/android/chrome_backup_watcher.h"
7 #include "chrome/browser/profiles/profile.h"
8 #include "jni/ChromeBackupWatcher_jni.h"
9
10 namespace chrome {
11 namespace android {
12
13 namespace {
14
15 void BackupPrefsChanged(
16 const base::android::ScopedJavaGlobalRef<jobject>& java_watcher) {
17 Java_ChromeBackupWatcher_onBackupPrefsChanged(
18 base::android::AttachCurrentThread(), java_watcher);
19 }
Bernhard Bauer 2016/11/14 10:05:39 Add an empty line after this one.
aberent 2016/11/14 17:23:40 Done.
20 }
21
22 ChromeBackupWatcher::ChromeBackupWatcher(Profile* profile)
23 : registrar_(new PrefChangeRegistrar) {
24 JNIEnv* env = base::android::AttachCurrentThread();
25 // Create the Java class, and start watching the Android (Java) preferences
26 java_watcher_.Reset(Java_ChromeBackupWatcher_createChromeBackupWatcher(env));
27 // Now watch the Chrome C++ preferences
28 registrar_->Init(profile->GetPrefs());
29 base::Closure callback = base::Bind(&BackupPrefsChanged, java_watcher_);
Bernhard Bauer 2016/11/14 10:05:39 In the interest of future-proofing the code, use a
aberent 2016/11/14 17:23:40 Done.
30 for (const std::string pref_name : GetBackupPrefNames()) {
31 registrar_->Add(pref_name, callback);
32 }
33 }
34
35 } // namespace android
36 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698