Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ui/base/ime/input_method_log_collector.h" | |
| 6 | |
| 7 #include <string.h> | |
| 8 | |
| 9 #include "base/debug/alias.h" | |
| 10 #include "base/debug/dump_without_crashing.h" | |
| 11 | |
| 12 namespace ui { | |
| 13 | |
| 14 InputMethodLogCollector::InputMethodLogCollector() {} | |
| 15 | |
| 16 InputMethodLogCollector::~InputMethodLogCollector() {} | |
| 17 | |
| 18 void InputMethodLogCollector::AddLog(const std::string& log_string) { | |
| 19 logs_.push_back(log_string); | |
| 20 } | |
| 21 | |
| 22 void InputMethodLogCollector::DumpLogs() { | |
| 23 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.
| |
| 24 return; | |
| 25 | |
| 26 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.
| |
| 27 size_t copy_from = 0; | |
| 28 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.
| |
| 29 strncpy(logs_copy + copy_from, logs_[i].c_str(), | |
| 30 sizeof(logs_copy) - copy_from); | |
| 31 copy_from += logs_[i].length(); | |
| 32 if (copy_from >= sizeof(logs_copy)) | |
| 33 break; | |
| 34 strncpy(logs_copy + copy_from, "; ", | |
| 35 sizeof(logs_copy) - copy_from); | |
| 36 copy_from += 2; | |
| 37 } | |
| 38 logs_.clear(); | |
| 39 base::debug::Alias(&logs_copy); | |
| 40 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.
| |
| 41 } | |
| 42 | |
| 43 void InputMethodLogCollector::ClearLogs() { | |
| 44 logs_.clear(); | |
| 45 } | |
| 46 | |
| 47 } // namespace ui | |
| OLD | NEW |