Skip to content

Commit 9a874a7

Browse files
committed
Merge remote-tracking branch 'origin/master' into ghm
2 parents cf213db + 2b8eb5a commit 9a874a7

22 files changed

+61
-50
lines changed

app/src/include/firebase/internal/future_impl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ inline FutureBase::FutureBase(detail::FutureApiInterface* api,
204204
const FutureHandle& handle)
205205
: api_(api), handle_(handle) {
206206
api_->ReferenceFuture(handle_);
207+
// Once the FutureBase has reference, we don't need extra handle reference.
208+
handle_.Detach();
207209
detail::RegisterForCleanup(api_, this);
208210
}
209211

app/src/reference_counted_future_impl.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -701,10 +701,9 @@ bool ReferenceCountedFutureImpl::IsReferencedExternally() const {
701701
}
702702
for (int i = 0; i < last_results_.size(); i++) {
703703
if (last_results_[i].status() != kFutureStatusInvalid) {
704-
// If the status is not invalid, this entry is using up 2 references,
705-
// one for the Future and one for the FutureHandle it holds.
704+
// If the status is not invalid, this entry is using up a reference.
706705
// Count up the internal references.
707-
internal_references += 2;
706+
internal_references++;
708707
}
709708
}
710709
// If there are more references than the internal ones, someone is holding

cmake/external/firestore.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ if(TARGET firestore)
1818
return()
1919
endif()
2020

21-
set(version Firestore-1.13.0)
21+
# Pin to the first revision that includes these changes:
22+
# https://github.com/firebase/firebase-ios-sdk/pull/5807.
23+
#
24+
# This should be released with the next version after Firestore-1.15.0.
25+
set(version 05026f3df92cdee7b91fccc72a7195be2618acdf)
2226

2327
ExternalProject_Add(
2428
firestore

firestore/src/android/document_reference_android.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ class DocumentReferenceInternal
167167
* only DocumentSnapshot.getMetadata() changed) should trigger snapshot
168168
* events.
169169
* @param[in] callback function or lambda to call. When this function is
170-
* called, snapshot value is valid if and only if error is Error::kOk.
170+
* called, snapshot value is valid if and only if error is Error::kErrorOk.
171171
*
172172
* @return A registration object that can be used to remove the listener.
173173
*

