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

Side by Side Diff: chrome/browser/sync/profile_sync_service_android.cc

Issue 195873020: [Sync] Move SyncPrefs into sync_driver component (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rerererebase Created 6 years, 9 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/sync/profile_sync_service_android.h" 5 #include "chrome/browser/sync/profile_sync_service_android.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/i18n/time_formatting.h" 10 #include "base/i18n/time_formatting.h"
11 #include "base/json/json_writer.h" 11 #include "base/json/json_writer.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/prefs/pref_service.h" 14 #include "base/prefs/pref_service.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "chrome/browser/browser_process.h" 17 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/chrome_notification_types.h" 18 #include "chrome/browser/chrome_notification_types.h"
19 #include "chrome/browser/profiles/profile_manager.h" 19 #include "chrome/browser/profiles/profile_manager.h"
20 #include "chrome/browser/signin/signin_manager.h" 20 #include "chrome/browser/signin/signin_manager.h"
21 #include "chrome/browser/signin/signin_manager_factory.h" 21 #include "chrome/browser/signin/signin_manager_factory.h"
22 #include "chrome/browser/sync/about_sync_util.h" 22 #include "chrome/browser/sync/about_sync_util.h"
23 #include "chrome/browser/sync/profile_sync_service.h" 23 #include "chrome/browser/sync/profile_sync_service.h"
24 #include "chrome/browser/sync/profile_sync_service_factory.h" 24 #include "chrome/browser/sync/profile_sync_service_factory.h"
25 #include "chrome/browser/sync/sync_prefs.h"
26 #include "chrome/browser/sync/sync_ui_util.h" 25 #include "chrome/browser/sync/sync_ui_util.h"
27 #include "chrome/common/pref_names.h" 26 #include "components/sync_driver/pref_names.h"
27 #include "components/sync_driver/sync_prefs.h"
28 #include "content/public/browser/browser_thread.h" 28 #include "content/public/browser/browser_thread.h"
29 #include "content/public/browser/notification_service.h" 29 #include "content/public/browser/notification_service.h"
30 #include "content/public/browser/notification_source.h" 30 #include "content/public/browser/notification_source.h"
31 #include "google/cacheinvalidation/types.pb.h" 31 #include "google/cacheinvalidation/types.pb.h"
32 #include "google_apis/gaia/gaia_constants.h" 32 #include "google_apis/gaia/gaia_constants.h"
33 #include "google_apis/gaia/google_service_auth_error.h" 33 #include "google_apis/gaia/google_service_auth_error.h"
34 #include "grit/generated_resources.h" 34 #include "grit/generated_resources.h"
35 #include "jni/ProfileSyncService_jni.h" 35 #include "jni/ProfileSyncService_jni.h"
36 #include "sync/internal_api/public/read_transaction.h" 36 #include "sync/internal_api/public/read_transaction.h"
37 #include "sync/notifier/object_id_invalidation_map.h" 37 #include "sync/notifier/object_id_invalidation_map.h"
(...skipping 25 matching lines...) Expand all
63 NOTREACHED() << "Browser process or profile manager not initialized"; 63 NOTREACHED() << "Browser process or profile manager not initialized";
64 return; 64 return;
65 } 65 }
66 66
67 profile_ = ProfileManager::GetActiveUserProfile(); 67 profile_ = ProfileManager::GetActiveUserProfile();
68 if (profile_ == NULL) { 68 if (profile_ == NULL) {
69 NOTREACHED() << "Sync Init: Profile not found."; 69 NOTREACHED() << "Sync Init: Profile not found.";
70 return; 70 return;
71 } 71 }
72 72
73 sync_prefs_.reset(new browser_sync::SyncPrefs(profile_->GetPrefs())); 73 sync_prefs_.reset(new sync_driver::SyncPrefs(profile_->GetPrefs()));
74 74
75 sync_service_ = 75 sync_service_ =
76 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_); 76 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_);
77 DCHECK(sync_service_); 77 DCHECK(sync_service_);
78 } 78 }
79 79
80 void ProfileSyncServiceAndroid::Init() { 80 void ProfileSyncServiceAndroid::Init() {
81 sync_service_->AddObserver(this); 81 sync_service_->AddObserver(this);
82 } 82 }
83 83
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 465
466 return ConvertUTF8ToJavaString(env, about_info_json); 466 return ConvertUTF8ToJavaString(env, about_info_json);
467 } 467 }
468 468
469 jlong ProfileSyncServiceAndroid::GetLastSyncedTimeForTest( 469 jlong ProfileSyncServiceAndroid::GetLastSyncedTimeForTest(
470 JNIEnv* env, jobject obj) { 470 JNIEnv* env, jobject obj) {
471 // Use profile preferences here instead of SyncPrefs to avoid an extra 471 // Use profile preferences here instead of SyncPrefs to avoid an extra
472 // conversion, since SyncPrefs::GetLastSyncedTime() converts the stored value 472 // conversion, since SyncPrefs::GetLastSyncedTime() converts the stored value
473 // to to base::Time. 473 // to to base::Time.
474 return static_cast<jlong>( 474 return static_cast<jlong>(
475 profile_->GetPrefs()->GetInt64(prefs::kSyncLastSyncedTime)); 475 profile_->GetPrefs()->GetInt64(sync_driver::prefs::kSyncLastSyncedTime));
476 } 476 }
477 477
478 void ProfileSyncServiceAndroid::NudgeSyncer(JNIEnv* env, 478 void ProfileSyncServiceAndroid::NudgeSyncer(JNIEnv* env,
479 jobject obj, 479 jobject obj,
480 jint objectSource, 480 jint objectSource,
481 jstring objectId, 481 jstring objectId,
482 jlong version, 482 jlong version,
483 jstring state) { 483 jstring state) {
484 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 484 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
485 SendNudgeNotification(objectSource, ConvertJavaStringToUTF8(env, objectId), 485 SendNudgeNotification(objectSource, ConvertJavaStringToUTF8(env, objectId),
(...skipping 23 matching lines...) Expand all
509 ProfileSyncServiceAndroid* profile_sync_service_android = 509 ProfileSyncServiceAndroid* profile_sync_service_android =
510 new ProfileSyncServiceAndroid(env, obj); 510 new ProfileSyncServiceAndroid(env, obj);
511 profile_sync_service_android->Init(); 511 profile_sync_service_android->Init();
512 return reinterpret_cast<intptr_t>(profile_sync_service_android); 512 return reinterpret_cast<intptr_t>(profile_sync_service_android);
513 } 513 }
514 514
515 // static 515 // static
516 bool ProfileSyncServiceAndroid::Register(JNIEnv* env) { 516 bool ProfileSyncServiceAndroid::Register(JNIEnv* env) {
517 return RegisterNativesImpl(env); 517 return RegisterNativesImpl(env);
518 } 518 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service_android.h ('k') | chrome/browser/sync/profile_sync_service_startup_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698