Commit Graph
54 Commits
Author SHA1 Message Date
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 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
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 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
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 b9113f500e Only retry transactions on non-permanent errors (#3443) 2019-07-27 09:46:42 -07:00
Gil 3b496318f4 Implement collection groups in C++ Query (#3327)
* Add a test that verifies canonical IDs don't change

* Remove Query::AtPath

This has no parallel in Typescript or Java implementations.

* Add util::Equals

... for comparing pointers by the thing to which they point.

* Use std::shared_ptr<const std::string> for collection group IDs

* Reorder/Cleanup C++ Query to match Android

* Add collection group to C++ Query
2019-07-11 15:59:35 -07:00
Gil 07b5eadf5a Rename WrapNSString to MakeNSString (#3274)
This makes it match the convention we've established for other
converters of this type. WrapNSString was perhaps the earliest of these
that we wrote and the convention hadn't yet been established.
2019-06-27 17:31:17 -07:00
Brian Chen 840ab65a69 Expose clearPersistence() publicly (#3026) 2019-06-05 16:25:09 -07:00
Gil 220589d9bc Port FIRCollectionReference to C++ (#3126)
Also fix up DocumentReference to use it.
2019-06-04 18:10:17 -07:00
Gil 8770828dd8 Refactor usages of DatabaseId to avoid raw pointers (#3041)
* Remove stale references to DatabaseId
* Have Firestore take the DatabaseId directly
* Allow tests to default the database implicitly
* Have FSTSerializerBeta take DatabaseId by value
* Have FSTUserDataConverter take DatabaseId by value
* Make FIRFirestore.databaseID a const reference
* Make FSTFirestoreClient.databaseID a const reference
* Have FSTReferenceValue take DatabaseId by value
* Have DatabaseInfo take DatabaseId by value
* Have Serializer take DatabaseId by value
* Fix C++ ReferenceValue
  * Take DatabaseId by value
  * Reverse order to match Android
  * Rename `reference` to `key`
2019-05-21 20:28:51 -07:00
Brian Chen afe63ccff5 Add clearPersistence() to Firestore client(#2993) 2019-05-17 11:29:20 -07:00
Brian Chen 570f4465de Use shared_ptr for AsyncQueue and Executor (#2996) 2019-05-15 09:55:18 -07:00
Gil fc1ebb808a Remove unused FIRFirestore instances dictionary (#2937)
This was copied into FSTFirestoreComponent but never removed.
2019-05-06 09:00:47 -07:00
Gil bef0dfb69e use portable util/log.h instead of FIRLogger (#2915) 2019-05-01 11:03:28 -07:00
Michael Lehenbauer 27b2f0a19c Port FIRWriteBatch. (#2844)
* Create api::WriteBatch "port" of FIRWriteBatch.
* Make FIRWriteBatch a wrapper around an api::WriteBatch (and a FSTUserDataConverter for parsing input).
2019-04-18 10:34:53 -07:00
Gil cad35b18d8 Migrate api::Firestore completions to C++ (#2831)
* Make error_apple definitions out-of-line

* Add util::MakeCallback

Translates between API completion handlers that take just an NSError and
the equivalent std::function that accepts util::Status.

* Port DocumentReference::Completion to a std::function callback

* Port Firestore::ErrorCompletions to StatusCallback

* Port transaction-related completions to C++

* Remove now-unused FSTVoidIDErrorBlock

* Fix tunneling of Firestore-generated NSErrors.

Remove MakeStatus(NSError*) because it has different results from
Status::FromNSError. Ensure that user-supplied errors created in
transactions tunnel through correctly.
2019-04-16 17:37:38 -07:00
Michael Lehenbauer a3c5064797 Use shared_ptr<Firestore> instead of Firestore* for api:: classes. (#2830)
This is safer and better matches our design (and the other platforms), since
classes like api::DocumentReference will have references to api::Firsetore but
the lifetime is controlled by the developer, not us.
2019-04-15 09:06:10 -07:00
Michael Lehenbauer 6dca5e601c Port FirestoreSettings to C++. (#2804)
* Creates a C++ api::Settings class as a container for the settings we pass
  into the core client.
* Adds [FIRFirestoreSettings internalSettings] to convert from public API
  settings to api::Settings.

Input validation, etc. still happens in FIRFirestoreSettings.
2019-04-14 12:28:22 -07:00
Gil 58205aa513 Tunnel underlying NSErrors through C++ Status (#2808)
* Tunnel underlying NSErrors through Status

* Make FIRFirestoreErrorDomain available to CMake builds

The prior state was actually semi-broken. The
firebase_credentials_provider_apple definition wasn't extern "C" so it
was defining the value in addition to whatever FIRFirestore was doing.

FIRFirestore's value isn't available to straight C++ though, so this
change pushes the definition down into error_apple.mm so that it can be
shared by the Objective-C API and MakeNSError.

Pushing MakeNSError up into the API layer isn't practical yet so this
change is a compromise that makes things work
2019-04-12 12:47:56 -07:00
Michael Lehenbauer 09010cfba0 Fix a couple small issues I tripped over today. (#2806)
* Fix a couple small issues I tripped over today.

1. Fix primeBackend so it uses an isolated FIRFirestore* instance. I ran into
   an issue where tests that try to change .settings would fail if they were the
   very first test run, since primeBackend had already configured the client and
   so settings could no longer be changed.
2. Remove FIRFirestore.client and make api::Firestore.client() assert client is configured.
2019-04-11 10:40:56 -07:00
Gil 47bd60a7d0 Move collectionGroup method out of the Internal category (#2802)
This prevents a warning for end users.
2019-04-10 17:32:49 -07:00
Gil 2e8b9181fa Port FSTUsageValidation to C++ (#2670)
* Port FSTUsageValidation to C++

* Add an error log level
2019-03-28 13:19:28 -07:00
Gil 38496c450c Add DelayedConstructor<T> (#2579)
* Add util::DelayedConstructor

* Run sync_project on any Firestore change since start

* Use DelayedConstructor in a few places to show how it works
2019-03-20 10:29:02 -07:00
Konstantin Varlamov 0643b36aef C++ migration: make FIRFirestore implementation delegate to core API (#2492) 2019-03-15 16:10:32 -07:00
Michael Lehenbauer bd0b8e9449 Collection Group Query Internals (#2378)
Includes the new index and all internals for collection group queries, but the public API will not be exposed until backend support is ready.
2019-03-08 13:37:00 -08:00
Konstantin Varlamov c422806d8e C++ migration: port FSTTransaction (#2362) 2019-02-11 19:12:52 -05:00
Michael Lehenbauer 5c67653de3 Change timestampsInSnapshots default to true and deprecate the setting. (#2251) 2019-01-11 13:47:13 -08:00
Paul Beusterien 7c53489e03 Travis to Xcode 10.1 and clang-format to 8.0.0 (tags/google/stable/2018-08-24) (#2222)
* Travis to Xcode 10.1
* Update to clang-format 8
* Update clang-format homebrew link
* Work around space in filename style.sh issue
2019-01-02 09:27:31 -08:00
Greg Soltis 305f87215e Wire together LRU GC (#1905)
* Wire together LRU GC
* Default enabled, threshold set to `100 MB`.
2018-11-26 14:33:28 -08:00
Konstantin Varlamov e0d797515c C++: eliminate FSTDispatchQueue and replace it with AsyncQueue (#2062)
* replace all references to `FSTDispatchQueue` and `FSTTimerID` with their C++ equivalents;
* remove `FSTDispatchQueue` class and related tests;
* in method argument names, replace `workerDispatchQueue` with just `workerQueue`, more similar to other platforms;
* move `Executor` and derived classes out of `internal` namespace.
2018-11-18 17:49:32 -05:00
Gil 16f7be5864 Migrate nearly all usages of MakeStringView to MakeString (#1679) 2018-08-13 15:23:58 -07:00
Gil 15ef78f090 Replace uses of absl::string_view in constructor parameters with std::string (#1676)
* Add a MakeStringView benchmark

Turns out this is worse than just creating a std::string:

BM_MakeString             29 ns         29 ns  189065849
BM_MakeStringView         59 ns         59 ns   93013367

* Convert database_id to take std::string

* Convert DatabaseInfo to take std::string

* Convert User to take std::string

* Convert Token to take std::string

* Convert MakeStringView([NSString stringWithFormat:]) to StringFormat
2018-08-13 11:02:28 -07:00
Ryan Wilson 7c56bb7c03 Move Firestore to Auth interop library. (#1525)
* Move Firestore to Auth interop library.

* Fixed TODO with no name.

* Extract interop into separate class.

* Further Firestore interop changes.

* Move auth instance to constructor of CredentialsProvider.

* Resolved travis failures.

* Create separate queue for FIRApp instances, remove dead test code.

* Add missing <string> import.
2018-07-25 13:19:53 -04:00
Gil 03d26a76a0 Remove nearly all usages of WrapNSStringNoCopy (#1351) 2018-05-30 10:24:40 -07:00
Gil 8037a4bf79 Replace Objective-C assertions with C++ assertions (#1327)
* Migrate FSTFail to HARD_FAIL
* FSTCFail -> HARD_FAIL
* FSTCAssert -> HARD_ASSERT
* FSTAssert -> HARD_ASSERT
* Replace FSTAssert with NSAssert in dead Objective-C code
* Remove FSTAssert.h
2018-05-24 11:00:23 -07:00
Gil af19a1b072 Reimplement C++ logging (#1313)
* Add direct support for formatting Objective-C objects
* Rewrite log.h
* Convert FSTWarn to LOG_WARN
* Convert FSTLog to LOG_DEBUG
* Remove FSTLogger
2018-05-23 07:00:05 -07:00
Gil 23f8320148 Directly validate collection and document paths (#1316)
... instead of relying on HARD_ASSERTS in resource_path.cc to catch
them.

This fixes an integration test broken in #1304.
2018-05-22 21:39:45 -07:00
Konstantin Varlamov edd6f60a73 Firestore: use C++ Executor for user queue. (#1238)
FSTDispatchQueue enforces serial execution, which is inappropriate for
user queue, because a user may configure usage of a concurrent queue in
settings, breaking FSTDispatchQueue invariants. Instead, use C++
ExecutorLibdispatch directly.
2018-05-10 20:16:50 -04:00
Gil 0a66187053 Add lint checking for Objective-C++ sources (#1048)
* lint.sh now lints Objective-C++ too

* cpplint checks system-style includes that should be user-style

This prevents it from recognizing project sources as if they were C
system headers and then complaining that they're in the wrong place.

* cpplint checks #imports and #includes

* cpplint checks that C++ system headers aren't #imported

* cpplint checks for C system headers that could be C++ system headers

* cpplint checks that Objective-C sources include their headers
2018-04-09 11:54:39 -07:00
Konstantin Varlamov a17740e914 Add a flag to control whether DocumentSnapshots return Dates or Timestamps for timestamp fields (#831)
* add a new property `timestampsInSnapshotsEnabled` to `FirestoreSettings`, `false` by default;
* add a verbose warning message urging users to opt into the new behavior;
* set `timestampsInSnapshotsEnabled` to true in the integration tests to reduce the verbose console
spam during the test run and make sure the flag won't break anything once it's flipped.
2018-03-30 14:50:15 -04:00
zxu cb8c4b6b1f port C++ DocumentKey to the rest of Firestore code (#977)
* port C++ DocumentKey to API's and Core's

* address changes

* address changes

* fix Hash return types
2018-03-27 14:33:39 -04:00
zxu 9e815620e9 grand PR to port the remaining paths (FieldPath and ResourcePath). (#865)
* naively remove FSTPath import and source/test files.

* port FieldPath, part I

* port FieldPath, part II

* port ResourcePath, part I

* port ResourcePath, part II

* the grand commit to fix build errors

* use testutil:: helper instead of those from FSTHelpers

* fix test and lint

* use c_str in errmsg directly

* fix

* fix

* make code clean

* fix integration test I missed

* fix to avoid naming collision in preprocessor

* address changes

* address changes

* address changes

* fix: fieldMask are actually shared with different context.

* address changes

* address changes
2018-03-14 08:57:31 -04:00
zxu 3e7c062f3b replacing Auth by C++ auth implementation (#802)
* lazy replacing FST(Firebase)CredentialsProvider by (Firebase)CredentialsProvider

* lazy replacing FSTUser by User

* adding error-code parameter to TokenListener

* actually use const user& instead of pointer; also add an error util

* add HashUser and pass into the unordered_map

* use User in test

* use c++ CredentialsProvider and subclass in test

* fix unit test

* use explicit capture in lambda instead of capture all by reference

* cache currentUser explicitly when reset sync engineer test driver

* objc object should be captured by value in lambda

* replacing Auth/FSTUser by C++ auth implementation

* address changes

* replacing FSTGetTokenResult by C++ Token implementation

* address changes

* fix unintentional change in merging

* patch the change in objc Auth up-stream

* somehow, the lambda-version of set-user-change-listener does not work... fallback to block

* address changes

* fix another const& v.s. dispatch bug

* fix more const& v.s. dispatch bug  zxu123 committed

* fix a bad sync line

* address changes

* address change

* address change

* fix upstream change from merge

* fix upstream changes

* Suggested fixes for cpp/port_auth (#846)

* Get rid of MockDatastore factory

This avoids the need to statically allocate (and leak) a credentials
provider

* Use absl::make_unique

std::make_unique technically does not exist until C++14.

* #include <utility> for std::move

* Use std::future for the initial user

* fix style
2018-02-27 14:04:39 -05:00
Gil 935f3ca7d7 Avoid wrapping and rewrapping NSStrings when constructing DatabaseId (#833)
* Avoid wrapping and rewrapping NSStrings when constructing DatabaseId

* Shorten DatabaseId::kDefaultDatabaseId
2018-02-22 08:12:54 -08:00