OLD | NEW |
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" |
(...skipping 16 matching lines...) Expand all Loading... |
27 #include "components/sync_driver/pref_names.h" | 27 #include "components/sync_driver/pref_names.h" |
28 #include "components/sync_driver/sync_prefs.h" | 28 #include "components/sync_driver/sync_prefs.h" |
29 #include "content/public/browser/browser_thread.h" | 29 #include "content/public/browser/browser_thread.h" |
30 #include "content/public/browser/notification_service.h" | 30 #include "content/public/browser/notification_service.h" |
31 #include "content/public/browser/notification_source.h" | 31 #include "content/public/browser/notification_source.h" |
32 #include "google/cacheinvalidation/types.pb.h" | 32 #include "google/cacheinvalidation/types.pb.h" |
33 #include "google_apis/gaia/gaia_constants.h" | 33 #include "google_apis/gaia/gaia_constants.h" |
34 #include "google_apis/gaia/google_service_auth_error.h" | 34 #include "google_apis/gaia/google_service_auth_error.h" |
35 #include "grit/generated_resources.h" | 35 #include "grit/generated_resources.h" |
36 #include "jni/ProfileSyncService_jni.h" | 36 #include "jni/ProfileSyncService_jni.h" |
| 37 #include "sync/internal_api/public/network_resources.h" |
37 #include "sync/internal_api/public/read_transaction.h" | 38 #include "sync/internal_api/public/read_transaction.h" |
38 #include "ui/base/l10n/l10n_util.h" | 39 #include "ui/base/l10n/l10n_util.h" |
39 | 40 |
40 using base::android::AttachCurrentThread; | 41 using base::android::AttachCurrentThread; |
41 using base::android::CheckException; | 42 using base::android::CheckException; |
42 using base::android::ConvertJavaStringToUTF8; | 43 using base::android::ConvertJavaStringToUTF8; |
43 using base::android::ConvertUTF8ToJavaString; | 44 using base::android::ConvertUTF8ToJavaString; |
44 using base::android::ScopedJavaLocalRef; | 45 using base::android::ScopedJavaLocalRef; |
45 using content::BrowserThread; | 46 using content::BrowserThread; |
46 | 47 |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 | 469 |
469 jlong ProfileSyncServiceAndroid::GetLastSyncedTimeForTest( | 470 jlong ProfileSyncServiceAndroid::GetLastSyncedTimeForTest( |
470 JNIEnv* env, jobject obj) { | 471 JNIEnv* env, jobject obj) { |
471 // Use profile preferences here instead of SyncPrefs to avoid an extra | 472 // Use profile preferences here instead of SyncPrefs to avoid an extra |
472 // conversion, since SyncPrefs::GetLastSyncedTime() converts the stored value | 473 // conversion, since SyncPrefs::GetLastSyncedTime() converts the stored value |
473 // to to base::Time. | 474 // to to base::Time. |
474 return static_cast<jlong>( | 475 return static_cast<jlong>( |
475 profile_->GetPrefs()->GetInt64(sync_driver::prefs::kSyncLastSyncedTime)); | 476 profile_->GetPrefs()->GetInt64(sync_driver::prefs::kSyncLastSyncedTime)); |
476 } | 477 } |
477 | 478 |
| 479 void ProfileSyncServiceAndroid::OverrideNetworkResourcesForTest( |
| 480 JNIEnv* env, |
| 481 jobject obj, |
| 482 jlong network_resources) { |
| 483 syncer::NetworkResources* resources = |
| 484 reinterpret_cast<syncer::NetworkResources*>(network_resources); |
| 485 sync_service_->OverrideNetworkResourcesForTest( |
| 486 make_scoped_ptr<syncer::NetworkResources>(resources)); |
| 487 } |
| 488 |
478 void ProfileSyncServiceAndroid::NudgeSyncer(JNIEnv* env, | 489 void ProfileSyncServiceAndroid::NudgeSyncer(JNIEnv* env, |
479 jobject obj, | 490 jobject obj, |
480 jint objectSource, | 491 jint objectSource, |
481 jstring objectId, | 492 jstring objectId, |
482 jlong version, | 493 jlong version, |
483 jstring state) { | 494 jstring state) { |
484 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 495 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
485 SendNudgeNotification(objectSource, ConvertJavaStringToUTF8(env, objectId), | 496 SendNudgeNotification(objectSource, ConvertJavaStringToUTF8(env, objectId), |
486 version, ConvertJavaStringToUTF8(env, state)); | 497 version, ConvertJavaStringToUTF8(env, state)); |
487 } | 498 } |
(...skipping 21 matching lines...) Expand all Loading... |
509 ProfileSyncServiceAndroid* profile_sync_service_android = | 520 ProfileSyncServiceAndroid* profile_sync_service_android = |
510 new ProfileSyncServiceAndroid(env, obj); | 521 new ProfileSyncServiceAndroid(env, obj); |
511 profile_sync_service_android->Init(); | 522 profile_sync_service_android->Init(); |
512 return reinterpret_cast<intptr_t>(profile_sync_service_android); | 523 return reinterpret_cast<intptr_t>(profile_sync_service_android); |
513 } | 524 } |
514 | 525 |
515 // static | 526 // static |
516 bool ProfileSyncServiceAndroid::Register(JNIEnv* env) { | 527 bool ProfileSyncServiceAndroid::Register(JNIEnv* env) { |
517 return RegisterNativesImpl(env); | 528 return RegisterNativesImpl(env); |
518 } | 529 } |
OLD | NEW |