Skip to content

Commit 732e4ad

Browse files
Googlera-maurice
authored andcommitted
[c++] Adding doc comments for EventListener java files
Making some edits to comments based on other CL reviews. PiperOrigin-RevId: 292645766
1 parent 2e730b4 commit 732e4ad

File tree

5 files changed

+57
-16
lines changed

5 files changed

+57
-16
lines changed

firestore/src/android/field_value_android.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ FieldValueInternal::FieldValueInternal(std::vector<FieldValue> value)
132132
JNIEnv* env = firestore_->app()->GetJNIEnv();
133133
jmethodID add_method = util::array_list::GetMethodId(util::array_list::kAdd);
134134
for (const FieldValue& element : value) {
135-
// ArrayList.Add() always returns true, which we have no use of.
135+
// ArrayList.Add() always returns true, which we have no use for.
136136
env->CallBooleanMethod(obj_, add_method, element.internal_->obj_);
137137
}
138138
CheckAndClearJniExceptions(env);
@@ -147,7 +147,7 @@ FieldValueInternal::FieldValueInternal(MapFieldValue value)
147147
for (const auto& kv : value) {
148148
jobject key = env->NewStringUTF(kv.first.c_str());
149149
// Map::Put() returns previously associated value or null, which we have no
150-
// use of.
150+
// use for.
151151
env->CallObjectMethod(obj_, put_method, key, kv.second.internal_->obj_);
152152
env->DeleteLocalRef(key);
153153
}

firestore/src_java/com/google/firebase/firestore/internal/cpp/DocumentEventListener.java

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,43 @@
55
import com.google.firebase.firestore.EventListener;
66
import com.google.firebase.firestore.FirebaseFirestoreException;
77

