| OLD | NEW |
| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "ash/touch/touch_hud_debug.h" | 9 #include "ash/touch/touch_hud_debug.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 119 |
| 120 // For now only touchpad (and mouse) logs are actually collected. | 120 // For now only touchpad (and mouse) logs are actually collected. |
| 121 for (size_t i = 0; i < commands.size(); ++i) { | 121 for (size_t i = 0; i < commands.size(); ++i) { |
| 122 std::string output; | 122 std::string output; |
| 123 base::GetAppOutput(commands[i].second, &output); | 123 base::GetAppOutput(commands[i].second, &output); |
| 124 (*response)[commands[i].first] = output; | 124 (*response)[commands[i].first] = output; |
| 125 } | 125 } |
| 126 | 126 |
| 127 // Cleanup these temporary log files. | 127 // Cleanup these temporary log files. |
| 128 base::PostTaskWithTraits( | 128 base::PostTaskWithTraits( |
| 129 FROM_HERE, | 129 FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND}, |
| 130 base::TaskTraits().MayBlock().WithPriority( | |
| 131 base::TaskPriority::BACKGROUND), | |
| 132 base::Bind(CleanupEventLog, base::Passed(&log_paths))); | 130 base::Bind(CleanupEventLog, base::Passed(&log_paths))); |
| 133 } | 131 } |
| 134 | 132 |
| 135 // Callback for handing the outcome of GetTouchEventLog(). | 133 // Callback for handing the outcome of GetTouchEventLog(). |
| 136 // | 134 // |
| 137 // This is the end of the whole touch log collection process. | 135 // This is the end of the whole touch log collection process. |
| 138 void OnEventLogCollected( | 136 void OnEventLogCollected( |
| 139 std::unique_ptr<system_logs::SystemLogsResponse> response, | 137 std::unique_ptr<system_logs::SystemLogsResponse> response, |
| 140 const system_logs::SysLogsSourceCallback& callback, | 138 const system_logs::SysLogsSourceCallback& callback, |
| 141 std::unique_ptr<std::vector<base::FilePath>> log_paths) { | 139 std::unique_ptr<std::vector<base::FilePath>> log_paths) { |
| 142 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 140 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 143 | 141 |
| 144 // We cannot eliminate these temporaries and inline these closures because the | 142 // We cannot eliminate these temporaries and inline these closures because the |
| 145 // compiler may call release() before get(). | 143 // compiler may call release() before get(). |
| 146 const base::Closure pack_closure = | 144 const base::Closure pack_closure = |
| 147 base::Bind(&PackEventLog, base::Unretained(response.get()), | 145 base::Bind(&PackEventLog, base::Unretained(response.get()), |
| 148 base::Passed(&log_paths)); | 146 base::Passed(&log_paths)); |
| 149 const base::Closure callback_closure = | 147 const base::Closure callback_closure = |
| 150 base::Bind(callback, base::Owned(response.release())); | 148 base::Bind(callback, base::Owned(response.release())); |
| 151 base::PostTaskWithTraitsAndReply(FROM_HERE, | 149 base::PostTaskWithTraitsAndReply( |
| 152 base::TaskTraits().MayBlock().WithPriority( | 150 FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND}, |
| 153 base::TaskPriority::BACKGROUND), | 151 pack_closure, callback_closure); |
| 154 pack_closure, callback_closure); | |
| 155 } | 152 } |
| 156 | 153 |
| 157 // Callback for handing the outcome of GetTouchDeviceStatus(). | 154 // Callback for handing the outcome of GetTouchDeviceStatus(). |
| 158 // | 155 // |
| 159 // Appends the collected log to the SystemLogsResponse map. Also goes on to | 156 // Appends the collected log to the SystemLogsResponse map. Also goes on to |
| 160 // collect touch event logs. | 157 // collect touch event logs. |
| 161 void OnStatusLogCollected( | 158 void OnStatusLogCollected( |
| 162 std::unique_ptr<system_logs::SystemLogsResponse> response, | 159 std::unique_ptr<system_logs::SystemLogsResponse> response, |
| 163 const system_logs::SysLogsSourceCallback& callback, | 160 const system_logs::SysLogsSourceCallback& callback, |
| 164 std::unique_ptr<std::string> log) { | 161 std::unique_ptr<std::string> log) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 195 | 192 |
| 196 std::unique_ptr<SystemLogsResponse> response(new SystemLogsResponse); | 193 std::unique_ptr<SystemLogsResponse> response(new SystemLogsResponse); |
| 197 CollectTouchHudDebugLog(response.get()); | 194 CollectTouchHudDebugLog(response.get()); |
| 198 | 195 |
| 199 // Collect touch device status logs. | 196 // Collect touch device status logs. |
| 200 ui::OzonePlatform::GetInstance()->GetInputController()->GetTouchDeviceStatus( | 197 ui::OzonePlatform::GetInstance()->GetInputController()->GetTouchDeviceStatus( |
| 201 base::Bind(&OnStatusLogCollected, base::Passed(&response), callback)); | 198 base::Bind(&OnStatusLogCollected, base::Passed(&response), callback)); |
| 202 } | 199 } |
| 203 | 200 |
| 204 } // namespace system_logs | 201 } // namespace system_logs |
| OLD | NEW |