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

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

Issue 23441042: Refactor common invalidation framework types (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move DEPS rule Created 7 years, 2 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"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 const std::string& str_object_id, 98 const std::string& str_object_id,
99 int64 version, 99 int64 version,
100 const std::string& state) { 100 const std::string& state) {
101 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 101 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
102 102
103 // TODO(nileshagrawal): Merge this with ChromeInvalidationClient::Invalidate. 103 // TODO(nileshagrawal): Merge this with ChromeInvalidationClient::Invalidate.
104 // Construct the ModelTypeStateMap and send it over with the notification. 104 // Construct the ModelTypeStateMap and send it over with the notification.
105 invalidation::ObjectId object_id( 105 invalidation::ObjectId object_id(
106 object_source, 106 object_source,
107 str_object_id); 107 str_object_id);
108 syncer::ObjectIdInvalidationMap object_ids_with_states;
108 if (version == ipc::invalidation::Constants::UNKNOWN) { 109 if (version == ipc::invalidation::Constants::UNKNOWN) {
109 version = syncer::Invalidation::kUnknownVersion; 110 object_ids_with_states.Insert(
111 syncer::Invalidation::InitUnknownVersion(object_id));
110 } else { 112 } else {
111 ObjectIdVersionMap::iterator it = 113 ObjectIdVersionMap::iterator it =
112 max_invalidation_versions_.find(object_id); 114 max_invalidation_versions_.find(object_id);
113 if ((it != max_invalidation_versions_.end()) && 115 if ((it != max_invalidation_versions_.end()) &&
114 (version <= it->second)) { 116 (version <= it->second)) {
115 DVLOG(1) << "Dropping redundant invalidation with version " << version; 117 DVLOG(1) << "Dropping redundant invalidation with version " << version;
116 return; 118 return;
117 } 119 }
118 max_invalidation_versions_[object_id] = version; 120 max_invalidation_versions_[object_id] = version;
121 object_ids_with_states.Insert(
122 syncer::Invalidation::Init(object_id, version, state));
119 } 123 }
120 124
121 syncer::ObjectIdSet object_ids;
122 object_ids.insert(object_id);
123 syncer::ObjectIdInvalidationMap object_ids_with_states =
124 syncer::ObjectIdSetToInvalidationMap(object_ids, version, state);
125
126 content::NotificationService::current()->Notify( 125 content::NotificationService::current()->Notify(
127 chrome::NOTIFICATION_SYNC_REFRESH_REMOTE, 126 chrome::NOTIFICATION_SYNC_REFRESH_REMOTE,
128 content::Source<Profile>(profile_), 127 content::Source<Profile>(profile_),
129 content::Details<const syncer::ObjectIdInvalidationMap>( 128 content::Details<const syncer::ObjectIdInvalidationMap>(
130 &object_ids_with_states)); 129 &object_ids_with_states));
131 } 130 }
132 131
133 void ProfileSyncServiceAndroid::OnStateChanged() { 132 void ProfileSyncServiceAndroid::OnStateChanged() {
134 // Notify the java world that our sync state has changed. 133 // Notify the java world that our sync state has changed.
135 JNIEnv* env = AttachCurrentThread(); 134 JNIEnv* env = AttachCurrentThread();
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 ProfileSyncServiceAndroid* profile_sync_service_android = 516 ProfileSyncServiceAndroid* profile_sync_service_android =
518 new ProfileSyncServiceAndroid(env, obj); 517 new ProfileSyncServiceAndroid(env, obj);
519 profile_sync_service_android->Init(); 518 profile_sync_service_android->Init();
520 return reinterpret_cast<jint>(profile_sync_service_android); 519 return reinterpret_cast<jint>(profile_sync_service_android);
521 } 520 }
522 521
523 // static 522 // static
524 bool ProfileSyncServiceAndroid::Register(JNIEnv* env) { 523 bool ProfileSyncServiceAndroid::Register(JNIEnv* env) {
525 return RegisterNativesImpl(env); 524 return RegisterNativesImpl(env);
526 } 525 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/sync_backend_host_unittest.cc ('k') | chrome/browser/sync/profile_sync_service_harness.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698