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

Side by Side Diff: components/invalidation/invalidation_service_android.cc

Issue 1146533005: [Sync] InvalidationService shouldn't CHECK when registering ObjectId for more than one handler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments from Bartosz. Created 5 years, 7 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/invalidation/invalidation_service_android.h" 5 #include "components/invalidation/invalidation_service_android.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_array.h" 8 #include "base/android/jni_array.h"
9 #include "base/android/jni_string.h" 9 #include "base/android/jni_string.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 20 matching lines...) Expand all
31 31
32 InvalidationServiceAndroid::~InvalidationServiceAndroid() { } 32 InvalidationServiceAndroid::~InvalidationServiceAndroid() { }
33 33
34 void InvalidationServiceAndroid::RegisterInvalidationHandler( 34 void InvalidationServiceAndroid::RegisterInvalidationHandler(
35 syncer::InvalidationHandler* handler) { 35 syncer::InvalidationHandler* handler) {
36 DCHECK(CalledOnValidThread()); 36 DCHECK(CalledOnValidThread());
37 invalidator_registrar_.RegisterHandler(handler); 37 invalidator_registrar_.RegisterHandler(handler);
38 logger_.OnRegistration(handler->GetOwnerName()); 38 logger_.OnRegistration(handler->GetOwnerName());
39 } 39 }
40 40
41 void InvalidationServiceAndroid::UpdateRegisteredInvalidationIds( 41 bool InvalidationServiceAndroid::UpdateRegisteredInvalidationIds(
42 syncer::InvalidationHandler* handler, 42 syncer::InvalidationHandler* handler,
43 const syncer::ObjectIdSet& ids) { 43 const syncer::ObjectIdSet& ids) {
44 DCHECK(CalledOnValidThread()); 44 DCHECK(CalledOnValidThread());
45 JNIEnv* env = base::android::AttachCurrentThread(); 45 JNIEnv* env = base::android::AttachCurrentThread();
46 DCHECK(env); 46 DCHECK(env);
47 47
48 invalidator_registrar_.UpdateRegisteredIds(handler, ids); 48 if (!invalidator_registrar_.UpdateRegisteredIds(handler, ids))
49 return false;
49 const syncer::ObjectIdSet& registered_ids = 50 const syncer::ObjectIdSet& registered_ids =
50 invalidator_registrar_.GetAllRegisteredIds(); 51 invalidator_registrar_.GetAllRegisteredIds();
51 52
52 // To call the corresponding method on the Java invalidation service, split 53 // To call the corresponding method on the Java invalidation service, split
53 // the object ids into object source and object name arrays. 54 // the object ids into object source and object name arrays.
54 std::vector<int> sources; 55 std::vector<int> sources;
55 std::vector<std::string> names; 56 std::vector<std::string> names;
56 syncer::ObjectIdSet::const_iterator id; 57 syncer::ObjectIdSet::const_iterator id;
57 for (id = registered_ids.begin(); id != registered_ids.end(); ++id) { 58 for (id = registered_ids.begin(); id != registered_ids.end(); ++id) {
58 sources.push_back(id->source()); 59 sources.push_back(id->source());
59 names.push_back(id->name()); 60 names.push_back(id->name());
60 } 61 }
61 62
62 Java_InvalidationService_setRegisteredObjectIds( 63 Java_InvalidationService_setRegisteredObjectIds(
63 env, 64 env,
64 java_ref_.obj(), 65 java_ref_.obj(),
65 base::android::ToJavaIntArray(env, sources).obj(), 66 base::android::ToJavaIntArray(env, sources).obj(),
66 base::android::ToJavaArrayOfStrings(env, names).obj()); 67 base::android::ToJavaArrayOfStrings(env, names).obj());
67 68
68 logger_.OnUpdateIds(invalidator_registrar_.GetSanitizedHandlersIdsMap()); 69 logger_.OnUpdateIds(invalidator_registrar_.GetSanitizedHandlersIdsMap());
70 return true;
69 } 71 }
70 72
71 void InvalidationServiceAndroid::UnregisterInvalidationHandler( 73 void InvalidationServiceAndroid::UnregisterInvalidationHandler(
72 syncer::InvalidationHandler* handler) { 74 syncer::InvalidationHandler* handler) {
73 DCHECK(CalledOnValidThread()); 75 DCHECK(CalledOnValidThread());
74 invalidator_registrar_.UnregisterHandler(handler); 76 invalidator_registrar_.UnregisterHandler(handler);
75 logger_.OnUnregistration(handler->GetOwnerName()); 77 logger_.OnUnregistration(handler->GetOwnerName());
76 } 78 }
77 79
78 syncer::InvalidatorState 80 syncer::InvalidatorState
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 effective_invalidation_map); 169 effective_invalidation_map);
168 logger_.OnInvalidation(effective_invalidation_map); 170 logger_.OnInvalidation(effective_invalidation_map);
169 } 171 }
170 172
171 // static 173 // static
172 bool InvalidationServiceAndroid::RegisterJni(JNIEnv* env) { 174 bool InvalidationServiceAndroid::RegisterJni(JNIEnv* env) {
173 return RegisterNativesImpl(env); 175 return RegisterNativesImpl(env);
174 } 176 }
175 177
176 } // namespace invalidation 178 } // namespace invalidation
OLDNEW
« no previous file with comments | « components/invalidation/invalidation_service_android.h ('k') | components/invalidation/invalidation_service_test_template.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698