Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion firestore/.clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ AllowAllParametersOfDeclarationOnNextLine: true
SpacesInContainerLiterals: true
DerivePointerAlignment: false
PointerAlignment: Left
AllowShortFunctionsOnASingleLine: None
IncludeBlocks: Preserve
3 changes: 2 additions & 1 deletion firestore/src/android/blob_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ void BlobInternal::Initialize(jni::Loader& loader) {

Class BlobInternal::GetClass() { return Class(g_class); }

Local<BlobInternal> BlobInternal::Create(Env& env, const uint8_t* value,
Local<BlobInternal> BlobInternal::Create(Env& env,
const uint8_t* value,
size_t size) {
Local<Array<uint8_t>> byte_array = env.NewArray<uint8_t>(size);
env.SetArrayRegion(byte_array, 0, size, value);
Expand Down
3 changes: 2 additions & 1 deletion firestore/src/android/blob_android.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class BlobInternal : public jni::Object {

static jni::Class GetClass();

static jni::Local<BlobInternal> Create(jni::Env& env, const uint8_t* value,
static jni::Local<BlobInternal> Create(jni::Env& env,
const uint8_t* value,
size_t size);

jni::Local<jni::Array<uint8_t>> ToBytes(jni::Env& env) const;
Expand Down
6 changes: 4 additions & 2 deletions firestore/src/android/converter_android.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ struct ConverterImpl {
}

template <typename PublicT, typename InternalT = InternalType<PublicT>>
static PublicT MakePublicFromJava(jni::Env& env, FirestoreInternal* firestore,
static PublicT MakePublicFromJava(jni::Env& env,
FirestoreInternal* firestore,
const jni::Object& object) {
if (!env.ok() || !object) return {};

Expand Down Expand Up @@ -62,7 +63,8 @@ PublicT MakePublic(jni::Env& env, const jni::Object& object) {
}

template <typename PublicT, typename InternalT = InternalType<PublicT>>
PublicT MakePublic(jni::Env& env, FirestoreInternal* firestore,
PublicT MakePublic(jni::Env& env,
FirestoreInternal* firestore,
const jni::Object& object) {
return ConverterImpl::MakePublicFromJava<PublicT, InternalT>(env, firestore,
object);
Expand Down
3 changes: 2 additions & 1 deletion firestore/src/android/document_reference_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ ListenerRegistration DocumentReferenceInternal::AddSnapshotListener(
#endif // defined(FIREBASE_USE_STD_FUNCTION)

ListenerRegistration DocumentReferenceInternal::AddSnapshotListener(
MetadataChanges metadata_changes, EventListener<DocumentSnapshot>* listener,
MetadataChanges metadata_changes,
EventListener<DocumentSnapshot>* listener,
bool passing_listener_ownership) {
Env env = GetEnv();
Local<Object> java_metadata =
Expand Down
3 changes: 2 additions & 1 deletion firestore/src/android/exception_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ std::string ExceptionInternal::ToString(Env& env, const Object& exception) {
return exception.CastTo<Throwable>().GetMessage(env);
}

Local<Throwable> ExceptionInternal::Create(Env& env, Error code,
Local<Throwable> ExceptionInternal::Create(Env& env,
Error code,
const std::string& message) {
if (code == Error::kErrorOk) {
return {};
Expand Down
3 changes: 2 additions & 1 deletion firestore/src/android/exception_android.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class ExceptionInternal {
static Error GetErrorCode(jni::Env& env, const jni::Object& exception);
static std::string ToString(jni::Env& env, const jni::Object& exception);

static jni::Local<jni::Throwable> Create(jni::Env& env, Error code,
static jni::Local<jni::Throwable> Create(jni::Env& env,
Error code,
const std::string& message);
static jni::Local<jni::Throwable> Wrap(
jni::Env& env, jni::Local<jni::Throwable>&& exception);
Expand Down
3 changes: 2 additions & 1 deletion firestore/src/android/field_value_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ FieldValue FieldValueInternal::Create(Env& env, const Object& object) {
return FieldValue(new FieldValueInternal(Type::kNull, object));
}

FieldValue FieldValueInternal::Create(Env& env, Type type,
FieldValue FieldValueInternal::Create(Env& env,
Type type,
const Object& object) {
if (!env.ok() || !object) return {};
return FieldValue(new FieldValueInternal(type, object));
Expand Down
24 changes: 6 additions & 18 deletions firestore/src/android/firestore_android.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,25 +65,17 @@ class FirestoreInternal {
explicit FirestoreInternal(App* app);
~FirestoreInternal();

App* app() const {
return app_;
}
App* app() const { return app_; }

// Whether this object was successfully initialized by the constructor.
bool initialized() const {
return app_ != nullptr;
}
bool initialized() const { return app_ != nullptr; }

// Manages all Future objects returned from Firestore API.
FutureManager& future_manager() {
return future_manager_;
}
FutureManager& future_manager() { return future_manager_; }

// When this is deleted, it will clean up all DatabaseReferences,
// DataSnapshots, and other such objects.
CleanupNotifier& cleanup() {
return cleanup_;
}
CleanupNotifier& cleanup() { return cleanup_; }

// Returns a CollectionReference that refers to the specific path.
CollectionReference Collection(const char* collection_path) const;
Expand Down Expand Up @@ -159,12 +151,8 @@ class FirestoreInternal {
firestore_public_ = firestore_public;
}

Firestore* firestore_public() {
return firestore_public_;
}
const Firestore* firestore_public() const {
return firestore_public_;
}
Firestore* firestore_public() { return firestore_public_; }
const Firestore* firestore_public() const { return firestore_public_; }

/**
* Finds the FirestoreInternal instance for the given Java Firestore instance.
Expand Down
3 changes: 2 additions & 1 deletion firestore/src/android/lambda_event_listener.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ class LambdaEventListener : public EventListener<T> {
FIREBASE_ASSERT(callback_);
}

void OnEvent(const T& value, Error error_code,
void OnEvent(const T& value,
Error error_code,
const std::string& error_message) override {
callback_(value, error_code, error_message);
}
Expand Down
3 changes: 2 additions & 1 deletion firestore/src/android/lambda_transaction_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ class LambdaTransactionFunction
}

// Override Promise::Completion::CompleteWith().
void CompleteWith(Error error_code, const char* error_message,
void CompleteWith(Error error_code,
const char* error_message,
void* result) override {
delete this;
}
Expand Down
15 changes: 10 additions & 5 deletions firestore/src/android/listener_registration_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ void ListenerRegistrationInternal::Initialize(jni::Loader& loader) {

ListenerRegistrationInternal::ListenerRegistrationInternal(
FirestoreInternal* firestore,
EventListener<DocumentSnapshot>* event_listener, bool owning_event_listener,
EventListener<DocumentSnapshot>* event_listener,
bool owning_event_listener,
const Object& listener_registration)
: firestore_(firestore),
listener_registration_(listener_registration),
Expand All @@ -40,8 +41,10 @@ ListenerRegistrationInternal::ListenerRegistrationInternal(
}

ListenerRegistrationInternal::ListenerRegistrationInternal(
FirestoreInternal* firestore, EventListener<QuerySnapshot>* event_listener,
bool owning_event_listener, const Object& listener_registration)
FirestoreInternal* firestore,
EventListener<QuerySnapshot>* event_listener,
bool owning_event_listener,
const Object& listener_registration)
: firestore_(firestore),
listener_registration_(listener_registration),
query_event_listener_(event_listener),
Expand All @@ -54,8 +57,10 @@ ListenerRegistrationInternal::ListenerRegistrationInternal(
}

ListenerRegistrationInternal::ListenerRegistrationInternal(
FirestoreInternal* firestore, EventListener<void>* event_listener,
bool owning_event_listener, const Object& listener_registration)
FirestoreInternal* firestore,
EventListener<void>* event_listener,
bool owning_event_listener,
const Object& listener_registration)
: firestore_(firestore),
listener_registration_(listener_registration),
void_event_listener_(event_listener),
Expand Down
4 changes: 1 addition & 3 deletions firestore/src/android/load_bundle_task_progress_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ void LoadBundleTaskProgressInternal::Initialize(jni::Loader& loader) {
loader.LoadClass(kStateEnumName, kTaskStateSuccess, kTaskStateRunning);
}

Class LoadBundleTaskProgressInternal::GetClass() {
return Class(g_clazz);
}
Class LoadBundleTaskProgressInternal::GetClass() { return Class(g_clazz); }

int32_t LoadBundleTaskProgressInternal::documents_loaded() const {
Env env = GetEnv();
Expand Down
3 changes: 1 addition & 2 deletions firestore/src/android/load_bundle_task_progress_android.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ class LoadBundleTaskProgressInternal : public Wrapper {

LoadBundleTaskProgressInternal(FirestoreInternal* firestore,
const jni::Object& object)
: Wrapper(firestore, object) {
}
: Wrapper(firestore, object) {}

int32_t documents_loaded() const;

Expand Down
15 changes: 10 additions & 5 deletions firestore/src/android/promise_android.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ class Promise {
class Completion {
public:
virtual ~Completion() = default;
virtual void CompleteWith(Error error_code, const char* error_message,
virtual void CompleteWith(Error error_code,
const char* error_message,
PublicType* result) = 0;
};

Expand All @@ -70,7 +71,8 @@ class Promise {
private:
// The constructor is intentionally private.
// Create instances with `PromiseFactory`.
Promise(ReferenceCountedFutureImpl* impl, FirestoreInternal* firestore,
Promise(ReferenceCountedFutureImpl* impl,
FirestoreInternal* firestore,
Completion* completion)
: completer_(MakeUnique<Completer<PublicType, InternalType>>(
impl, firestore, completion)),
Expand All @@ -80,7 +82,8 @@ class Promise {
class CompleterBase {
public:
CompleterBase(ReferenceCountedFutureImpl* impl,
FirestoreInternal* firestore, Completion* completion)
FirestoreInternal* firestore,
Completion* completion)
: impl_{impl}, firestore_{firestore}, completion_(completion) {}

virtual ~CompleterBase() = default;
Expand Down Expand Up @@ -174,9 +177,11 @@ class Promise {
}
};

static void ResultCallback(JNIEnv* env, jobject result,
static void ResultCallback(JNIEnv* env,
jobject result,
util::FutureResult result_code,
const char* status_message, void* callback_data) {
const char* status_message,
void* callback_data) {
if (callback_data != nullptr) {
auto* data =
static_cast<Completer<PublicType, InternalType>*>(callback_data);
Expand Down
4 changes: 3 additions & 1 deletion firestore/src/android/promise_factory_android.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ class PromiseFactory {

template <typename PublicT, typename InternalT = InternalType<PublicT>>
Future<PublicT> NewFuture(
jni::Env& env, EnumT op, const jni::Task& task,
jni::Env& env,
EnumT op,
const jni::Task& task,
typename Promise<PublicT, InternalT, EnumT>::Completion* completion =
nullptr) {
if (!env.ok()) return {};
Expand Down
9 changes: 6 additions & 3 deletions firestore/src/android/query_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -249,15 +249,17 @@ Future<QuerySnapshot> QueryInternal::Get(Source source) {
return promises_.NewFuture<QuerySnapshot>(env, AsyncFn::kGet, task);
}

Query QueryInternal::Where(const FieldPath& field, const Method<Object>& method,
Query QueryInternal::Where(const FieldPath& field,
const Method<Object>& method,
const FieldValue& value) const {
Env env = GetEnv();
Local<Object> java_field = FieldPathConverter::Create(env, field);
Local<Object> query = env.Call(obj_, method, java_field, ToJava(value));
return firestore_->NewQuery(env, query);
}

Query QueryInternal::Where(const FieldPath& field, const Method<Object>& method,
Query QueryInternal::Where(const FieldPath& field,
const Method<Object>& method,
const std::vector<FieldValue>& values) const {
Env env = GetEnv();

Expand Down Expand Up @@ -300,7 +302,8 @@ ListenerRegistration QueryInternal::AddSnapshotListener(
#endif // defined(FIREBASE_USE_STD_FUNCTION) || defined(DOXYGEN)

ListenerRegistration QueryInternal::AddSnapshotListener(
MetadataChanges metadata_changes, EventListener<QuerySnapshot>* listener,
MetadataChanges metadata_changes,
EventListener<QuerySnapshot>* listener,
bool passing_listener_ownership) {
Env env = GetEnv();

Expand Down
9 changes: 6 additions & 3 deletions firestore/src/android/query_android.h
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,8 @@ class QueryInternal : public Wrapper {
* @return A registration object that can be used to remove the listener.
*/
ListenerRegistration AddSnapshotListener(
MetadataChanges metadata_changes, EventListener<QuerySnapshot>* listener,
MetadataChanges metadata_changes,
EventListener<QuerySnapshot>* listener,
bool passing_listener_ownership = false);

protected:
Expand All @@ -375,9 +376,11 @@ class QueryInternal : public Wrapper {
friend class FirestoreInternal;

// A generalized function for all WhereFoo calls.
Query Where(const FieldPath& field, const jni::Method<jni::Object>& method,
Query Where(const FieldPath& field,
const jni::Method<jni::Object>& method,
const FieldValue& value) const;
Query Where(const FieldPath& field, const jni::Method<jni::Object>& method,
Query Where(const FieldPath& field,
const jni::Method<jni::Object>& method,
const std::vector<FieldValue>& values) const;

// A generalized function for all {Start|End}{Before|After|At} calls.
Expand Down
7 changes: 5 additions & 2 deletions firestore/src/android/transaction_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,11 @@ Local<Object> TransactionInternal::Create(Env& env,
}

jobject TransactionInternal::TransactionFunctionNativeApply(
JNIEnv* raw_env, jclass clazz, jlong firestore_ptr,
jlong transaction_function_ptr, jobject java_transaction) {
JNIEnv* raw_env,
jclass clazz,
jlong firestore_ptr,
jlong transaction_function_ptr,
jobject java_transaction) {
if (firestore_ptr == 0 || transaction_function_ptr == 0) {
return nullptr;
}
Expand Down
9 changes: 6 additions & 3 deletions firestore/src/android/transaction_android.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class TransactionInternal : public Wrapper {
: Wrapper(firebase::Move(rhs)),
first_exception_(Move(rhs.first_exception_)) {}

void Set(const DocumentReference& document, const MapFieldValue& data,
void Set(const DocumentReference& document,
const MapFieldValue& data,
const SetOptions& options);

void Update(const DocumentReference& document, const MapFieldValue& data);
Expand All @@ -42,14 +43,16 @@ class TransactionInternal : public Wrapper {

void Delete(const DocumentReference& document);

DocumentSnapshot Get(const DocumentReference& document, Error* error_code,
DocumentSnapshot Get(const DocumentReference& document,
Error* error_code,
std::string* error_message);

static jni::Local<jni::Object> Create(jni::Env& env,
FirestoreInternal* firestore,
TransactionFunction* function);

static jobject TransactionFunctionNativeApply(JNIEnv* env, jclass clazz,
static jobject TransactionFunctionNativeApply(JNIEnv* env,
jclass clazz,
jlong firestore_ptr,
jlong transaction_function_ptr,
jobject transaction);
Expand Down
3 changes: 2 additions & 1 deletion firestore/src/android/write_batch_android.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ class WriteBatchInternal : public Wrapper {
WriteBatchInternal(FirestoreInternal* firestore, const jni::Object& object)
: Wrapper(firestore, object), promises_(firestore) {}

void Set(const DocumentReference& document, const MapFieldValue& data,
void Set(const DocumentReference& document,
const MapFieldValue& data,
const SetOptions& options);

void Update(const DocumentReference& document, const MapFieldValue& data);
Expand Down
3 changes: 2 additions & 1 deletion firestore/src/common/cleanup.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ class FirestoreInternal;
// F is almost always FirestoreInternal unless one wants something else to
// manage the cleanup process. We define type F to make this CleanupFn
// implementation platform-independent.
template <typename T, typename U = InternalType<T>,
template <typename T,
typename U = InternalType<T>,
typename F = FirestoreInternal>
struct CleanupFn {
static void Cleanup(void* obj_void) { DoCleanup(static_cast<T*>(obj_void)); }
Expand Down
Loading