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

Unified Diff: chrome/browser/chromeos/system_logs/touch_log_source_ozone.cc

Issue 893753002: Dump touchpad event logs for touch log source (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased codes. However, seems to have some problems. Created 5 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: chrome/browser/chromeos/system_logs/touch_log_source_ozone.cc
diff --git a/chrome/browser/chromeos/system_logs/touch_log_source_ozone.cc b/chrome/browser/chromeos/system_logs/touch_log_source_ozone.cc
index 078b692ee0a62ff3bcf2c38ddabecc91883906a4..4d10965b935965bae6715b39599645df68478d9c 100644
--- a/chrome/browser/chromeos/system_logs/touch_log_source_ozone.cc
+++ b/chrome/browser/chromeos/system_logs/touch_log_source_ozone.cc
@@ -9,6 +9,8 @@
#include "base/bind_helpers.h"
#include "base/callback.h"
#include "base/command_line.h"
+#include "base/files/file_path.h"
+#include "base/files/file_util.h"
#include "base/json/json_string_value_serializer.h"
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
@@ -28,18 +30,80 @@ const char kHUDLogDataKey[] = "hud_log";
// We continue to go with it in order to be compatible with the existing touch
// log processing toolchain.
const char kDeviceStatusLogDataKey[] = "hack-33025-touchpad";
+const char kTouchpadEventLogDataKey[] = "hack-33025-touchpad_activity";
-// Callback for handing the outcome of GetTouchDeviceStatus(). Appends the
-// collected log to the SystemLogsResponse map.
-void OnStatusLogCollected(scoped_ptr<system_logs::SystemLogsResponse> response,
- const system_logs::SysLogsSourceCallback& callback,
- scoped_ptr<std::string> log) {
+// Directory for temp touch event logs.
+const char kTouchEventLogDir[] = "/home/chronos/user/log";
+
+// Binary paths.
+const char kShellCommand[] = "/bin/sh";
+const char kTarCommand[] = "/bin/tar";
+const char kUuencodeCommand[] = "/usr/bin/uuencode";
+
+void CleanupEventLog(scoped_ptr<std::vector<base::FilePath>> log_paths) {
+ for (size_t i = 0; i < log_paths->size(); ++i)
+ base::DeleteFile((*log_paths)[i], false);
+}
+
+void PackEventLog(system_logs::SystemLogsResponse* response,
+ scoped_ptr<std::vector<base::FilePath>> log_paths) {
+ // Combine logs with a command line call that tars them up and uuencode the
+ // result in one string. This is to be compatible with the X11 behavior.
+ std::vector<std::pair<std::string, base::CommandLine>> commands;
+ base::CommandLine command = base::CommandLine(base::FilePath(kShellCommand));
+ command.AppendArg("-c");
+ std::string log_dir(kTouchEventLogDir);
spang 2015/02/02 21:43:16 Don't need this, you can concatenate a const char*
Shecky Lin 2015/02/03 08:20:14 It doesn't look like so. I tried it before and got
spang 2015/02/03 16:31:20 Ah, right, you're building a new string rather tha
+ std::string get_touchpad_gesture_log =
+ "ls -1t " + log_dir + "/touchpad_activity_* | head -n 7";
+ std::string get_touchpad_evdev_log =
+ "ls -1t " + log_dir + "/cmt_input_events_* | head -n 7";
+ command.AppendArg(std::string(kTarCommand) + " cf - $(" +
+ get_touchpad_gesture_log + " ) $(" +
+ get_touchpad_evdev_log + " ) 2>/dev/null | " +
+ kUuencodeCommand + " -m touchpad_activity_log.tar");
spang 2015/02/02 21:43:16 Can't this use log_paths instead of doing the $(ls
Shecky Lin 2015/02/03 08:20:14 I will have to use two separate vectors in the cal
spang 2015/02/03 16:31:20 Sure, I think we should really minimize use of she
Shecky Lin 2015/02/10 08:21:22 Done.
+ commands.push_back(std::make_pair(kTouchpadEventLogDataKey, command));
+
+ // For now only touchpad (and mouse) logs are actually collected.
+ for (size_t i = 0; i < commands.size(); ++i) {
+ std::string output;
+ base::GetAppOutput(commands[i].second, &output);
+ (*response)[commands[i].first] = output;
+ }
+
+ // Cleanup these temporary log files.
+ BrowserThread::PostBlockingPoolTask(
+ FROM_HERE, base::Bind(CleanupEventLog, base::Passed(&log_paths)));
+}
+
+void OnEventLogCollected(scoped_ptr<system_logs::SystemLogsResponse> response,
+ const system_logs::SysLogsSourceCallback& callback,
+ scoped_ptr<std::vector<base::FilePath>> log_paths) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- (*response)[kDeviceStatusLogDataKey] = *log;
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- base::Bind(callback, base::Owned(response.release())));
+ base::Closure pack_closure =
+ base::Bind(&PackEventLog, base::Unretained(response.get()),
+ base::Passed(&log_paths));
+ base::Closure callback_closure =
+ base::Bind(callback, base::Owned(response.release()));
+ BrowserThread::PostBlockingPoolTaskAndReply(FROM_HERE, pack_closure,
+ callback_closure);
+}
+
+// Callback for handing the outcome of GetTouchDeviceStatus().
+//
+// Appends the collected log to the SystemLogsResponse map. Also goes on to
+// collect touch event logs.
+ void OnStatusLogCollected(scoped_ptr<system_logs::SystemLogsResponse> response,
+ const system_logs::SysLogsSourceCallback& callback,
+ scoped_ptr<std::string> log) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ (*response)[kDeviceStatusLogDataKey] = *log;
+
+ // Collect touch event logs.
+ const base::FilePath kBaseLogPath(kTouchEventLogDir);
+ ui::OzonePlatform::GetInstance()->GetInputController()->GetTouchEventLog(
+ kBaseLogPath,
+ base::Bind(&OnEventLogCollected, base::Passed(&response), callback));
}
// Collect touch HUD debug logs. This needs to be done on the UI thread.
« no previous file with comments | « no previous file | ui/events/ozone/evdev/input_controller_evdev.h » ('j') | ui/events/ozone/evdev/input_device_factory_evdev.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698