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

Unified Diff: ui/base/ime/input_method_log_collector.cc

Issue 1566083002: Makes sure the keyboard typing isn't blocked when InputMethod::OnFocus() is not correctly called. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use DumpWithoutCrashing(). Created 4 years, 11 months 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: ui/base/ime/input_method_log_collector.cc
diff --git a/ui/base/ime/input_method_log_collector.cc b/ui/base/ime/input_method_log_collector.cc
new file mode 100644
index 0000000000000000000000000000000000000000..40e9429d169aa6e1189e71e63ba7cc78124e157f
--- /dev/null
+++ b/ui/base/ime/input_method_log_collector.cc
@@ -0,0 +1,47 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/base/ime/input_method_log_collector.h"
+
+#include <string.h>
+
+#include "base/debug/alias.h"
+#include "base/debug/dump_without_crashing.h"
+
+namespace ui {
+
+InputMethodLogCollector::InputMethodLogCollector() {}
+
+InputMethodLogCollector::~InputMethodLogCollector() {}
+
+void InputMethodLogCollector::AddLog(const std::string& log_string) {
+ logs_.push_back(log_string);
+}
+
+void InputMethodLogCollector::DumpLogs() {
+ if (logs_.empty())
eroman 2016/01/13 22:27:08 Is knowing that the logs_ was empty useful in itse
Shu Chen 2016/01/14 07:44:47 Done.
+ return;
+
+ char logs_copy[4096];
eroman 2016/01/13 22:27:08 See suggestion for using string literals (const ch
Shu Chen 2016/01/14 07:44:47 Done.
+ size_t copy_from = 0;
+ for (size_t i = 0; i < logs_.size() && copy_from < sizeof(logs_copy); ++i) {
eroman 2016/01/13 22:27:08 I didn't review this yet (in case you change to th
Shu Chen 2016/01/14 07:44:47 Done.
+ strncpy(logs_copy + copy_from, logs_[i].c_str(),
+ sizeof(logs_copy) - copy_from);
+ copy_from += logs_[i].length();
+ if (copy_from >= sizeof(logs_copy))
+ break;
+ strncpy(logs_copy + copy_from, "; ",
+ sizeof(logs_copy) - copy_from);
+ copy_from += 2;
+ }
+ logs_.clear();
+ base::debug::Alias(&logs_copy);
+ base::debug::DumpWithoutCrashing();
eroman 2016/01/13 22:27:08 How often do you expect this to be hit? Do you hav
Shu Chen 2016/01/14 07:44:47 Done. I've made it only dump 5 times at maximum.
+}
+
+void InputMethodLogCollector::ClearLogs() {
+ logs_.clear();
+}
+
+} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698