firestore/src/android/event_listener_android.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void EventListenerInternal::DocumentEventListenerNativeOnEvent(
5757
reinterpret_cast<EventListener<DocumentSnapshot>*>(listener_ptr);
5858
Error error_code =
5959
FirebaseFirestoreExceptionInternal::ToErrorCode(env, error);
60-
if (error_code != Error::kOk) {
60+
if (error_code != Error::kErrorOk) {
6161
listener->OnEvent(DocumentSnapshot{}, error_code);
6262
return;
6363
}
@@ -79,7 +79,7 @@ void EventListenerInternal::QueryEventListenerNativeOnEvent(
7979
reinterpret_cast<EventListener<QuerySnapshot>*>(listener_ptr);
8080
Error error_code =
8181
FirebaseFirestoreExceptionInternal::ToErrorCode(env, error);
82-
if (error_code != Error::kOk) {
82+
if (error_code != Error::kErrorOk) {
8383
listener->OnEvent(QuerySnapshot{}, error_code);
8484
return;
8585
}
@@ -100,7 +100,7 @@ void EventListenerInternal::VoidEventListenerNativeOnEvent(JNIEnv* env,
100100
EventListener<void>* listener =
101101
reinterpret_cast<EventListener<void>*>(listener_ptr);
102102

103-
listener->OnEvent(Error::kOk);
103+
listener->OnEvent(Error::kErrorOk);
104104
}
105105

106106
/* static */

firestore/src/android/firebase_firestore_exception_android.cc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,16 @@ METHOD_LOOKUP_DEFINITION(illegal_state_exception,
5151
Error FirebaseFirestoreExceptionInternal::ToErrorCode(JNIEnv* env,
5252
jobject exception) {
5353
if (exception == nullptr) {
54-
return Error::kOk;
54+
return Error::kErrorOk;
5555
}
5656

5757
// Some of the Precondition failure is thrown as IllegalStateException instead
5858
// of a FirebaseFirestoreException. So we convert them into a more meaningful
5959
// code.
6060
if (env->IsInstanceOf(exception, illegal_state_exception::GetClass())) {
61-
return Error::kFailedPrecondition;
61+
return Error::kErrorFailedPrecondition;
6262
} else if (!IsInstance(env, exception)) {
63-
return Error::kUnknown;
63+
return Error::kErrorUnknown;
6464
}
6565

6666
jobject code = env->CallObjectMethod(
@@ -72,8 +72,9 @@ Error FirebaseFirestoreExceptionInternal::ToErrorCode(JNIEnv* env,
7272
env->DeleteLocalRef(code);
7373
CheckAndClearJniExceptions(env);
7474

75-
if (code_value > Error::kUnauthenticated || code_value < Error::kOk) {
76-
return Error::kUnknown;
75+
if (code_value > Error::kErrorUnauthenticated ||
76+
code_value < Error::kErrorOk) {
77+
return Error::kErrorUnknown;
7778
}
7879
return static_cast<Error>(code_value);
7980
}
@@ -87,7 +88,7 @@ std::string FirebaseFirestoreExceptionInternal::ToString(JNIEnv* env,
8788
/* static */
8889
jthrowable FirebaseFirestoreExceptionInternal::ToException(
8990
JNIEnv* env, Error code, const char* message) {
90-
if (code == Error::kOk) {
91+
if (code == Error::kErrorOk) {
9192
return nullptr;
9293
}
9394
// FirebaseFirestoreException requires message to be non-empty. If the caller

firestore/src/android/promise_android.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,18 @@ class Promise {
8686
return;
8787
}
8888

89-
Error error_code = Error::kUnknown;
89+
Error error_code = Error::kErrorUnknown;
9090
switch (result_code) {
9191
case util::kFutureResultFailure:
9292
// When failed, result is the exception raised.
9393
error_code = FirebaseFirestoreExceptionInternal::ToErrorCode(
9494
this->firestore_->app()->GetJNIEnv(), result);
9595
break;
9696
case util::kFutureResultCancelled:
97-
error_code = Error::kCancelled;
97+
error_code = Error::kErrorCancelled;
9898
break;
9999
default:
100-
error_code = Error::kUnknown;
100+
error_code = Error::kErrorUnknown;
101101
FIREBASE_ASSERT_MESSAGE(false, "unknown FutureResult %d",
102102
result_code);
103103
break;
@@ -130,10 +130,10 @@ class Promise {
130130
PublicT future_result = FirestoreInternal::Wrap<InternalT>(
131131
new InternalT(this->firestore_, result));
132132

133-
this->impl_->CompleteWithResult(this->handle_, Error::kOk,
133+
this->impl_->CompleteWithResult(this->handle_, Error::kErrorOk,
134134
/*error_msg=*/"", future_result);
135135
if (this->completion_ != nullptr) {
136-
this->completion_->CompleteWith(Error::kOk, /*error_message*/ "",
136+
this->completion_->CompleteWith(Error::kErrorOk, /*error_message*/ "",
137137
&future_result);
138138
}
139139
delete this;
@@ -146,9 +146,9 @@ class Promise {
146146
using CompleterBase<void>::CompleterBase;
147147

148148
void SucceedWithResult(jobject result) override {
149-
this->impl_->Complete(this->handle_, Error::kOk, /*error_msg=*/"");
149+
this->impl_->Complete(this->handle_, Error::kErrorOk, /*error_msg=*/"");
150150
if (this->completion_ != nullptr) {
151-
this->completion_->CompleteWith(Error::kOk, /*error_message*/ "",
151+
this->completion_->CompleteWith(Error::kErrorOk, /*error_message*/ "",
152152
nullptr);
153153
}
154154
delete this;

firestore/src/android/transaction_android.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ DocumentSnapshot TransactionInternal::Get(const DocumentReference& document,
142142
return DocumentSnapshot{};
143143
} else {
144144
if (error_code != nullptr) {
145-
*error_code = Error::kOk;
145+
*error_code = Error::kErrorOk;
146146
}
147147
if (error_message != nullptr) {
148148
*error_message = "";

firestore/src/common/futures.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Future<T> CreateFailedFuture(
1818
ReferenceCountedFutureImpl* ref_counted_future_impl) {
1919
SafeFutureHandle<T> handle = ref_counted_future_impl->SafeAlloc<T>();
2020
ref_counted_future_impl->Complete(
21-
handle, Error::kFailedPrecondition,
21+
handle, Error::kErrorFailedPrecondition,
2222
"This instance is in an invalid state. This could either because the "
2323
"underlying Firestore instance has been destructed or because you're "
2424
"running on an unsupported platform. Currently the Firestore C++/Unity "

firestore/src/include/firebase/csharp/snapshots_in_sync_listener.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ ListenerRegistration SnapshotsInSyncListener::AddListenerTo(
1818
SnapshotsInSyncListener listener(callback_id, callback);
1919

2020
return firestore->AddSnapshotsInSyncListener(
21-
[listener]() mutable { listener.OnEvent(Error::kOk); });
21+
[listener]() mutable { listener.OnEvent(Error::kErrorOk); });
2222
}
2323

2424
} // namespace csharp

0 commit comments

Comments
 (0)