Skip to content

Commit ab5ecec

Browse files
committed
Merge remote-tracking branch 'origin/master' into ghm
2 parents 57d5ea6 + 5d83ee4 commit ab5ecec

File tree

12 files changed

+63
-15
lines changed

12 files changed

+63
-15
lines changed

Android/firebase_dependencies.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def firebaseDependenciesMap = [
2222
'analytics' : ['com.google.firebase:firebase-analytics:17.2.2'],
2323
'auth' : ['com.google.firebase:firebase-auth:19.2.0'],
2424
'database' : ['com.google.firebase:firebase-database:19.2.1'],
25-
'dynamic_links' : ['com.google.firebase:firebase-dynamic-links:19.0.0'],
25+
'dynamic_links' : ['com.google.firebase:firebase-dynamic-links:19.1.0'],
2626
'functions' : ['com.google.firebase:firebase-functions:19.0.2'],
2727
'instance_id' : ['com.google.firebase:firebase-iid:20.0.2'],
2828
'invites' : ['com.google.firebase:firebase-invites:17.0.0'],

app/invites_resources/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ android {
4646

4747
dependencies {
4848
implementation 'com.google.firebase:firebase-analytics:17.2.2'
49-
implementation 'com.google.firebase:firebase-dynamic-links:19.0.0'
49+
implementation 'com.google.firebase:firebase-dynamic-links:19.1.0'
5050
implementation project(':app:app_resources')
5151
}
5252

database/src/desktop/core/tree.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ class Tree {
535535
}
536536

537537
// The key of this element in the Tree. This will the eqivalent to the
538-
// std:;string stored in the children_ map in the parent Tree node.
538+
// std::string stored in the children_ map in the parent Tree node.
539539
std::string key_;
540540

541541
// The value stored at this location in the tree. A location in a tree is not

firestore/src/android/field_value_android.cc

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,7 @@ FieldValueInternal::FieldValueInternal(const uint8_t* value, size_t size)
112112
}
113113

114114
FieldValueInternal::FieldValueInternal(DocumentReference value)
115-
: Wrapper(firebase::Move(*value.internal_)),
116-
cached_type_(Type::kReference) {}
115+
: Wrapper(value.internal_), cached_type_{Type::kReference} {}
117116

118117
FieldValueInternal::FieldValueInternal(GeoPoint value)
119118
: cached_type_(Type::kGeoPoint) {
@@ -133,7 +132,8 @@ FieldValueInternal::FieldValueInternal(std::vector<FieldValue> value)
133132
jmethodID add_method = util::array_list::GetMethodId(util::array_list::kAdd);
134133
for (const FieldValue& element : value) {
135134
// ArrayList.Add() always returns true, which we have no use for.
136-
env->CallBooleanMethod(obj_, add_method, element.internal_->obj_);
135+
// TODO(b/150016438): don't conflate invalid `FieldValue`s and null.
136+
env->CallBooleanMethod(obj_, add_method, TryGetJobject(element));
137137
}
138138
CheckAndClearJniExceptions(env);
139139
}
@@ -148,7 +148,8 @@ FieldValueInternal::FieldValueInternal(MapFieldValue value)
148148
jobject key = env->NewStringUTF(kv.first.c_str());
149149
// Map::Put() returns previously associated value or null, which we have no
150150
// use for.
151-
env->CallObjectMethod(obj_, put_method, key, kv.second.internal_->obj_);
151+
// TODO(b/150016438): don't conflate invalid `FieldValue`s and null.
152+
env->CallObjectMethod(obj_, put_method, key, TryGetJobject(kv.second));
152153
env->DeleteLocalRef(key);
153154
}
154155
CheckAndClearJniExceptions(env);
@@ -345,6 +346,10 @@ DocumentReference FieldValueInternal::reference_value() const {
345346
FIREBASE_ASSERT(cached_type_ == Type::kReference);
346347
}
347348

349+
if (!obj_) {
350+
// Reference may be invalid.
351+
return DocumentReference{};
352+
}
348353
return DocumentReference{new DocumentReferenceInternal(firestore_, obj_)};
349354
}
350355

@@ -585,5 +590,9 @@ bool operator==(const FieldValueInternal& lhs, const FieldValueInternal& rhs) {
585590
return lhs.EqualsJavaObject(rhs);
586591
}
587592

593+
jobject FieldValueInternal::TryGetJobject(const FieldValue& value) {
594+
return value.internal_ ? value.internal_->obj_ : nullptr;
595+
}
596+
588597
} // namespace firestore
589598
} // namespace firebase

