| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 ObjectIdVersionMap::iterator it = | 111 ObjectIdVersionMap::iterator it = |
| 112 max_invalidation_versions_.find(object_id); | 112 max_invalidation_versions_.find(object_id); |
| 113 if ((it != max_invalidation_versions_.end()) && | 113 if ((it != max_invalidation_versions_.end()) && |
| 114 (version <= it->second)) { | 114 (version <= it->second)) { |
| 115 DVLOG(1) << "Dropping redundant invalidation with version " << version; | 115 DVLOG(1) << "Dropping redundant invalidation with version " << version; |
| 116 return; | 116 return; |
| 117 } | 117 } |
| 118 max_invalidation_versions_[object_id] = version; | 118 max_invalidation_versions_[object_id] = version; |
| 119 } | 119 } |
| 120 | 120 |
| 121 syncer::ObjectIdSet object_ids; | 121 InvalidationMap invalidation_map; |
| 122 object_ids.insert(object_id); | 122 invalidationMap.Insert(Invalidation::Init(object_id, version, state)); |
| 123 syncer::ObjectIdInvalidationMap object_ids_with_states = | |
| 124 syncer::ObjectIdSetToInvalidationMap(object_ids, version, state); | |
| 125 | 123 |
| 126 content::NotificationService::current()->Notify( | 124 content::NotificationService::current()->Notify( |
| 127 chrome::NOTIFICATION_SYNC_REFRESH_REMOTE, | 125 chrome::NOTIFICATION_SYNC_REFRESH_REMOTE, |
| 128 content::Source<Profile>(profile_), | 126 content::Source<Profile>(profile_), |
| 129 content::Details<const syncer::ObjectIdInvalidationMap>( | 127 content::Details<const syncer::ObjectIdInvalidationMap>( |
| 130 &object_ids_with_states)); | 128 &invalidation_map)); |
| 131 } | 129 } |
| 132 | 130 |
| 133 void ProfileSyncServiceAndroid::OnStateChanged() { | 131 void ProfileSyncServiceAndroid::OnStateChanged() { |
| 134 // Notify the java world that our sync state has changed. | 132 // Notify the java world that our sync state has changed. |
| 135 JNIEnv* env = AttachCurrentThread(); | 133 JNIEnv* env = AttachCurrentThread(); |
| 136 Java_ProfileSyncService_syncStateChanged( | 134 Java_ProfileSyncService_syncStateChanged( |
| 137 env, weak_java_profile_sync_service_.get(env).obj()); | 135 env, weak_java_profile_sync_service_.get(env).obj()); |
| 138 } | 136 } |
| 139 | 137 |
| 140 void ProfileSyncServiceAndroid::TokenAvailable( | 138 void ProfileSyncServiceAndroid::TokenAvailable( |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 jlong version, | 488 jlong version, |
| 491 jstring state) { | 489 jstring state) { |
| 492 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 490 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 493 SendNudgeNotification(objectSource, ConvertJavaStringToUTF8(env, objectId), | 491 SendNudgeNotification(objectSource, ConvertJavaStringToUTF8(env, objectId), |
| 494 version, ConvertJavaStringToUTF8(env, state)); | 492 version, ConvertJavaStringToUTF8(env, state)); |
| 495 } | 493 } |
| 496 | 494 |
| 497 void ProfileSyncServiceAndroid::NudgeSyncerForAllTypes(JNIEnv* env, | 495 void ProfileSyncServiceAndroid::NudgeSyncerForAllTypes(JNIEnv* env, |
| 498 jobject obj) { | 496 jobject obj) { |
| 499 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 497 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 500 syncer::ObjectIdInvalidationMap object_ids_with_states; | 498 syncer::InvalidationMap empty_invalidations; |
| 501 content::NotificationService::current()->Notify( | 499 content::NotificationService::current()->Notify( |
| 502 chrome::NOTIFICATION_SYNC_REFRESH_REMOTE, | 500 chrome::NOTIFICATION_SYNC_REFRESH_REMOTE, |
| 503 content::Source<Profile>(profile_), | 501 content::Source<Profile>(profile_), |
| 504 content::Details<const syncer::ObjectIdInvalidationMap>( | 502 content::Details<const syncer::ObjectIdInvalidationMap>( |
| 505 &object_ids_with_states)); | 503 &empty_invalidations)); |
| 506 } | 504 } |
| 507 | 505 |
| 508 // static | 506 // static |
| 509 ProfileSyncServiceAndroid* | 507 ProfileSyncServiceAndroid* |
| 510 ProfileSyncServiceAndroid::GetProfileSyncServiceAndroid() { | 508 ProfileSyncServiceAndroid::GetProfileSyncServiceAndroid() { |
| 511 return reinterpret_cast<ProfileSyncServiceAndroid*>( | 509 return reinterpret_cast<ProfileSyncServiceAndroid*>( |
| 512 Java_ProfileSyncService_getProfileSyncServiceAndroid( | 510 Java_ProfileSyncService_getProfileSyncServiceAndroid( |
| 513 AttachCurrentThread(), base::android::GetApplicationContext())); | 511 AttachCurrentThread(), base::android::GetApplicationContext())); |
| 514 } | 512 } |
| 515 | 513 |
| 516 static int Init(JNIEnv* env, jobject obj) { | 514 static int Init(JNIEnv* env, jobject obj) { |
| 517 ProfileSyncServiceAndroid* profile_sync_service_android = | 515 ProfileSyncServiceAndroid* profile_sync_service_android = |
| 518 new ProfileSyncServiceAndroid(env, obj); | 516 new ProfileSyncServiceAndroid(env, obj); |
| 519 profile_sync_service_android->Init(); | 517 profile_sync_service_android->Init(); |
| 520 return reinterpret_cast<jint>(profile_sync_service_android); | 518 return reinterpret_cast<jint>(profile_sync_service_android); |
| 521 } | 519 } |
| 522 | 520 |
| 523 // static | 521 // static |
| 524 bool ProfileSyncServiceAndroid::Register(JNIEnv* env) { | 522 bool ProfileSyncServiceAndroid::Register(JNIEnv* env) { |
| 525 return RegisterNativesImpl(env); | 523 return RegisterNativesImpl(env); |
| 526 } | 524 } |
| OLD | NEW |