29
29
#include " Firestore/core/src/firebase/firestore/util/log.h"
30
30
#include " Firestore/core/src/firebase/firestore/util/status.h"
31
31
32
+ namespace firebase {
33
+ namespace firestore {
34
+ namespace core {
35
+
32
36
namespace {
33
37
34
- using firebase:: firestore::Error;
35
- using firebase::firestore:: model::ListenSequenceNumber;
36
- using firebase::firestore:: util::Status;
38
+ using firestore::Error;
39
+ using model::ListenSequenceNumber;
40
+ using util::Status;
37
41
38
42
// Limbo documents don't use persistence, and are eagerly GC'd. So, listens for
39
43
// them don't need real sequence numbers.
@@ -48,9 +52,6 @@ bool ErrorIsInteresting(const Status& error) {
48
52
}
49
53
50
54
} // namespace
51
- namespace firebase {
52
- namespace firestore {
53
- namespace core {
54
55
55
56
using auth::User;
56
57
using local::LocalViewChanges;
@@ -89,6 +90,7 @@ bool ErrorIsInteresting(const Status& error) {
89
90
90
91
TargetId SyncEngine::Listen (Query query) {
91
92
AssertCallbackExists (" Listen" );
93
+
92
94
HARD_ASSERT (query_views_by_query_.find (query) == query_views_by_query_.end (),
93
95
" We already listen to query: %s" , query.ToString ());
94
96
@@ -131,6 +133,7 @@ bool ErrorIsInteresting(const Status& error) {
131
133
132
134
void SyncEngine::StopListening (const Query& query) {
133
135
AssertCallbackExists (" StopListening" );
136
+
134
137
auto query_view = query_views_by_query_[query];
135
138
HARD_ASSERT (query_view, " Trying to stop listening to a query not found" );
136
139
@@ -231,13 +234,15 @@ bool ErrorIsInteresting(const Status& error) {
231
234
if (it == limbo_resolutions_by_target_.end ()) {
232
235
continue ;
233
236
}
237
+
234
238
LimboResolution& limbo_resolution = it->second ;
235
239
// Since this is a limbo resolution lookup, it's for a single document and
236
240
// it could be added, modified, or removed, but not a combination.
241
+ auto changed_documents_count = change.added_documents ().size () +
242
+ change.modified_documents ().size () +
243
+ change.removed_documents ().size ();
237
244
HARD_ASSERT (
238
- change.added_documents ().size () + change.modified_documents ().size () +
239
- change.removed_documents ().size () <=
240
- 1 ,
245
+ changed_documents_count <= 1 ,
241
246
" Limbo resolution for single document contains multiple changes." );
242
247
243
248
if (!change.added_documents ().empty ()) {
@@ -420,7 +425,7 @@ NoDocument doc(limbo_key, SnapshotVersion::None(),
420
425
421
426
for (const auto & entry : query_views_by_query_) {
422
427
const auto & query_view = entry.second ;
423
- const View& view = query_view->view ();
428
+ View& view = query_view->view ();
424
429
ViewDocumentChanges view_doc_changes = view.ComputeDocumentChanges (changes);
425
430
if (view_doc_changes.needs_refill ()) {
426
431
// The query has a limit and some docs were removed/updated, so we need to
@@ -440,7 +445,7 @@ NoDocument doc(limbo_key, SnapshotVersion::None(),
440
445
}
441
446
}
442
447
ViewChange view_change =
443
- query_view-> view () .ApplyChanges (view_doc_changes, target_changes);
448
+ view.ApplyChanges (view_doc_changes, target_changes);
444
449
445
450
UpdateTrackedLimboDocuments (view_change.limbo_changes (),
446
451
query_view->target_id ());
0 commit comments