FSTLevelDBMutationQueue.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. @protocol FSTGarbageCollector;
  24. NS_ASSUME_NONNULL_BEGIN
  25. /** A mutation queue for a specific user, backed by LevelDB. */
  26. @interface FSTLevelDBMutationQueue : NSObject <FSTMutationQueue>
  27. - (instancetype)init __attribute__((unavailable("Use a static constructor")));
  28. /** The garbage collector to notify about potential garbage keys. */
  29. @property(nonatomic, weak, readwrite, nullable) id<FSTGarbageCollector> garbageCollector;
  30. /**
  31. * Creates a new mutation queue for the given user, in the given LevelDB.
  32. *
  33. * @param user The user for which to create a mutation queue.
  34. * @param db The LevelDB in which to create the queue.
  35. */
  36. + (instancetype)mutationQueueWithUser:(const firebase::firestore::auth::User &)user
  37. db:(FSTLevelDB *)db
  38. serializer:(FSTLocalSerializer *)serializer;
  39. /**
  40. * Returns one larger than the largest batch ID that has been stored. If there are no mutations
  41. * returns 0. Note that batch IDs are global.
  42. */
  43. + (FSTBatchID)loadNextBatchIDFromDB:(std::shared_ptr<leveldb::DB>)db;
  44. @end
  45. NS_ASSUME_NONNULL_END