firestore/src/android/field_value_android.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ class FieldValueInternal : public Wrapper {
7070
static bool Initialize(App* app);
7171
static void Terminate(App* app);
7272

73+
static jobject TryGetJobject(const FieldValue& value);
74+
7375
static jobject delete_;
7476
static jobject server_timestamp_;
7577

firestore/src/android/wrapper.cc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Wrapper::Wrapper(jclass clazz, jmethodID method_id, ...) {
4747
Wrapper::Wrapper(const Wrapper& wrapper)
4848
: Wrapper(wrapper.firestore_, wrapper.obj_, AllowNullObject::Yes) {}
4949

50-
Wrapper::Wrapper(Wrapper&& wrapper)
50+
Wrapper::Wrapper(Wrapper&& wrapper) noexcept
5151
: firestore_(wrapper.firestore_), obj_(wrapper.obj_) {
5252
FIREBASE_ASSERT(firestore_ != nullptr);
5353
wrapper.obj_ = nullptr;
@@ -60,6 +60,14 @@ Wrapper::Wrapper() : obj_(nullptr) {
6060
FIREBASE_ASSERT(firestore_ != nullptr);
6161
}
6262

63+
Wrapper::Wrapper(Wrapper* rhs) : Wrapper() {
64+
if (rhs) {
65+
firestore_ = rhs->firestore_;
66+
FIREBASE_ASSERT(firestore_ != nullptr);
67+
obj_ = firestore_->app()->GetJNIEnv()->NewGlobalRef(rhs->obj_);
68+
}
69+
}
70+
6371
Wrapper::Wrapper(FirestoreInternal* firestore, jobject obj, AllowNullObject)
6472
: firestore_(firestore),
6573
// NewGlobalRef() is supposed to accept Null Java object and return Null,

firestore/src/android/wrapper.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Wrapper {
3737

3838
Wrapper(const Wrapper& wrapper);
3939

40-
Wrapper(Wrapper&& wrapper);
40+
Wrapper(Wrapper&& wrapper) noexcept;
4141

4242
virtual ~Wrapper();
4343

@@ -62,6 +62,9 @@ class Wrapper {
6262
// Java object a.k.a. nullptr.
6363
Wrapper(FirestoreInternal* firestore, jobject obj, AllowNullObject);
6464

65+
// Similar to a copy constructor, but can handle the case where `rhs` is null.
66+
explicit Wrapper(Wrapper* rhs);
67+
6568
// Converts a java list of java type e.g. java.util.List<FirestoreJavaType> to
6669
// a C++ vector of equivalent type e.g. std::vector<FirestoreType>.
6770
template <typename FirestoreType, typename FirestoreTypeInternal>
@@ -100,8 +103,8 @@ class Wrapper {
100103
FirestoreInternal* firestore, MapFieldPathValue::const_iterator begin,
101104
MapFieldPathValue::const_iterator end);
102105

103-
FirestoreInternal* firestore_; // not owning
104-
jobject obj_;
106+
FirestoreInternal* firestore_ = nullptr; // not owning
107+
jobject obj_ = nullptr;
105108

106109
private:
107110
friend class FirestoreInternal;

firestore/src/include/firebase/firestore.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@
5151
#include "firebase/firestore/timestamp.h"
5252

5353
namespace firebase {
54+
/**
55+
* @brief Cloud Firestore API.
56+
*
57+
* Cloud Firestore is a flexible, scalable database for mobile, web, and server
58+
* development from Firebase and Google Cloud Platform.
59+
*/
5460
namespace firestore {
5561

5662
class FirestoreInternal;

firestore/src/include/firebase/firestore/event_listener.h

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@
2222
namespace firebase {
2323
namespace firestore {
2424

25-
/** An interface for event listeners. */
25+
/**
26+
* An interface for event listeners.
27+
*
28+
* @note This class should only be used when using the STLPort C++ runtime
29+
* library.
30+
*/
2631
template <typename T>
2732
class EventListener {
2833
public:
@@ -40,13 +45,18 @@ class EventListener {
4045
virtual void OnEvent(const T& value, Error error) = 0;
4146
};
4247

43-
/** Interface used for void EventListeners that don't produce a value. */
48+
/**
49+
* Interface used for void EventListeners that don't produce a value.
50+
*
51+
* @note This class should only be used when using the STLPort C++ runtime
52+
* library.
53+
*/
4454
template <>
4555
class EventListener<void> {
4656
public:
4757
virtual ~EventListener() = default;
4858

49-
/**
59+
/**
5060
* @brief OnEvent will be called with the error if an error occurred.
5161
*
5262
* @param error The error if there was error. Error::Ok otherwise.

firestore/src/include/firebase/firestore/map_field_value.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,14 @@ class FieldPath;
2727
class FieldValue;
2828

2929
#ifdef STLPORT
30+
/** @brief A map of `FieldValue`s indexed by stringified field paths. */
3031
using MapFieldValue = std::tr1::unordered_map<std::string, FieldValue>;
32+
/** @brief A map of `FieldValue`s indexed by field paths. */
3133
using MapFieldPathValue = std::tr1::unordered_map<FieldPath, FieldValue>;
3234
#else
35+
/** @brief A map of `FieldValue`s indexed by stringified field paths. */
3336
using MapFieldValue = std::unordered_map<std::string, FieldValue>;
37+
/** @brief A map of `FieldValue`s indexed by field paths. */
3438
using MapFieldPathValue = std::unordered_map<FieldPath, FieldValue>;
3539
#endif
3640

0 commit comments

Comments
 (0)