Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(600)

Unified Diff: components/spellcheck/browser/spellchecker_session_bridge_android.cc

Issue 2503933002: [Android] spellcheck: add availability UMA. (Closed)
Patch Set: tweak histogram description Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/spellcheck/browser/spellchecker_session_bridge_android.cc
diff --git a/components/spellcheck/browser/spellchecker_session_bridge_android.cc b/components/spellcheck/browser/spellchecker_session_bridge_android.cc
index 5c2644f8ecc3c85e211fd8aa0f4081aec66651df..de8b3f92550431c85c57a54cd6b64e5ded8ba549 100644
--- a/components/spellcheck/browser/spellchecker_session_bridge_android.cc
+++ b/components/spellcheck/browser/spellchecker_session_bridge_android.cc
@@ -9,6 +9,7 @@
#include "base/android/jni_array.h"
#include "base/android/jni_string.h"
+#include "base/metrics/histogram_macros.h"
#include "components/spellcheck/common/spellcheck_messages.h"
#include "components/spellcheck/common/spellcheck_result.h"
#include "content/public/browser/browser_thread.h"
@@ -17,9 +18,18 @@
using base::android::JavaParamRef;
+namespace {
+
+void RecordAvailabilityUMA(bool spellcheck_available) {
+ UMA_HISTOGRAM_BOOLEAN("Spellcheck.Android.Available", spellcheck_available);
+}
+
+} // namespace
+
SpellCheckerSessionBridge::SpellCheckerSessionBridge(int render_process_id)
: render_process_id_(render_process_id),
- java_object_initialization_failed_(false) {}
+ java_object_initialization_failed_(false),
+ active_session_(false) {}
SpellCheckerSessionBridge::~SpellCheckerSessionBridge() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
@@ -38,8 +48,13 @@ void SpellCheckerSessionBridge::RequestTextCheck(int route_id,
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
// SpellCheckerSessionBridge#create() will return null if spell checker
// service is unavailable.
- if (java_object_initialization_failed_)
+ if (java_object_initialization_failed_) {
+ if (!active_session_) {
+ RecordAvailabilityUMA(false);
+ active_session_ = true;
+ }
return;
+ }
// RequestTextCheck IPC arrives at the message filter before
// ToggleSpellCheck IPC when the user focuses an input field that already
@@ -50,6 +65,10 @@ void SpellCheckerSessionBridge::RequestTextCheck(int route_id,
java_object_.Reset(Java_SpellCheckerSessionBridge_create(
base::android::AttachCurrentThread(),
reinterpret_cast<intptr_t>(this)));
+ if (!active_session_) {
+ RecordAvailabilityUMA(!java_object_.is_null());
+ active_session_ = true;
+ }
if (java_object_.is_null()) {
java_object_initialization_failed_ = true;
return;
@@ -114,6 +133,7 @@ void SpellCheckerSessionBridge::DisconnectSession() {
active_request_.reset();
pending_request_.reset();
+ active_session_ = false;
if (!java_object_.is_null()) {
Java_SpellCheckerSessionBridge_disconnect(
« no previous file with comments | « components/spellcheck/browser/spellchecker_session_bridge_android.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698