diff --git a/firestore/.clang-format b/firestore/.clang-format index c6701e8850..e241231928 100644 --- a/firestore/.clang-format +++ b/firestore/.clang-format @@ -6,5 +6,4 @@ AllowAllParametersOfDeclarationOnNextLine: true SpacesInContainerLiterals: true DerivePointerAlignment: false PointerAlignment: Left -AllowShortFunctionsOnASingleLine: None IncludeBlocks: Preserve diff --git a/firestore/src/android/blob_android.cc b/firestore/src/android/blob_android.cc index ac68a1d173..caa9ee4ecc 100644 --- a/firestore/src/android/blob_android.cc +++ b/firestore/src/android/blob_android.cc @@ -34,7 +34,8 @@ void BlobInternal::Initialize(jni::Loader& loader) { Class BlobInternal::GetClass() { return Class(g_class); } -Local BlobInternal::Create(Env& env, const uint8_t* value, +Local BlobInternal::Create(Env& env, + const uint8_t* value, size_t size) { Local> byte_array = env.NewArray(size); env.SetArrayRegion(byte_array, 0, size, value); diff --git a/firestore/src/android/blob_android.h b/firestore/src/android/blob_android.h index 187072a4c4..0a3b6c5125 100644 --- a/firestore/src/android/blob_android.h +++ b/firestore/src/android/blob_android.h @@ -15,7 +15,8 @@ class BlobInternal : public jni::Object { static jni::Class GetClass(); - static jni::Local Create(jni::Env& env, const uint8_t* value, + static jni::Local Create(jni::Env& env, + const uint8_t* value, size_t size); jni::Local> ToBytes(jni::Env& env) const; diff --git a/firestore/src/android/converter_android.h b/firestore/src/android/converter_android.h index b982f4f231..472aedb566 100644 --- a/firestore/src/android/converter_android.h +++ b/firestore/src/android/converter_android.h @@ -32,7 +32,8 @@ struct ConverterImpl { } template > - 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 {}; @@ -62,7 +63,8 @@ PublicT MakePublic(jni::Env& env, const jni::Object& object) { } template > -PublicT MakePublic(jni::Env& env, FirestoreInternal* firestore, +PublicT MakePublic(jni::Env& env, + FirestoreInternal* firestore, const jni::Object& object) { return ConverterImpl::MakePublicFromJava(env, firestore, object); diff --git a/firestore/src/android/document_reference_android.cc b/firestore/src/android/document_reference_android.cc index 0b28a70bc5..5a113b7eee 100644 --- a/firestore/src/android/document_reference_android.cc +++ b/firestore/src/android/document_reference_android.cc @@ -176,7 +176,8 @@ ListenerRegistration DocumentReferenceInternal::AddSnapshotListener( #endif // defined(FIREBASE_USE_STD_FUNCTION) ListenerRegistration DocumentReferenceInternal::AddSnapshotListener( - MetadataChanges metadata_changes, EventListener* listener, + MetadataChanges metadata_changes, + EventListener* listener, bool passing_listener_ownership) { Env env = GetEnv(); Local java_metadata = diff --git a/firestore/src/android/exception_android.cc b/firestore/src/android/exception_android.cc index a866985be2..b79fb6f213 100644 --- a/firestore/src/android/exception_android.cc +++ b/firestore/src/android/exception_android.cc @@ -98,7 +98,8 @@ std::string ExceptionInternal::ToString(Env& env, const Object& exception) { return exception.CastTo().GetMessage(env); } -Local ExceptionInternal::Create(Env& env, Error code, +Local ExceptionInternal::Create(Env& env, + Error code, const std::string& message) { if (code == Error::kErrorOk) { return {}; diff --git a/firestore/src/android/exception_android.h b/firestore/src/android/exception_android.h index f1708098ea..3b497dc802 100644 --- a/firestore/src/android/exception_android.h +++ b/firestore/src/android/exception_android.h @@ -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 Create(jni::Env& env, Error code, + static jni::Local Create(jni::Env& env, + Error code, const std::string& message); static jni::Local Wrap( jni::Env& env, jni::Local&& exception); diff --git a/firestore/src/android/field_value_android.cc b/firestore/src/android/field_value_android.cc index 7f634424d6..85172840ff 100644 --- a/firestore/src/android/field_value_android.cc +++ b/firestore/src/android/field_value_android.cc @@ -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)); diff --git a/firestore/src/android/firestore_android.h b/firestore/src/android/firestore_android.h index 9ceedb7e96..3403276974 100644 --- a/firestore/src/android/firestore_android.h +++ b/firestore/src/android/firestore_android.h @@ -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; @@ -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. diff --git a/firestore/src/android/lambda_event_listener.h b/firestore/src/android/lambda_event_listener.h index b7594f5915..347906cb2a 100644 --- a/firestore/src/android/lambda_event_listener.h +++ b/firestore/src/android/lambda_event_listener.h @@ -24,7 +24,8 @@ class LambdaEventListener : public EventListener { 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); } diff --git a/firestore/src/android/lambda_transaction_function.h b/firestore/src/android/lambda_transaction_function.h index 326d2e1111..c9ef3bcd4b 100644 --- a/firestore/src/android/lambda_transaction_function.h +++ b/firestore/src/android/lambda_transaction_function.h @@ -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; } diff --git a/firestore/src/android/listener_registration_android.cc b/firestore/src/android/listener_registration_android.cc index 5e782820d5..b81fb70e39 100644 --- a/firestore/src/android/listener_registration_android.cc +++ b/firestore/src/android/listener_registration_android.cc @@ -26,7 +26,8 @@ void ListenerRegistrationInternal::Initialize(jni::Loader& loader) { ListenerRegistrationInternal::ListenerRegistrationInternal( FirestoreInternal* firestore, - EventListener* event_listener, bool owning_event_listener, + EventListener* event_listener, + bool owning_event_listener, const Object& listener_registration) : firestore_(firestore), listener_registration_(listener_registration), @@ -40,8 +41,10 @@ ListenerRegistrationInternal::ListenerRegistrationInternal( } ListenerRegistrationInternal::ListenerRegistrationInternal( - FirestoreInternal* firestore, EventListener* event_listener, - bool owning_event_listener, const Object& listener_registration) + FirestoreInternal* firestore, + EventListener* event_listener, + bool owning_event_listener, + const Object& listener_registration) : firestore_(firestore), listener_registration_(listener_registration), query_event_listener_(event_listener), @@ -54,8 +57,10 @@ ListenerRegistrationInternal::ListenerRegistrationInternal( } ListenerRegistrationInternal::ListenerRegistrationInternal( - FirestoreInternal* firestore, EventListener* event_listener, - bool owning_event_listener, const Object& listener_registration) + FirestoreInternal* firestore, + EventListener* event_listener, + bool owning_event_listener, + const Object& listener_registration) : firestore_(firestore), listener_registration_(listener_registration), void_event_listener_(event_listener), diff --git a/firestore/src/android/load_bundle_task_progress_android.cc b/firestore/src/android/load_bundle_task_progress_android.cc index 124e490d2d..cc47887300 100644 --- a/firestore/src/android/load_bundle_task_progress_android.cc +++ b/firestore/src/android/load_bundle_task_progress_android.cc @@ -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(); diff --git a/firestore/src/android/load_bundle_task_progress_android.h b/firestore/src/android/load_bundle_task_progress_android.h index b8910ae7a3..4597374a8a 100644 --- a/firestore/src/android/load_bundle_task_progress_android.h +++ b/firestore/src/android/load_bundle_task_progress_android.h @@ -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; diff --git a/firestore/src/android/promise_android.h b/firestore/src/android/promise_android.h index 6cbafdae00..d9b3e76a5c 100644 --- a/firestore/src/android/promise_android.h +++ b/firestore/src/android/promise_android.h @@ -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; }; @@ -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>( impl, firestore, completion)), @@ -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; @@ -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*>(callback_data); diff --git a/firestore/src/android/promise_factory_android.h b/firestore/src/android/promise_factory_android.h index d0c564dc99..913b6180cb 100644 --- a/firestore/src/android/promise_factory_android.h +++ b/firestore/src/android/promise_factory_android.h @@ -46,7 +46,9 @@ class PromiseFactory { template > Future NewFuture( - jni::Env& env, EnumT op, const jni::Task& task, + jni::Env& env, + EnumT op, + const jni::Task& task, typename Promise::Completion* completion = nullptr) { if (!env.ok()) return {}; diff --git a/firestore/src/android/query_android.cc b/firestore/src/android/query_android.cc index c3992b59fc..c2b2046f0e 100644 --- a/firestore/src/android/query_android.cc +++ b/firestore/src/android/query_android.cc @@ -249,7 +249,8 @@ Future QueryInternal::Get(Source source) { return promises_.NewFuture(env, AsyncFn::kGet, task); } -Query QueryInternal::Where(const FieldPath& field, const Method& method, +Query QueryInternal::Where(const FieldPath& field, + const Method& method, const FieldValue& value) const { Env env = GetEnv(); Local java_field = FieldPathConverter::Create(env, field); @@ -257,7 +258,8 @@ Query QueryInternal::Where(const FieldPath& field, const Method& method, return firestore_->NewQuery(env, query); } -Query QueryInternal::Where(const FieldPath& field, const Method& method, +Query QueryInternal::Where(const FieldPath& field, + const Method& method, const std::vector& values) const { Env env = GetEnv(); @@ -300,7 +302,8 @@ ListenerRegistration QueryInternal::AddSnapshotListener( #endif // defined(FIREBASE_USE_STD_FUNCTION) || defined(DOXYGEN) ListenerRegistration QueryInternal::AddSnapshotListener( - MetadataChanges metadata_changes, EventListener* listener, + MetadataChanges metadata_changes, + EventListener* listener, bool passing_listener_ownership) { Env env = GetEnv(); diff --git a/firestore/src/android/query_android.h b/firestore/src/android/query_android.h index 2c2b898910..a42a3b1f12 100644 --- a/firestore/src/android/query_android.h +++ b/firestore/src/android/query_android.h @@ -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* listener, + MetadataChanges metadata_changes, + EventListener* listener, bool passing_listener_ownership = false); protected: @@ -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& method, + Query Where(const FieldPath& field, + const jni::Method& method, const FieldValue& value) const; - Query Where(const FieldPath& field, const jni::Method& method, + Query Where(const FieldPath& field, + const jni::Method& method, const std::vector& values) const; // A generalized function for all {Start|End}{Before|After|At} calls. diff --git a/firestore/src/android/transaction_android.cc b/firestore/src/android/transaction_android.cc index c31f27f122..992e81ebd6 100644 --- a/firestore/src/android/transaction_android.cc +++ b/firestore/src/android/transaction_android.cc @@ -193,8 +193,11 @@ Local 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; } diff --git a/firestore/src/android/transaction_android.h b/firestore/src/android/transaction_android.h index e37849a7be..485077e5c8 100644 --- a/firestore/src/android/transaction_android.h +++ b/firestore/src/android/transaction_android.h @@ -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); @@ -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 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); diff --git a/firestore/src/android/write_batch_android.h b/firestore/src/android/write_batch_android.h index f38493d31e..84e5213949 100644 --- a/firestore/src/android/write_batch_android.h +++ b/firestore/src/android/write_batch_android.h @@ -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); diff --git a/firestore/src/common/cleanup.h b/firestore/src/common/cleanup.h index 957bfc9913..3c6ef74d46 100644 --- a/firestore/src/common/cleanup.h +++ b/firestore/src/common/cleanup.h @@ -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 , +template , typename F = FirestoreInternal> struct CleanupFn { static void Cleanup(void* obj_void) { DoCleanup(static_cast(obj_void)); } diff --git a/firestore/src/common/exception_common.cc b/firestore/src/common/exception_common.cc index e86f87bc6c..de2c6d063f 100644 --- a/firestore/src/common/exception_common.cc +++ b/firestore/src/common/exception_common.cc @@ -34,7 +34,10 @@ const char* ExceptionName(ExceptionType exception) { } FIRESTORE_ATTRIBUTE_NORETURN void DefaultThrowHandler( - ExceptionType type, const char* file, const char* func, int line, + ExceptionType type, + const char* file, + const char* func, + int line, const std::string& message) { std::ostringstream what; what << ExceptionName(type) << ": "; @@ -82,8 +85,10 @@ ThrowHandler SetThrowHandler(ThrowHandler handler) { } FIRESTORE_ATTRIBUTE_NORETURN void Throw(ExceptionType exception, - const char* file, const char* func, - int line, const std::string& message) { + const char* file, + const char* func, + int line, + const std::string& message) { throw_handler(exception, file, func, line, message); // It's expected that the throw handler above does not return. If it does, diff --git a/firestore/src/common/exception_common.h b/firestore/src/common/exception_common.h index ab685453ad..42c651dad5 100644 --- a/firestore/src/common/exception_common.h +++ b/firestore/src/common/exception_common.h @@ -52,8 +52,10 @@ enum class ExceptionType { * platform. Implementations of `ThrowHandler` must tolerate null/zero values * for `file`, `func`, and `line`. */ -using ThrowHandler = void (*)(ExceptionType type, const char* file, - const char* func, int line, +using ThrowHandler = void (*)(ExceptionType type, + const char* file, + const char* func, + int line, const std::string& message); /** @@ -72,8 +74,10 @@ using ThrowHandler = void (*)(ExceptionType type, const char* file, ThrowHandler SetThrowHandler(ThrowHandler handler); FIRESTORE_ATTRIBUTE_NORETURN void Throw(ExceptionType exception, - const char* file, const char* func, - int line, const std::string& message); + const char* file, + const char* func, + int line, + const std::string& message); } // namespace util diff --git a/firestore/src/common/firestore.cc b/firestore/src/common/firestore.cc index 302a4843fc..6affc8e2da 100644 --- a/firestore/src/common/firestore.cc +++ b/firestore/src/common/firestore.cc @@ -138,8 +138,7 @@ Firestore* Firestore::AddFirestoreToCache(Firestore* firestore, } Firestore::Firestore(::firebase::App* app) - : Firestore{new FirestoreInternal{app}} { -} + : Firestore{new FirestoreInternal{app}} {} Firestore::Firestore(FirestoreInternal* internal) // TODO(wuandy): use make_unique once it is supported for our build here. @@ -167,9 +166,7 @@ Firestore::Firestore(FirestoreInternal* internal) } } -Firestore::~Firestore() { - DeleteInternal(); -} +Firestore::~Firestore() { DeleteInternal(); } void Firestore::DeleteInternal() { MutexLock lock(*g_firestores_lock); diff --git a/firestore/src/common/hard_assert_common.cc b/firestore/src/common/hard_assert_common.cc index 83124d9edb..017b664034 100644 --- a/firestore/src/common/hard_assert_common.cc +++ b/firestore/src/common/hard_assert_common.cc @@ -9,13 +9,18 @@ namespace internal { #if defined(__ANDROID__) -void FailAssertion(const char* file, const char* func, const int line, +void FailAssertion(const char* file, + const char* func, + const int line, const std::string& message) { Throw(ExceptionType::AssertionFailure, file, func, line, message); } -void FailAssertion(const char* file, const char* func, const int line, - const std::string& message, const char* condition) { +void FailAssertion(const char* file, + const char* func, + const int line, + const std::string& message, + const char* condition) { std::string failure; if (message.empty()) { failure = condition; diff --git a/firestore/src/common/hard_assert_common.h b/firestore/src/common/hard_assert_common.h index 2ab824253d..ff0c35a5f4 100644 --- a/firestore/src/common/hard_assert_common.h +++ b/firestore/src/common/hard_assert_common.h @@ -106,11 +106,13 @@ namespace internal { // These symbols are in the util::internal namespace to match their iOS // equivalents. FIRESTORE_ATTRIBUTE_NORETURN void FailAssertion(const char* file, - const char* func, int line, + const char* func, + int line, const std::string& message); FIRESTORE_ATTRIBUTE_NORETURN void FailAssertion(const char* file, - const char* func, int line, + const char* func, + int line, const std::string& message, const char* condition); diff --git a/firestore/src/common/load_bundle_task_progress.cc b/firestore/src/common/load_bundle_task_progress.cc index c17b8dfd62..e50cee7a58 100644 --- a/firestore/src/common/load_bundle_task_progress.cc +++ b/firestore/src/common/load_bundle_task_progress.cc @@ -34,8 +34,7 @@ LoadBundleTaskProgress::LoadBundleTaskProgress(int32_t documents_loaded, total_documents_(total_documents), bytes_loaded_(bytes_loaded), total_bytes_(total_bytes), - state_(state) { -} + state_(state) {} // Android requires below constructor to create this object from internal // objects in a promise. See promise_android.h diff --git a/firestore/src/common/transaction.cc b/firestore/src/common/transaction.cc index be28061c6f..46faf4ce75 100644 --- a/firestore/src/common/transaction.cc +++ b/firestore/src/common/transaction.cc @@ -29,7 +29,8 @@ Transaction::~Transaction() { } void Transaction::Set(const DocumentReference& document, - const MapFieldValue& data, const SetOptions& options) { + const MapFieldValue& data, + const SetOptions& options) { if (!internal_) return; internal_->Set(document, data, options); } diff --git a/firestore/src/include/firebase/firestore/event_listener.h b/firestore/src/include/firebase/firestore/event_listener.h index bfe5657fde..e813694234 100644 --- a/firestore/src/include/firebase/firestore/event_listener.h +++ b/firestore/src/include/firebase/firestore/event_listener.h @@ -52,7 +52,8 @@ class EventListener { * @param error_message The error message if there was an error. An empty * string otherwise. */ - virtual void OnEvent(const T& value, Error error_code, + virtual void OnEvent(const T& value, + Error error_code, const std::string& error_message) = 0; }; diff --git a/firestore/src/include/firebase/firestore/load_bundle_task_progress.h b/firestore/src/include/firebase/firestore/load_bundle_task_progress.h index 2c286e9c89..e848ff5b73 100644 --- a/firestore/src/include/firebase/firestore/load_bundle_task_progress.h +++ b/firestore/src/include/firebase/firestore/load_bundle_task_progress.h @@ -42,35 +42,25 @@ class LoadBundleTaskProgress { State state); /** Returns how many documents have been loaded. */ - int32_t documents_loaded() const { - return documents_loaded_; - } + int32_t documents_loaded() const { return documents_loaded_; } /** * Returns the total number of documents in the bundle. Returns 0 if the * bundle failed to parse. */ - int32_t total_documents() const { - return total_documents_; - } + int32_t total_documents() const { return total_documents_; } /** Returns how many bytes have been loaded. */ - int64_t bytes_loaded() const { - return bytes_loaded_; - } + int64_t bytes_loaded() const { return bytes_loaded_; } /** * Returns the total number of bytes in the bundle. Returns 0 if the bundle * failed to parse. */ - int64_t total_bytes() const { - return total_bytes_; - } + int64_t total_bytes() const { return total_bytes_; } /** Returns the current state of the loading progress. */ - State state() const { - return state_; - } + State state() const { return state_; } private: friend class EventListenerInternal; diff --git a/firestore/src/include/firebase/firestore/transaction.h b/firestore/src/include/firebase/firestore/transaction.h index 5343921994..4430ff5e83 100644 --- a/firestore/src/include/firebase/firestore/transaction.h +++ b/firestore/src/include/firebase/firestore/transaction.h @@ -72,7 +72,8 @@ class Transaction { * @param[in] data A map of the fields and values to write to the document. * @param[in] options An object to configure the Set() behavior (optional). */ - virtual void Set(const DocumentReference& document, const MapFieldValue& data, + virtual void Set(const DocumentReference& document, + const MapFieldValue& data, const SetOptions& options = SetOptions()); /** @@ -115,7 +116,8 @@ class Transaction { * DocumentSnapshot if there is any error. */ virtual DocumentSnapshot Get(const DocumentReference& document, - Error* error_code, std::string* error_message); + Error* error_code, + std::string* error_message); protected: /** diff --git a/firestore/src/jni/env.cc b/firestore/src/jni/env.cc index 0a0b0ce8e5..e6bbf44d89 100644 --- a/firestore/src/jni/env.cc +++ b/firestore/src/jni/env.cc @@ -119,7 +119,8 @@ bool Env::IsSameObject(const Object& object1, const Object& object2) { return result; } -jmethodID Env::GetMethodId(const Class& clazz, const char* name, +jmethodID Env::GetMethodId(const Class& clazz, + const char* name, const char* sig) { if (!ok()) return nullptr; @@ -128,7 +129,8 @@ jmethodID Env::GetMethodId(const Class& clazz, const char* name, return result; } -jfieldID Env::GetStaticFieldId(const Class& clazz, const char* name, +jfieldID Env::GetStaticFieldId(const Class& clazz, + const char* name, const char* sig) { if (!ok()) return nullptr; @@ -137,7 +139,8 @@ jfieldID Env::GetStaticFieldId(const Class& clazz, const char* name, return result; } -jmethodID Env::GetStaticMethodId(const Class& clazz, const char* name, +jmethodID Env::GetStaticMethodId(const Class& clazz, + const char* name, const char* sig) { if (!ok()) return nullptr; diff --git a/firestore/src/jni/env.h b/firestore/src/jni/env.h index b93c035aaa..e9b7abbaa1 100644 --- a/firestore/src/jni/env.h +++ b/firestore/src/jni/env.h @@ -207,7 +207,8 @@ class Env { } template - ResultType Call(const Object& object, const Method& method, + ResultType Call(const Object& object, + const Method& method, Args&&... args) { auto env_method = CallTraits>::kCall; return CallHelper(env_method, object.get(), method.id(), @@ -225,7 +226,8 @@ class Env { // MARK: Accessing Static Fields - jfieldID GetStaticFieldId(const Class& clazz, const char* name, + jfieldID GetStaticFieldId(const Class& clazz, + const char* name, const char* sig); /** @@ -263,7 +265,8 @@ class Env { * Finds the method on the given class that's associated with the method name * and signature. */ - jmethodID GetStaticMethodId(const Class& clazz, const char* name, + jmethodID GetStaticMethodId(const Class& clazz, + const char* name, const char* sig); /** @@ -280,7 +283,8 @@ class Env { * or a local reference to the returned object. */ template - ResultType CallStatic(const Class& clazz, jmethodID method, + ResultType CallStatic(const Class& clazz, + jmethodID method, Args&&... args) { auto env_method = CallTraits>::kCallStatic; return CallHelper(env_method, clazz.get(), method, @@ -397,7 +401,8 @@ class Env { * Sets the value at the given index in the Java object array. */ template - EnableForReference SetArrayElement(Array& array, size_t index, + EnableForReference SetArrayElement(Array& array, + size_t index, const Object& value) { if (!ok()) return; @@ -412,7 +417,8 @@ class Env { */ template EnableForPrimitive GetArrayRegion(const Array& array, - size_t start, size_t len, + size_t start, + size_t len, T* buffer) { if (!ok()) return; @@ -440,8 +446,10 @@ class Env { * elements. */ template - EnableForPrimitive SetArrayRegion(Array& array, size_t start, - size_t len, const T* buffer) { + EnableForPrimitive SetArrayRegion(Array& array, + size_t start, + size_t len, + const T* buffer) { if (!ok()) return; auto env_method = CallTraits>::kSetArrayRegion; diff --git a/firestore/src/jni/loader.cc b/firestore/src/jni/loader.cc index e34952080e..ec4f85dd13 100644 --- a/firestore/src/jni/loader.cc +++ b/firestore/src/jni/loader.cc @@ -26,7 +26,8 @@ Loader::Loader(App* app) : app_(app), env_(app->GetJNIEnv()) { Loader::~Loader() { Unload(); } -void Loader::AddEmbeddedFile(const char* name, const unsigned char* data, +void Loader::AddEmbeddedFile(const char* name, + const unsigned char* data, size_t size) { #if defined(_STLPORT_VERSION) embedded_files_.push_back(EmbeddedFile(name, data, size)); diff --git a/firestore/src/jni/loader.h b/firestore/src/jni/loader.h index cf194a16c3..6539e297f8 100644 --- a/firestore/src/jni/loader.h +++ b/firestore/src/jni/loader.h @@ -49,7 +49,8 @@ class Loader { /** * Adds metadata about embedded class files in the binary distribution. */ - void AddEmbeddedFile(const char* name, const unsigned char* data, + void AddEmbeddedFile(const char* name, + const unsigned char* data, size_t size); /** * Unpacks any embedded files added above and writes them out to a temporary @@ -82,7 +83,8 @@ class Loader { * param existing_ref An existing local or global reference to a Java class. */ template - void LoadFromExistingClass(const char* class_name, jclass existing_ref, + void LoadFromExistingClass(const char* class_name, + jclass existing_ref, Members&&... members) { UsingExistingClass(class_name, existing_ref); LoadAll(Forward(members)...); diff --git a/firestore/src/jni/string.cc b/firestore/src/jni/string.cc index 83b8b60767..1144fcdc28 100644 --- a/firestore/src/jni/string.cc +++ b/firestore/src/jni/string.cc @@ -44,7 +44,8 @@ Class String::GetClass() { return Class(string_class); } String String::GetUtf8() { return String(utf8_string); } -Local String::Create(Env& env, const Array& bytes, +Local String::Create(Env& env, + const Array& bytes, const String& encoding) { return env.New(kNewFromBytes, bytes, encoding); } diff --git a/firestore/src/jni/string.h b/firestore/src/jni/string.h index 80c6b9b40b..3961d83405 100644 --- a/firestore/src/jni/string.h +++ b/firestore/src/jni/string.h @@ -29,7 +29,8 @@ class String : public Object { * @param bytes A Java array of encoded bytes. * @param encoding A Java string naming the encoding of the bytes. */ - static Local Create(Env& env, const Array& bytes, + static Local Create(Env& env, + const Array& bytes, const String& encoding); jstring get() const override { return static_cast(object_); } diff --git a/firestore/src/main/converter_main.h b/firestore/src/main/converter_main.h index ab869f8767..de8d6e3b0e 100644 --- a/firestore/src/main/converter_main.h +++ b/firestore/src/main/converter_main.h @@ -45,8 +45,10 @@ struct ConverterImpl { return PublicT{internal}; } - template , typename... Args> + template , + typename... Args> static PublicT MakePublicFromCore(CoreT&& from, Args... args) { auto* internal = new InternalT(std::move(from), std::move(args)...); return PublicT{internal}; diff --git a/firestore/src/main/credentials_provider_desktop.cc b/firestore/src/main/credentials_provider_desktop.cc index e9c4243192..96a17ffdac 100644 --- a/firestore/src/main/credentials_provider_desktop.cc +++ b/firestore/src/main/credentials_provider_desktop.cc @@ -128,8 +128,7 @@ void OnToken(const Future& future_token, } // namespace FirebaseCppCredentialsProvider::FirebaseCppCredentialsProvider(App& app) - : contents_(std::make_shared(app)) { -} + : contents_(std::make_shared(app)) {} FirebaseCppCredentialsProvider::~FirebaseCppCredentialsProvider() { RemoveAuthStateListener(); diff --git a/firestore/src/main/firestore_main.cc b/firestore/src/main/firestore_main.cc index 4ddadfddd0..e8f1037b05 100644 --- a/firestore/src/main/firestore_main.cc +++ b/firestore/src/main/firestore_main.cc @@ -68,8 +68,7 @@ LoadBundleTaskProgress ToApiProgress( } // namespace FirestoreInternal::FirestoreInternal(App* app) - : FirestoreInternal{app, CreateCredentialsProvider(*app)} { -} + : FirestoreInternal{app, CreateCredentialsProvider(*app)} {} FirestoreInternal::FirestoreInternal( App* app, std::unique_ptr credentials) diff --git a/firestore/src/main/firestore_main.h b/firestore/src/main/firestore_main.h index 8c3338cdbb..23e3dfb705 100644 --- a/firestore/src/main/firestore_main.h +++ b/firestore/src/main/firestore_main.h @@ -41,25 +41,17 @@ class FirestoreInternal { FirestoreInternal(const FirestoreInternal&) = delete; FirestoreInternal& operator=(const FirestoreInternal&) = delete; - 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_; } CollectionReference Collection(const char* collection_path) const; @@ -111,12 +103,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_; } const std::shared_ptr& firestore_core() const { return firestore_core_; diff --git a/firestore/src/main/promise_main.h b/firestore/src/main/promise_main.h index 8d08e9348f..3d0d2a7f82 100644 --- a/firestore/src/main/promise_main.h +++ b/firestore/src/main/promise_main.h @@ -30,7 +30,8 @@ template class Promise { public: // Creates a future backed by `LastResults` cache. - Promise(CleanupNotifier* cleanup, ReferenceCountedFutureImpl* future_api, + Promise(CleanupNotifier* cleanup, + ReferenceCountedFutureImpl* future_api, int identifier) : cleanup_{NOT_NULL(cleanup)}, future_api_{NOT_NULL(future_api)}, diff --git a/firestore/src/main/query_main.cc b/firestore/src/main/query_main.cc index bdd0aabc6b..4868576c66 100644 --- a/firestore/src/main/query_main.cc +++ b/firestore/src/main/query_main.cc @@ -65,7 +65,8 @@ Future QueryInternal::Get(Source source) { return promise.future(); } -Query QueryInternal::Where(const FieldPath& field_path, Operator op, +Query QueryInternal::Where(const FieldPath& field_path, + Operator op, const FieldValue& value) const { const model::FieldPath& path = GetInternal(field_path); model::FieldValue parsed = user_data_converter_.ParseQueryValue(value); @@ -75,7 +76,8 @@ Query QueryInternal::Where(const FieldPath& field_path, Operator op, return MakePublic(std::move(decorated)); } -Query QueryInternal::Where(const FieldPath& field_path, Operator op, +Query QueryInternal::Where(const FieldPath& field_path, + Operator op, const std::vector& values) const { const model::FieldPath& path = GetInternal(field_path); auto array_value = FieldValue::Array(values); diff --git a/firestore/src/main/query_main.h b/firestore/src/main/query_main.h index 2a4d4d0b41..464041501e 100644 --- a/firestore/src/main/query_main.h +++ b/firestore/src/main/query_main.h @@ -160,9 +160,11 @@ class QueryInternal { using Operator = core::Filter::Operator; - Query Where(const FieldPath& field, Operator op, + Query Where(const FieldPath& field, + Operator op, const FieldValue& value) const; - Query Where(const FieldPath& field, Operator op, + Query Where(const FieldPath& field, + Operator op, const std::vector& values) const; Query WithBound(BoundPosition bound_pos, diff --git a/firestore/src/main/transaction_main.cc b/firestore/src/main/transaction_main.cc index b6e61af5f1..5021d487a9 100644 --- a/firestore/src/main/transaction_main.cc +++ b/firestore/src/main/transaction_main.cc @@ -35,7 +35,8 @@ const model::DocumentKey& GetKey(const DocumentReference& document) { } DocumentSnapshot ConvertToSingleSnapshot( - const std::shared_ptr& firestore, model::DocumentKey key, + const std::shared_ptr& firestore, + model::DocumentKey key, const std::vector& documents) { SIMPLE_HARD_ASSERT( documents.size() == 1, diff --git a/firestore/src/main/transaction_main.h b/firestore/src/main/transaction_main.h index 3ae676eef9..a59aacf4f7 100644 --- a/firestore/src/main/transaction_main.h +++ b/firestore/src/main/transaction_main.h @@ -24,7 +24,8 @@ class TransactionInternal { Firestore* firestore(); FirestoreInternal* firestore_internal(); - 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); @@ -32,7 +33,8 @@ class TransactionInternal { 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); void MarkPermanentlyFailed(); diff --git a/firestore/src/main/user_data_converter_main.cc b/firestore/src/main/user_data_converter_main.cc index 677bd4771f..f507bb8d68 100644 --- a/firestore/src/main/user_data_converter_main.cc +++ b/firestore/src/main/user_data_converter_main.cc @@ -72,7 +72,8 @@ void ParseServerTimestamp(ParseContext&& context) { context.AddToFieldTransforms(*context.path(), ServerTimestampTransform{}); } -void ParseArrayTransform(Type type, const model::FieldValue::Array& elements, +void ParseArrayTransform(Type type, + const model::FieldValue::Array& elements, ParseContext&& context) { auto transform_type = [type] { switch (type) { diff --git a/firestore/src/main/write_batch_main.h b/firestore/src/main/write_batch_main.h index 068c84dc14..9ae83dc554 100644 --- a/firestore/src/main/write_batch_main.h +++ b/firestore/src/main/write_batch_main.h @@ -19,7 +19,8 @@ class WriteBatchInternal { Firestore* firestore(); FirestoreInternal* firestore_internal(); - 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); diff --git a/firestore/src/stub/transaction_stub.h b/firestore/src/stub/transaction_stub.h index 2c9a13415e..03cff3c979 100644 --- a/firestore/src/stub/transaction_stub.h +++ b/firestore/src/stub/transaction_stub.h @@ -16,7 +16,8 @@ class TransactionInternal { TransactionInternal() {} FirestoreInternal* firestore_internal() const { return nullptr; } - 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) {} @@ -26,7 +27,8 @@ class TransactionInternal { 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) { return DocumentSnapshot{}; } diff --git a/firestore/src/stub/write_batch_stub.h b/firestore/src/stub/write_batch_stub.h index d69a0a3496..7eb944cdd5 100644 --- a/firestore/src/stub/write_batch_stub.h +++ b/firestore/src/stub/write_batch_stub.h @@ -17,7 +17,8 @@ class WriteBatchInternal { WriteBatchInternal() {} FirestoreInternal* firestore_internal() const { return nullptr; } - 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) {}