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

Side by Side 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, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/system_logs/touch_log_source.h" 5 #include "chrome/browser/chromeos/system_logs/touch_log_source.h"
6 6
7 #include "ash/touch/touch_hud_debug.h" 7 #include "ash/touch/touch_hud_debug.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/files/file_path.h"
13 #include "base/files/file_util.h"
12 #include "base/json/json_string_value_serializer.h" 14 #include "base/json/json_string_value_serializer.h"
13 #include "base/logging.h" 15 #include "base/logging.h"
14 #include "base/message_loop/message_loop.h" 16 #include "base/message_loop/message_loop.h"
15 #include "base/process/launch.h" 17 #include "base/process/launch.h"
16 #include "components/feedback/feedback_util.h" 18 #include "components/feedback/feedback_util.h"
17 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
18 #include "ui/ozone/public/input_controller.h" 20 #include "ui/ozone/public/input_controller.h"
19 #include "ui/ozone/public/ozone_platform.h" 21 #include "ui/ozone/public/ozone_platform.h"
20 22
21 using content::BrowserThread; 23 using content::BrowserThread;
22 24
23 namespace { 25 namespace {
24 26
25 const char kHUDLogDataKey[] = "hud_log"; 27 const char kHUDLogDataKey[] = "hud_log";
26 28
27 // The prefix "hack-33025" was historically chosen in http://crbug.com/139715. 29 // The prefix "hack-33025" was historically chosen in http://crbug.com/139715.
28 // We continue to go with it in order to be compatible with the existing touch 30 // We continue to go with it in order to be compatible with the existing touch
29 // log processing toolchain. 31 // log processing toolchain.
30 const char kDeviceStatusLogDataKey[] = "hack-33025-touchpad"; 32 const char kDeviceStatusLogDataKey[] = "hack-33025-touchpad";
33 const char kTouchpadEventLogDataKey[] = "hack-33025-touchpad_activity";
31 34
32 // Callback for handing the outcome of GetTouchDeviceStatus(). Appends the 35 // Directory for temp touch event logs.
33 // collected log to the SystemLogsResponse map. 36 const char kTouchEventLogDir[] = "/home/chronos/user/log";
34 void OnStatusLogCollected(scoped_ptr<system_logs::SystemLogsResponse> response, 37
35 const system_logs::SysLogsSourceCallback& callback, 38 // Binary paths.
36 scoped_ptr<std::string> log) { 39 const char kShellCommand[] = "/bin/sh";
40 const char kTarCommand[] = "/bin/tar";
41 const char kUuencodeCommand[] = "/usr/bin/uuencode";
42
43 void CleanupEventLog(scoped_ptr<std::vector<base::FilePath>> log_paths) {
44 for (size_t i = 0; i < log_paths->size(); ++i)
45 base::DeleteFile((*log_paths)[i], false);
46 }
47
48 void PackEventLog(system_logs::SystemLogsResponse* response,
49 scoped_ptr<std::vector<base::FilePath>> log_paths) {
50 // Combine logs with a command line call that tars them up and uuencode the
51 // result in one string. This is to be compatible with the X11 behavior.
52 std::vector<std::pair<std::string, base::CommandLine>> commands;
53 base::CommandLine command = base::CommandLine(base::FilePath(kShellCommand));
54 command.AppendArg("-c");
55 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
56 std::string get_touchpad_gesture_log =
57 "ls -1t " + log_dir + "/touchpad_activity_* | head -n 7";
58 std::string get_touchpad_evdev_log =
59 "ls -1t " + log_dir + "/cmt_input_events_* | head -n 7";
60 command.AppendArg(std::string(kTarCommand) + " cf - $(" +
61 get_touchpad_gesture_log + " ) $(" +
62 get_touchpad_evdev_log + " ) 2>/dev/null | " +
63 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.
64 commands.push_back(std::make_pair(kTouchpadEventLogDataKey, command));
65
66 // For now only touchpad (and mouse) logs are actually collected.
67 for (size_t i = 0; i < commands.size(); ++i) {
68 std::string output;
69 base::GetAppOutput(commands[i].second, &output);
70 (*response)[commands[i].first] = output;
71 }
72
73 // Cleanup these temporary log files.
74 BrowserThread::PostBlockingPoolTask(
75 FROM_HERE, base::Bind(CleanupEventLog, base::Passed(&log_paths)));
76 }
77
78 void OnEventLogCollected(scoped_ptr<system_logs::SystemLogsResponse> response,
79 const system_logs::SysLogsSourceCallback& callback,
80 scoped_ptr<std::vector<base::FilePath>> log_paths) {
37 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 81 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
38 (*response)[kDeviceStatusLogDataKey] = *log;
39 82
40 BrowserThread::PostTask( 83 base::Closure pack_closure =
41 BrowserThread::UI, FROM_HERE, 84 base::Bind(&PackEventLog, base::Unretained(response.get()),
42 base::Bind(callback, base::Owned(response.release()))); 85 base::Passed(&log_paths));
86 base::Closure callback_closure =
87 base::Bind(callback, base::Owned(response.release()));
88 BrowserThread::PostBlockingPoolTaskAndReply(FROM_HERE, pack_closure,
89 callback_closure);
90 }
91
92 // Callback for handing the outcome of GetTouchDeviceStatus().
93 //
94 // Appends the collected log to the SystemLogsResponse map. Also goes on to
95 // collect touch event logs.
96 void OnStatusLogCollected(scoped_ptr<system_logs::SystemLogsResponse> response,
97 const system_logs::SysLogsSourceCallback& callback,
98 scoped_ptr<std::string> log) {
99 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
100 (*response)[kDeviceStatusLogDataKey] = *log;
101
102 // Collect touch event logs.
103 const base::FilePath kBaseLogPath(kTouchEventLogDir);
104 ui::OzonePlatform::GetInstance()->GetInputController()->GetTouchEventLog(
105 kBaseLogPath,
106 base::Bind(&OnEventLogCollected, base::Passed(&response), callback));
43 } 107 }
44 108
45 // Collect touch HUD debug logs. This needs to be done on the UI thread. 109 // Collect touch HUD debug logs. This needs to be done on the UI thread.
46 void CollectTouchHudDebugLog(system_logs::SystemLogsResponse* response) { 110 void CollectTouchHudDebugLog(system_logs::SystemLogsResponse* response) {
47 scoped_ptr<base::DictionaryValue> dictionary = 111 scoped_ptr<base::DictionaryValue> dictionary =
48 ash::TouchHudDebug::GetAllAsDictionary(); 112 ash::TouchHudDebug::GetAllAsDictionary();
49 if (!dictionary->empty()) { 113 if (!dictionary->empty()) {
50 std::string touch_log; 114 std::string touch_log;
51 JSONStringValueSerializer json(&touch_log); 115 JSONStringValueSerializer json(&touch_log);
52 json.set_pretty_print(true); 116 json.set_pretty_print(true);
(...skipping 12 matching lines...) Expand all
65 129
66 scoped_ptr<SystemLogsResponse> response(new SystemLogsResponse); 130 scoped_ptr<SystemLogsResponse> response(new SystemLogsResponse);
67 CollectTouchHudDebugLog(response.get()); 131 CollectTouchHudDebugLog(response.get());
68 132
69 // Collect touch device status logs. 133 // Collect touch device status logs.
70 ui::OzonePlatform::GetInstance()->GetInputController()->GetTouchDeviceStatus( 134 ui::OzonePlatform::GetInstance()->GetInputController()->GetTouchDeviceStatus(
71 base::Bind(&OnStatusLogCollected, base::Passed(&response), callback)); 135 base::Bind(&OnStatusLogCollected, base::Passed(&response), callback));
72 } 136 }
73 137
74 } // namespace system_logs 138 } // namespace system_logs
OLDNEW
« 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