Commit Graph
217 Commits
Author SHA1 Message Date
Paul Beusterien 83e898ab5c One Firebase version (#6634) 2020-10-02 12:26:22 -07:00
Konstantin Varlamov 2311c36dbc Integrate Firestore with Firebase platform logging (#6507)
The sample user agent string I'm getting in XCode is `apple-platform/ios apple-sdk/17E8258 fire-fst/1.17.1 fire-ios/6.10.2 swift/true xcode/11E503a`.
2020-09-25 15:47:20 -04:00
Brian Chen 21921e9851 Add != and notIn support (#6418) 2020-09-15 16:12:44 -05:00
Konstantin Varlamov 160f21a6ca Make the language reported via headers configurable (#6264) 2020-08-14 15:21:43 -04:00
Denver Coneybeare ffe23884da Add #include for config.h to get the value for HAVE_LIBDISPATCH (#6041) 2020-07-14 15:38:18 -04:00
Gil ea71423c09 Avoid deadlock during shutdown on Linux/Windows (#5920)
* Avoid deadlock during shutdown on Linux/Windows

Under some circumstances, the Executor can be accessed by a user task
that's running during shutdown.

* Fix running with HAVE_LIBDISPATCH=0 on macOS
2020-06-25 17:56:16 -07:00
Paul Beusterien e15724a436 Migrate from interop pods to source_files header access (#5760) 2020-06-09 06:09:27 -07:00
Paul Beusterien d4621a636f Use preserve_paths instead of CocoaPods private (#5758) 2020-06-09 05:21:28 -07:00
Gil 7a58eba2e5 Remove firebase/firestore from paths in Firestore/core (#5374)
* Manual Xcode project fixups

* Remove `firebase/firestore` from paths in Firestore/core

This renames all Firestore files under `Firestore/core` to remove the
interior `firebase/firestore` directory structure. This is motivated by
build failures under Windows where the filenames of intermediates were
too long.

Concretely:

  * `Firebase/core/src/firebase/firestore` becomes `Firebase/core/src`
  * `Firebase/core/test/firebase/firestore` becomes
    `Firebase/core/test/unit`

Moving the tests into a `unit` subdirectory aligns Firestore with the
directory structure in
[AddNewPod](https://github.com/firebase/firebase-ios-sdk/blob/master/AddNewPod.md),
modified for C++ (see discussion in #3224).
2020-04-20 14:57:34 -07:00
Gil 74f4ceb4c9 Fix unused variable warnings (#5389)
* Fix unused variable warnings

These are now exposed because libprotobuf is no longer polluting the
compiler command-line with -Wno-unused-parameter.

* Convert (void)var to __unused where possible
2020-04-20 14:23:36 -07:00
Gil 77f92cd2c6 Stop using built-in CMake Framework support (#5316)
* Fix previously unknown warnings

These become visible once flags are handled uniformly across all
Firestore targets in an upcoming build change.

* Stop using built-in CMake Framework support

CMake has built-in support for building Framework bundles (briefly:
bundles of libraries, associated headers, and resources) but this
doesn't work well for our needs.

1. In CMake 3.5.1 (our earliest supported CMake version) it doesn't copy
headers properly at build time.

2. Even up to CMake 3.15.5, CMake doesn't handle link-line multiplicity
correctly. CMake passes the static library location within the framework
and this seems to cause the linker to mishandle Objective-C metaclass
information resulting in duplicate symbols. Building with `-framework`
flags works correctly.

Previously we partially worked around the latter problem by building
some frameworks as shared instead of static frameworks, but this is
problematic because this mode of operation isn't actually intended and
is unsupported as far as the rest of Firebase is concerned. This turned
out to be fragile though and while refactoring libraries this workaround
broke.

Rather than piling on additional workarounds, this change converts the
frameworks to simple library targets and emulates framework imports
through include paths.

Additionally, this starts refactoring our cmake helper functions to make
them more like built-in functions. This makes it possible to freely use
different CMake features that were made difficult by trying to wrap
everything up in a single CMake command.

* style.sh generated changes

* Review feedback

* More review feedback
2020-04-14 08:40:33 -07:00
Gil d9b7a33f0c Use forward declarations instead of IWYU (#4868)
* Remove rarely used template argumnets from SortedMap/SortedSet

* Remove unused STATUS_CHECK_OK

* Rename QuerySnapshot::Listener to QuerySnapshotListener

This makes the type something that can be forward declared.

* Rename DocumentSnapshot::Listener to DocumentSnapshotListener

This makes the type something that can be forward declared.

* Rename ViewSnapshot::Listener to ViewSnapshotListener

This makes the type something that can be forward declared.

* Put most QueryListener implementation in .cc

* Actually use sync_engine_callback.h

* Add forward declaration headers for api, core, and model

These centralize forward declarations, including declarations for some
hard-to-forward-declare types.

* Move includes of hard_assert.h out of other headers

* Make testutil definitions out of line

* Move definitions out-of-line

* Move DocumentKey definitions out-of-line

* Move definitions out-of-line

* Shorten unnecessarily long namespace usages

* Use default destructors where possible

* Delete unused MutationBatch::kUnknown constant

* Use forward declarations instead of IWYU

* Misc fixups from Linux/GCC 9.2.1

* Fix testutil under VS 2017

Forward declarations of functions local to a function body end up
generating unresolved externals. Reduce most of these back to just
calling FieldValue::FromX methods.
2020-02-15 14:34:38 -08:00
Gil 904c1835a5 Prep for forward declarations (#4859)
* Remove rarely used template argumnets from SortedMap/SortedSet

* Remove unused STATUS_CHECK_OK

* Rename QuerySnapshot::Listener to QuerySnapshotListener

This makes the type something that can be forward declared.

* Rename DocumentSnapshot::Listener to DocumentSnapshotListener

This makes the type something that can be forward declared.

* Rename ViewSnapshot::Listener to ViewSnapshotListener

This makes the type something that can be forward declared.

* Put most QueryListener implementation in .cc

* Actually use sync_engine_callback.h
2020-02-10 14:44:10 -08:00
Gil 7f84e84bf9 Fixes for issues discovered in the Unity desktop build (#4795)
* Make Filesystem's destructor virtual

* Avoid capturing a strong reference to FirestoreClient in GC tasks.

This prevents this task from keeping the FirestoreClient alive even
after the api::Firestore instance has been destroyed.

* Ensure that FirestoreClient is terminated

In the public C++ API, it's possible to delete the owning FirebaseApp
which triggers the destruction of the api::Firestore object even though
we haven't called Terminate.

This makes it such that api::Firestore calls a blocking Terminate call
on FirestoreClient in its destructor.

Additionally, change AsyncQueue to always run the operation enqueued on
shutdown, even if already shutdown. Make FirestoreClient capable of
short circuiting the termination work for itself. This makes terminate
idempotent in a more staightforward way.

* Clean up excess logging

* Remove defintion of weak_from_this

* Review feedback

* Make AsyncQueue extend std::enable_shared_from_this

Also hide the AsyncQueue's public constructor and force all users to
manage their reference to it via std::shared_ptr.

* Handle Executor shutdown from within its own pool
2020-02-04 13:38:59 -08:00
Gil 6cc1a449ea Clean up Objective-C interop and other dead code (#4601)
* Remove unused -[FIRFirestore isLoggingEnabled]

Use util::LogIsLoggable(util::kLogLevelDebug) directly.

* Remove objc_compatibility.h

* Remove/cleanup unused #if __OBJC__ blocks

* Remove dead code

* Remove MakeNSStringNoCopy

* Remove worthless include

* Tidy up FIRFirestore

* Remove dead code and use forward declarations in FSTHelpers

* Minor fixes for LevelDbTransaction:

  * Make methods const where possible
  * Make key() and value() return const std::string&, allowing callers
    to create their own const references

* Remove Comparator<NSString*>
2020-01-08 18:40:29 -08:00
wu-hui 14e28121e2 Release LimitToLast (#4616)
* [1/4] Split Query and Target, and make LocalStore/RemoteStore work with Target. (#4413)

* [2/4]LimitToLast: Make SyncEngine work with Target (#4491)

* [3/4] Implement LimitToLast (#4505)
2020-01-08 09:04:28 -08:00
Gil 9a4f4e73c7 Miscellaneous fixes (#4584)
* Fix use after move in LevelDbPersistenceForTesting

* Fix size-related errors when compiling in 32-bit mode

* Fix test-only memory leaks

* Fix test-only memory leaks

* Prevent spec tests from appearing to leak

The spec tests aren't actually leaking, but they accumulate enough
garbage without clearing the autorelease pool that Instruments
complains.

* Avoid temporaries in methods that @throw

ARC does not release temporaries when an Objective-C exception is
thrown. Use C++ equivalents directly to avoid leaks as detected by
Instruments.

* Fix memory leak in acknowledge mutation

Any previous value must be freed before the next one is assigned.

* Manually implement assignment operators in ByteString

The single by-value implementation wasn't preventing the compiler
generated standard versions from being generated which was causing
leaks.

* Prevent leaking GrpcCompletions that complete after Shutdown

After shutdown, the AsyncQueue silently drops Enqueue requests which
prevents these blocks from being deleted.

* Avoid racing with enqueued operations

It's possible for the Executor to immediately execute the given block,
at which point the block might observe the async queue in a
not-shutting-down state.
2020-01-08 07:11:05 -08:00
Gil 16447a5e2b Restrict use of Abseil types in public C++ accessible APIs (#4503)
* Change string parameters from absl::string_view to std::string

No abseil types can be used as parameters in this package.

This fixes an issue where Unity builds fail due to missing symbols.

The underlying issue is that Abseil in CocoaPods is an LTS release and
LTS releases contain an inline namespace, making types like
absl::string_view link as absl::lts_2019_08_08::string_view. When
compiling Firestore in google3 it uses the abseil in //third_party/absl,
which is not an LTS release and does not include the inline namespace.
This disagreement causes issues for the public C++ API which is compiled
in google3 and consumes code in the API package.

* Avoid absl::any in interfaces shared with public C++

* Make resource-related methods class members

This gives them access to private methods of friends of Serializer.

* Access control FieldPath/ResourcePath construction

* Access control Document construction

* Access control FieldValue construction

* Access control TransformOperation methods

* Remove DocumentSnapshot constructor that takes metadata pieces individually

* Restrict access to DocumentSnapshot from optional<Document>

* Add comments indicating how Abseil types are restricted

* Make DocumentKey::FromPathString take std::string
2019-12-17 11:32:48 -08:00
Gil e6a4905336 Add concurrent execution support to Executor (#4309) 2019-11-15 09:34:44 -08:00
Brian Chen 0170957544 Allow querying for arrays in IN queries (#4285) 2019-11-12 13:07:58 -08:00
Morgan Chen 9a611a859d Update header docs based on feedback in cr/278458897 (#4235)
* Update header docs based on feedback in cr/278458897

* Change param names in .mm to match header file
2019-11-05 13:01:45 -08:00
Brian Chen 251a70f26a Make IN queries publicly available (#4174) 2019-10-29 14:13:02 -07:00
Brian Chen 441d7eda8b Change id to NSArray<id> for IN queries (#4182) 2019-10-28 22:22:37 -07:00
Konstantin Varlamov 0f2a0bfeef Use C++ serializer for communicating with the backend (#4013)
Replace all uses of `FSTSerializerBeta` in `remote_objc_bridge.{h,mm}` with the C++ `Serializer`. Also, make most of `remote/` sources pure C++ and remove no-longer-used methods in `FSTSerializerBeta`. All integration tests pass, under Address Sanitizer as well.

Unfortunately, pretty-printing is still delegated to Objective-C, so that `remote_objc_bridge.mm` still has to be an Objective-C++ source (and which prevents inlining `remote_objc_bridge` into the streams).

#no-changelog Will add a changelog entry when local serializer is ported, too.
2019-10-18 17:58:14 -04:00
Gil cd460eca2d Rationalize input validation exceptions and assertion failures (#4107)
* Rationalize input validation exceptions and assertions

... under a single ThrowHandler concept. This makes it possible to set
an alternative ThrowHandler in our C# bindings that properly translates
input validation exceptions to the correct .NET exception types.

* Rename api/input_validation.h to util/exception.h

* Reimplement util/hard_assert.h in terms of util/exception.h
2019-10-18 12:58:45 -07:00
Brian Chen bca8785e62 Move addSnapshotsInSyncListener to public (#3968) 2019-10-01 14:32:30 -07:00
Brian Chen 6495dca55c Move snapshotsInSync to public (#3942) 2019-09-30 16:36:51 -07:00
Brian Chen 9d230de9c0 Adding onSnapshotsInSync (not public) (#3850) 2019-09-20 14:15:57 -04:00
Gil 538cdfd10f Clean up Objective-C remnants (#3866)
* Remove references to removed classes

* Remove references to FSTSyncEngine

* Fix references to Objective-C names that are no longer valid.

* Remove forward declarations to classes that don't exist

* Remove FSTTypes.h

* Remove usages of headers that no longer apply

* Clean up header imports

* Remove traces of Objective-C from api/firestore.{h,mm}

* Strip NS_ASSUME_NONNULL directives that don't apply

* Remove FSTSyncEngine.h
2019-09-18 10:06:35 -07:00
Brian Chen f7028988b1 Split ListenerRegistration into QueryListenerRegistration (#3832) 2019-09-12 16:44:14 -07:00
Gil 6ad473ae04 Merge persistence-master to master (#3829)
* Port FSTMemoryPersistence to C++ (#3754)

* Add local::Persistence

* Add MemoryPersistence

* Add MemoryEagerReferenceDelegate

* Make LruDelegate extend ReferenceDelegate

This enables downcasting to LruDelegate in tests that need to do so.

* Add MemoryLruReferenceDelegate

* Don't double-count document key size.

* Port FSTLevelDB to C++ (#3755)

* Add LevelDbPersistence

Note that Apple-specific initialization has been partitioned off in
anticipation of being able to run this code on non-Apple platforms.

* Add LevelDbLruReferenceDelegate

* Migrate to C++ Persistence (1/2) (#3756)

* Use C++ Persistence classes in FSTLocalStore

* Remove ReferenceDelegateBridge

* Cut src over to C++ persistence types

* Remove Objective-C requirement from some classes

... that no longer require it.

* Migrate to C++ Persistence (2/2) (#3757)

* Remove LruDelegateBridge

* Update test initialization of persistence components

In particular, ensure that there's always an owner for the Persistence
instance, which wasn't always handled explicitly in the Objective-C
version of the tests.

* Largely mechanical changes to tests

* Remove Objective-C persistence classes

* Forward declare util::Status when possible (#3761)

* Add a header dedicated to forward declarations for util::Status

* Use status_fwd.h wherever possible
2019-09-12 14:28:10 -07:00
rsgowman ae3310317c Allow overriding of the default failure handler (#3793) 2019-09-10 17:14:15 -04:00
wu-hui c5b5a44603 Rename shutdown to terminate and publish it. (#3694)
* Rename shutdown to terminate and publish it.

* Addressing feedbacks
2019-08-27 11:51:01 -04:00
wu-hui 6bcf6ba58c publish waitForPendingWrites (#3690)
* publish waitForPendingWrites

* add change log

* move impl out of internal
2019-08-26 16:08:46 -04:00
wu-hui 7870c73b7c Port FSTFirestoreClient to C++ 2/2 (#3657)
* firestore_client + FSTFirestoreClient becomes delegate.

* fix comment

* addressing comment

* use new instead make_shared

* reformat

* Update references to firestore client

* Addressing comments#2

* addressing comments #3

* add std::move

* remove deleted header.

* fix cmake build error.
2019-08-26 15:48:18 -04:00
wu-hui adb93131fa Fix misplaced waitForPendingWrites (#3654)
* Fix misplaced waitForPendingWrites

* reformat
2019-08-22 15:02:30 -04:00
wu-hui ea3b589ac0 Port waitForPendingWrites (#3619)
* port waitForPendingWrites

* addressing comments #1

* remove commented line

* another change to disable network
2019-08-20 16:18:02 -04:00
Marek Gilbert cd8619b817 Merge branch 'firestore-master' 2019-08-16 10:09:38 -07:00
Michael Lehenbauer 6555e1cc7c Provide a helpful error if FIROptions.projectID is missing. (#3610) 2019-08-16 07:43:13 -07:00
Gil 22b9c9006b Convert TransformOperations to polymorphic value types (#3567)
* Rename transform_operation{s,}

* Convert TransformOperation to a polymorphic value class

* fixup! Convert TransformOperation to a polymorphic value class

* Remove ServerTimestampTransform::Get
2019-08-16 07:23:57 -07:00
Gil 9c35050270 Migrate FSTMutation to C++ Mutations (#3564)
* Nontrivial edits

* Mostly mechanical edits

* Remove FSTMutation
2019-08-14 23:18:47 -07:00
Gil 0c23f38397 Migrate Objective-C document types to C++ (#3531)
* Rewrite Document-related classes as a polymorphic value type

* Pass ObjectValue without rvalue references

* Rename HasLocalMutations

* Port C++ users to new Documents

* Port FSTDocumentTests to C++

* Port FSTDocumentSetTests to C++

* Migrate DocumentMap and DocumentSet to C++ Document

* Migrate test helpers

* Delete FSTDocumentSetTests

* Delete FSTDocumentTests

* Mechanical changes to use C++ Document

* Updates to the project file

* Nontrivial test updates

* Remove FSTTestDeletedDoc

* Remove FSTTestUnknownDoc

* Remove FSTDocument

* Convert usage of FSTDocument to C++ Document

* Fix Serializer usage of Documents
2019-08-13 13:59:00 -07:00
Gil 92cd10913f A grab bag of misc fixes (#3526)
* Remove last traces of FSTObjectValue

* Fix typos

* Add ToString to SnapshotVersion

* Add support for hashing enums and optionals
2019-08-07 21:28:50 -07:00
Hui-Wu 902d9fe4c5 Port public shutdown (#3467)
* async_queue shutdown ready

* shutdown feature complete. need to fix shared_ptr for credprovider and stop executor leakage.

* stop executor leakage.

* Improved comments without shared_from_this

* shared_ptr everywhere!

* undo scheme change

* addressing comments #1

* addressing comments

* addressing comments #3
2019-08-06 20:33:08 -04:00
Brian Chen 86b09fa469 Add IN and ARRAY_CONTAINS_ANY (not publicly exposed) (#3492) 2019-08-05 11:47:06 -07:00
Gil 13a1b33913 Migrate from FSTQuery to C++ Query (#3484) 2019-08-02 11:35:33 -07:00
Gil 2f22dce569 Reimplement C++ Query with AppendOnlyList (#3483)
* Reimplement C++ Query with AppendOnlyList

* Fix missing assignment to last_document (!!!)

* Refer to filters as std::shared_ptr<const Filter>
2019-08-02 09:14:10 -07:00
Gil bef89668f0 Migrate FSTBound to C++ Bound (#3478)
* Port FSTBound to C++ Bound

* Add limit and Bound to Query

* Migrate FSTBound to C++ Bound, also limits
2019-08-01 12:58:53 -07:00
Gil 561325300b Port FSTSortOrder to C++ OrderBy (#3468)
* Port FSTSortOrder to C++ OrderBy

* Finish port of C++ Direction from Android

* Reimplement FSTSortOrder with C++ OrderBy

* Migrate FSTSortOrder to C++ OrderBy

* Remove FSTSortOrder

* Compare OrderBy equality in C++ Query
2019-07-31 15:39:38 -07:00
Brian Chen b9113f500e Only retry transactions on non-permanent errors (#3443) 2019-07-27 09:46:42 -07:00