@@ -48,7 +48,14 @@ import { DocumentKey } from '../model/document_key';
48
48
import { Mutation } from '../model/mutation' ;
49
49
import { BATCHID_UNKNOWN , MutationBatchResult } from '../model/mutation_batch' ;
50
50
import { RemoteEvent , TargetChange } from '../remote/remote_event' ;
51
- import { RemoteStore } from '../remote/remote_store' ;
51
+ import {
52
+ canUseNetwork ,
53
+ fillWritePipeline ,
54
+ RemoteStore ,
55
+ remoteStoreApplyPrimaryState ,
56
+ remoteStoreListen ,
57
+ remoteStoreUnlisten
58
+ } from '../remote/remote_store' ;
52
59
import { debugAssert , debugCast , fail , hardAssert } from '../util/assert' ;
53
60
import { Code , FirestoreError } from '../util/error' ;
54
61
import { logDebug } from '../util/log' ;
@@ -338,7 +345,7 @@ export async function syncEngineListen(
338
345
status === 'current'
339
346
) ;
340
347
if ( syncEngineImpl . isPrimaryClient ) {
341
- syncEngineImpl . remoteStore . listen ( targetData ) ;
348
+ remoteStoreListen ( syncEngineImpl . remoteStore , targetData ) ;
342
349
}
343
350
}
344
351
@@ -439,7 +446,7 @@ export async function syncEngineUnlisten(
439
446
)
440
447
. then ( ( ) => {
441
448
syncEngineImpl . sharedClientState . clearQueryState ( queryView . targetId ) ;
442
- syncEngineImpl . remoteStore . unlisten ( queryView . targetId ) ;
449
+ remoteStoreUnlisten ( syncEngineImpl . remoteStore , queryView . targetId ) ;
443
450
removeAndCleanupTarget ( syncEngineImpl , queryView . targetId ) ;
444
451
} )
445
452
. catch ( ignoreIfPrimaryLeaseLoss ) ;
@@ -477,7 +484,7 @@ export async function syncEngineWrite(
477
484
syncEngineImpl . sharedClientState . addPendingMutation ( result . batchId ) ;
478
485
addMutationCallback ( syncEngineImpl , result . batchId , userCallback ) ;
479
486
await emitNewSnapsAndNotifyLocalStore ( syncEngineImpl , result . changes ) ;
480
- await syncEngineImpl . remoteStore . fillWritePipeline ( ) ;
487
+ await fillWritePipeline ( syncEngineImpl . remoteStore ) ;
481
488
} catch ( e ) {
482
489
// If we can't persist the mutation, we reject the user callback and
483
490
// don't send the mutation. The user can then retry the write.
@@ -725,7 +732,7 @@ export async function registerPendingWritesCallback(
725
732
callback : Deferred < void >
726
733
) : Promise < void > {
727
734
const syncEngineImpl = debugCast ( syncEngine , SyncEngineImpl ) ;
728
- if ( ! syncEngineImpl . remoteStore . canUseNetwork ( ) ) {
735
+ if ( ! canUseNetwork ( syncEngineImpl . remoteStore ) ) {
729
736
logDebug (
730
737
LOG_TAG ,
731
738
'The network is disabled. The task returned by ' +
@@ -888,7 +895,7 @@ function removeLimboTarget(
888
895
return ;
889
896
}
890
897
891
- syncEngineImpl . remoteStore . unlisten ( limboTargetId ) ;
898
+ remoteStoreUnlisten ( syncEngineImpl . remoteStore , limboTargetId ) ;
892
899
syncEngineImpl . activeLimboTargetsByKey = syncEngineImpl . activeLimboTargetsByKey . remove (
893
900
key
894
901
) ;
@@ -960,7 +967,8 @@ function pumpEnqueuedLimboResolutions(syncEngineImpl: SyncEngineImpl): void {
960
967
key ,
961
968
limboTargetId
962
969
) ;
963
- syncEngineImpl . remoteStore . listen (
970
+ remoteStoreListen (
971
+ syncEngineImpl . remoteStore ,
964
972
new TargetData (
965
973
queryToTarget ( newQueryForPath ( key . path ) ) ,
966
974
limboTargetId ,
@@ -1064,7 +1072,7 @@ async function applyDocChanges(
1064
1072
return viewChange . snapshot ;
1065
1073
}
1066
1074
1067
- export async function handleCredentialChange (
1075
+ export async function syncEngineHandleCredentialChange (
1068
1076
syncEngine : SyncEngine ,
1069
1077
user : User
1070
1078
) : Promise < void > {
@@ -1181,7 +1189,7 @@ export async function applyBatchState(
1181
1189
// If we are the primary client, we need to send this write to the
1182
1190
// backend. Secondary clients will ignore these writes since their remote
1183
1191
// connection is disabled.
1184
- await syncEngineImpl . remoteStore . fillWritePipeline ( ) ;
1192
+ await fillWritePipeline ( syncEngineImpl . remoteStore ) ;
1185
1193
} else if ( batchState === 'acknowledged' || batchState === 'rejected' ) {
1186
1194
// NOTE: Both these methods are no-ops for batches that originated from
1187
1195
// other clients.
@@ -1217,9 +1225,9 @@ export async function applyPrimaryState(
1217
1225
/*transitionToPrimary=*/ true
1218
1226
) ;
1219
1227
syncEngineImpl . _isPrimaryClient = true ;
1220
- await syncEngineImpl . remoteStore . applyPrimaryState ( true ) ;
1228
+ await remoteStoreApplyPrimaryState ( syncEngineImpl . remoteStore , true ) ;
1221
1229
for ( const targetData of activeQueries ) {
1222
- syncEngineImpl . remoteStore . listen ( targetData ) ;
1230
+ remoteStoreListen ( syncEngineImpl . remoteStore , targetData ) ;
1223
1231
}
1224
1232
} else if ( isPrimary === false && syncEngineImpl . _isPrimaryClient !== false ) {
1225
1233
const activeTargets : TargetId [ ] = [ ] ;
@@ -1238,7 +1246,7 @@ export async function applyPrimaryState(
1238
1246
) ;
1239
1247
} ) ;
1240
1248
}
1241
- syncEngineImpl . remoteStore . unlisten ( targetId ) ;
1249
+ remoteStoreUnlisten ( syncEngineImpl . remoteStore , targetId ) ;
1242
1250
} ) ;
1243
1251
await p ;
1244
1252
@@ -1249,15 +1257,15 @@ export async function applyPrimaryState(
1249
1257
) ;
1250
1258
resetLimboDocuments ( syncEngineImpl ) ;
1251
1259
syncEngineImpl . _isPrimaryClient = false ;
1252
- await syncEngineImpl . remoteStore . applyPrimaryState ( false ) ;
1260
+ await remoteStoreApplyPrimaryState ( syncEngineImpl . remoteStore , false ) ;
1253
1261
}
1254
1262
}
1255
1263
1256
1264
// PORTING NOTE: Multi-Tab only.
1257
1265
function resetLimboDocuments ( syncEngine : SyncEngine ) : void {
1258
1266
const syncEngineImpl = debugCast ( syncEngine , SyncEngineImpl ) ;
1259
1267
syncEngineImpl . activeLimboResolutionsByTarget . forEach ( ( _ , targetId ) => {
1260
- syncEngineImpl . remoteStore . unlisten ( targetId ) ;
1268
+ remoteStoreUnlisten ( syncEngineImpl . remoteStore , targetId ) ;
1261
1269
} ) ;
1262
1270
syncEngineImpl . limboDocumentRefs . removeAllReferences ( ) ;
1263
1271
syncEngineImpl . activeLimboResolutionsByTarget = new Map <
@@ -1447,7 +1455,7 @@ export async function applyActiveTargetsChange(
1447
1455
targetData . targetId ,
1448
1456
/*current=*/ false
1449
1457
) ;
1450
- syncEngineImpl . remoteStore . listen ( targetData ) ;
1458
+ remoteStoreListen ( syncEngineImpl . remoteStore , targetData ) ;
1451
1459
}
1452
1460
1453
1461
for ( const targetId of removed ) {
@@ -1464,7 +1472,7 @@ export async function applyActiveTargetsChange(
1464
1472
/* keepPersistedTargetData */ false
1465
1473
)
1466
1474
. then ( ( ) => {
1467
- syncEngineImpl . remoteStore . unlisten ( targetId ) ;
1475
+ remoteStoreUnlisten ( syncEngineImpl . remoteStore , targetId ) ;
1468
1476
removeAndCleanupTarget ( syncEngineImpl , targetId ) ;
1469
1477
} )
1470
1478
. catch ( ignoreIfPrimaryLeaseLoss ) ;
@@ -1473,15 +1481,15 @@ export async function applyActiveTargetsChange(
1473
1481
1474
1482
function ensureWatchCallbacks ( syncEngine : SyncEngine ) : SyncEngineImpl {
1475
1483
const syncEngineImpl = debugCast ( syncEngine , SyncEngineImpl ) ;
1476
- syncEngineImpl . remoteStore . remoteSyncer . applyRemoteEvent = applyRemoteEvent . bind (
1484
+ syncEngineImpl . remoteStore . syncEngine . applyRemoteEvent = applyRemoteEvent . bind (
1477
1485
null ,
1478
1486
syncEngineImpl
1479
1487
) ;
1480
- syncEngineImpl . remoteStore . remoteSyncer . getRemoteKeysForTarget = getRemoteKeysForTarget . bind (
1488
+ syncEngineImpl . remoteStore . syncEngine . getRemoteKeysForTarget = getRemoteKeysForTarget . bind (
1481
1489
null ,
1482
1490
syncEngineImpl
1483
1491
) ;
1484
- syncEngineImpl . remoteStore . remoteSyncer . rejectListen = rejectListen . bind (
1492
+ syncEngineImpl . remoteStore . syncEngine . rejectListen = rejectListen . bind (
1485
1493
null ,
1486
1494
syncEngineImpl
1487
1495
) ;
@@ -1490,11 +1498,11 @@ function ensureWatchCallbacks(syncEngine: SyncEngine): SyncEngineImpl {
1490
1498
1491
1499
function ensureWriteCallbacks ( syncEngine : SyncEngine ) : SyncEngineImpl {
1492
1500
const syncEngineImpl = debugCast ( syncEngine , SyncEngineImpl ) ;
1493
- syncEngineImpl . remoteStore . remoteSyncer . applySuccessfulWrite = applySuccessfulWrite . bind (
1501
+ syncEngineImpl . remoteStore . syncEngine . applySuccessfulWrite = applySuccessfulWrite . bind (
1494
1502
null ,
1495
1503
syncEngineImpl
1496
1504
) ;
1497
- syncEngineImpl . remoteStore . remoteSyncer . rejectFailedWrite = rejectFailedWrite . bind (
1505
+ syncEngineImpl . remoteStore . syncEngine . rejectFailedWrite = rejectFailedWrite . bind (
1498
1506
null ,
1499
1507
syncEngineImpl
1500
1508
) ;
0 commit comments