@@ -44,7 +44,11 @@ import { Code, FirestoreError } from '../../../src/util/error';
44
44
import { Deferred } from '../../../src/util/promise' ;
45
45
import { LruParams } from '../../../src/local/lru_garbage_collector' ;
46
46
import { CACHE_SIZE_UNLIMITED } from '../../../src/api/database' ;
47
- import { DatabaseInfo } from '../../../src/core/database_info' ;
47
+ import { DatabaseId , DatabaseInfo } from '../../../src/core/database_info' ;
48
+ import {
49
+ buildStoragePrefix ,
50
+ clearPersistence
51
+ } from '../../../src/local/indexeddb_persistence' ;
48
52
49
53
/**
50
54
* The root reference to the Firestore database and the entry point for the
@@ -142,7 +146,16 @@ export class Firestore extends LiteFirestore
142
146
return terminate ( this ) ;
143
147
}
144
148
145
- _clearPersistence ( ) : Promise < void > {
149
+ /**
150
+ * Verifies that the client is not running and clears persistence by invoking
151
+ * `clearPersistenceDelegate` on the async queue.
152
+ *
153
+ * @param delegate A function that clears the clients
154
+ * backing storage.
155
+ */
156
+ _clearPersistence (
157
+ delegate : ( databaseId : DatabaseId , persistenceKey : string ) => Promise < void >
158
+ ) : Promise < void > {
146
159
if ( this . _deferredInitialization !== undefined && ! this . _terminated ) {
147
160
throw new FirestoreError (
148
161
Code . FAILED_PRECONDITION ,
@@ -151,16 +164,10 @@ export class Firestore extends LiteFirestore
151
164
) ;
152
165
}
153
166
154
- const settings = this . _getSettings ( ) ;
155
167
const deferred = new Deferred < void > ( ) ;
156
168
this . _queue . enqueueAndForgetEvenAfterShutdown ( async ( ) => {
157
169
try {
158
- const databaseInfo = this . _makeDatabaseInfo (
159
- settings . host ,
160
- settings . ssl ,
161
- settings . experimentalForceLongPolling
162
- ) ;
163
- await this . _componentProvider . clearPersistence ( databaseInfo ) ;
170
+ await delegate ( this . _databaseId , this . _persistenceKey ) ;
164
171
deferred . resolve ( ) ;
165
172
} catch ( e ) {
166
173
deferred . reject ( e ) ;
@@ -246,7 +253,9 @@ export function clearIndexedDbPersistence(
246
253
firestore : firestore . FirebaseFirestore
247
254
) : Promise < void > {
248
255
const firestoreImpl = cast ( firestore , Firestore ) ;
249
- return firestoreImpl . _clearPersistence ( ) ;
256
+ return firestoreImpl . _clearPersistence ( ( databaseId , persistenceKey ) => {
257
+ return clearPersistence ( buildStoragePrefix ( databaseId , persistenceKey ) ) ;
258
+ } ) ;
250
259
}
251
260
252
261
export function waitForPendingWrites (
0 commit comments