8-
/** Implements Firestore EventListener<DocumentSnapshot> by redirecting calls into C++. */
8+
/**
9+
* Implements Firestore {@code
10+
* firebase::firestore::EventListener<firebase::firestore::DocumentSnapshot>} by redirecting calls
11+
* into the C++ equivalent.
12+
*/
913
public class DocumentEventListener extends CppEventListener
1014
implements EventListener<DocumentSnapshot> {
11-
/** Construct a DocumentEventListener. Parameters are C++ pointers. */
15+
/**
16+
* Constructs a DocumentEventListener. Ownership of the underlying EventListener can be
17+
* transferred when creating the {@code ListenerRegistration}. If the ListenerRegistration owns
18+
* the EventListener, it will de-allocate the EventListener in its destructor.
19+
*
20+
* <p>Passing in 0 is considered a null pointer and will result in {@code onEvent} becoming a
21+
* no-op.
22+
*
23+
* @param cppFirestoreObject Pointer to a {@code firebase::firestore::Firestore}.
24+
* @param cppListenerObject Pointer to a {@code
25+
* firebase::firestore::EventListener<firebase::firestore::DocumentSnapshot>}.
26+
*/
1227
public DocumentEventListener(long cppFirestoreObject, long cppListenerObject) {
1328
super(cppFirestoreObject, cppListenerObject);
1429
}
1530

1631
@Override
1732
public synchronized void onEvent(
1833
@Nullable DocumentSnapshot value, @Nullable FirebaseFirestoreException error) {
19-
if (cppFirestoreObject != 0 && cppListenerObject != 0) {
2034
nativeOnEvent(cppFirestoreObject, cppListenerObject, value, error);
21-
}
2235
}
2336

2437
/**
25-
* This native function is implemented in the Firestore C++ library (event_listener_android.cc).
38+
* Interprets the {@code listenerObject} as a {@code
39+
* firebase::firestore::EventListener<DocumentSnapshot>} and invokes the listener's {@code
40+
* OnEvent} method with the {@code error} and {@code DocumentSnapshot} created by interpreting the
41+
* {@code firestoreObject} as a {@code firebase::firestore::Firestore}.
42+
*
43+
* <p>This native method is implemented in the Firestore C++ library {@code
44+
* event_listener_android.cc}.
2645
*/
2746
private static native void nativeOnEvent(
2847
long firestoreObject,
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.google.firebase.firestore.internal.cpp;
22

33
/**
4-
* Place-holder dummy Java class for Firestore C++ Android clients.
4+
* Place-holder dummy Java class for Firestore C++ Android clients. This is currently being used to
5+
* prevent Tricorder errors since we do not have desktop support yet.
56
*/
6-
public class Dummy {
7-
}
7+
public class Dummy {}

firestore/src_java/com/google/firebase/firestore/internal/cpp/QueryEventListener.java

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,42 @@
55
import com.google.firebase.firestore.FirebaseFirestoreException;
66
import com.google.firebase.firestore.QuerySnapshot;
77

8-
/** Implements Firestore EventListener<QuerySnapshot> by redirecting calls into C++. */
8+
/**
9+
* Implements Firestore {@code
10+
* firebase::firestore::EventListener<firebase::firestore::QuerySnapshot>} by redirecting calls into
11+
* the C++ equivalent.
12+
*/
913
public class QueryEventListener extends CppEventListener implements EventListener<QuerySnapshot> {
10-
/** Construct a QueryEventListener. Parameters are C++ pointers. */
14+
/**
15+
* Constructs a QueryEventListener. Ownership of the underlying EventListener can be transferred
16+
* when creating the {@code ListenerRegistration}. If the ListenerRegistration owns the
17+
* EventListener, it will de-allocate the EventListener in its destructor.
18+
*
19+
* <p>Passing in 0 is considered a null pointer and will result in {@code onEvent} becoming a
20+
* no-op.
21+
*
22+
* @param cppFirestoreObject Pointer to a {@code firebase::firestore::Firestore}.
23+
* @param cppListenerObject Pointer to a {@code
24+
* firebase::firestore::EventListener<firebase::firestore::QuerySnapshot>}.
25+
*/
1126
public QueryEventListener(long cppFirestoreObject, long cppListenerObject) {
1227
super(cppFirestoreObject, cppListenerObject);
1328
}
1429

1530
@Override
1631
public synchronized void onEvent(
1732
@Nullable QuerySnapshot value, @Nullable FirebaseFirestoreException error) {
18-
if (cppFirestoreObject != 0 && cppListenerObject != 0) {
1933
nativeOnEvent(cppFirestoreObject, cppListenerObject, value, error);
20-
}
2134
}
2235

2336
/**
24-
* This native function is implemented in the Firestore C++ library (event_listener_android.cc).
37+
* Interprets the {@code listenerObject} as a {@code
38+
* firebase::firestore::EventListener<QuerySnapshot>} and invokes the listener's {@code OnEvent}
39+
* method with the {@code error} and {@code QuerySnapshot} created by interpreting the {@code
40+
* firestoreObject} as a {@code firebase::firestore::Firestore}.
41+
*
42+
* <p>This native method is implemented in the Firestore C++ library {@code
43+
* event_listener_android.cc}.
2544
*/
2645
private static native void nativeOnEvent(
2746
long firestoreObject,

firestore/src_java/com/google/firebase/firestore/internal/cpp/VoidEventListener.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class VoidEventListener extends CppEventListener implements Runnable {
1111
* when creating the {@code ListenerRegistration}. If the ListenerRegistration owns the
1212
* EventListener, it will de-allocate the EventListener in its destructor.
1313
*
14-
* <p>Passing in 0 is considered a null pointer and will result in an early return.
14+
* <p>Passing in 0 is considered a null pointer and will result in {@code run} becoming a no-op.
1515
*
1616
* @param cppListenerObject Pointer to a {@code firebase::firestore::EventListener<void>}.
1717
*/
@@ -29,6 +29,9 @@ public void run() {
2929
* invokes the listener's {@code OnEvent} method with {@code Error::Ok}. The EventListener will
3030
* never be passed anything other than Ok because VoidEventListener can only be used in
3131
* circumstances where the callback can't fail.
32+
*
33+
* <p>This native method is implemented in the Firestore C++ library {@code
34+
* event_listener_android.cc}.
3235
*/
3336
private static native void nativeOnEvent(long listenerObject);
3437
}

0 commit comments

Comments
 (0)