FSTLevelDBMutationQueue.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Copyright 2017 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import <Foundation/Foundation.h>
  17. #include <memory>
  18. #import "Firestore/Source/Local/FSTMutationQueue.h"
  19. #include "Firestore/core/src/firebase/firestore/auth/user.h"
  20. #include "leveldb/db.h"
  21. @class FSTLevelDB;
  22. @class FSTLocalSerializer;
  23. NS_ASSUME_NONNULL_BEGIN
  24. /** A mutation queue for a specific user, backed by LevelDB. */
  25. @interface FSTLevelDBMutationQueue : NSObject <FSTMutationQueue>
  26. - (instancetype)init __attribute__((unavailable("Use a static constructor")));
  27. /**
  28. * Creates a new mutation queue for the given user, in the given LevelDB.
  29. *
  30. * @param user The user for which to create a mutation queue.
  31. * @param db The LevelDB in which to create the queue.
  32. */
  33. + (instancetype)mutationQueueWithUser:(const firebase::firestore::auth::User &)user
  34. db:(FSTLevelDB *)db
  35. serializer:(FSTLocalSerializer *)serializer;
  36. /**
  37. * Returns one larger than the largest batch ID that has been stored. If there are no mutations
  38. * returns 0. Note that batch IDs are global.
  39. */
  40. + (FSTBatchID)loadNextBatchIDFromDB:(leveldb::DB *)db;
  41. @end
  42. NS_ASSUME_NONNULL_END