| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ui/events/ozone/evdev/libgestures_glue/gesture_feedback.h" | 5 #include "ui/events/ozone/evdev/libgestures_glue/gesture_feedback.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <time.h> | 8 #include <time.h> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 return DumpArrayProperty(property->GetDoubleValue(), "%lf"); | 59 return DumpArrayProperty(property->GetDoubleValue(), "%lf"); |
| 60 break; | 60 break; |
| 61 default: | 61 default: |
| 62 NOTREACHED(); | 62 NOTREACHED(); |
| 63 break; | 63 break; |
| 64 } | 64 } |
| 65 return std::string(); | 65 return std::string(); |
| 66 } | 66 } |
| 67 | 67 |
| 68 // Compress dumped event logs in place. | 68 // Compress dumped event logs in place. |
| 69 void CompressDumpedLog(scoped_ptr<std::vector<std::string>> log_paths) { | 69 void CompressDumpedLog(std::unique_ptr<std::vector<std::string>> log_paths) { |
| 70 for (size_t i = 0; i < log_paths->size(); ++i) { | 70 for (size_t i = 0; i < log_paths->size(); ++i) { |
| 71 // Zip the file. | 71 // Zip the file. |
| 72 base::CommandLine command = base::CommandLine(base::FilePath(kGzipCommand)); | 72 base::CommandLine command = base::CommandLine(base::FilePath(kGzipCommand)); |
| 73 command.AppendArg("-f"); | 73 command.AppendArg("-f"); |
| 74 command.AppendArg((*log_paths)[i]); | 74 command.AppendArg((*log_paths)[i]); |
| 75 std::string output; | 75 std::string output; |
| 76 base::GetAppOutput(command, &output); | 76 base::GetAppOutput(command, &output); |
| 77 | 77 |
| 78 // Replace the original file with the zipped one. | 78 // Replace the original file with the zipped one. |
| 79 base::Move(base::FilePath((*log_paths)[i] + ".gz"), | 79 base::Move(base::FilePath((*log_paths)[i] + ".gz"), |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 status->append("\t" + DumpGesturePropertyValue(property) + '\n'); | 165 status->append("\t" + DumpGesturePropertyValue(property) + '\n'); |
| 166 } | 166 } |
| 167 } | 167 } |
| 168 } | 168 } |
| 169 | 169 |
| 170 // Dump touch event logs. | 170 // Dump touch event logs. |
| 171 void DumpTouchEventLog( | 171 void DumpTouchEventLog( |
| 172 std::map<base::FilePath, EventConverterEvdev*>& converters, | 172 std::map<base::FilePath, EventConverterEvdev*>& converters, |
| 173 GesturePropertyProvider* provider, | 173 GesturePropertyProvider* provider, |
| 174 const base::FilePath& out_dir, | 174 const base::FilePath& out_dir, |
| 175 scoped_ptr<std::vector<base::FilePath>> log_paths, | 175 std::unique_ptr<std::vector<base::FilePath>> log_paths, |
| 176 const GetTouchEventLogReply& reply) { | 176 const GetTouchEventLogReply& reply) { |
| 177 // Get device ids. | 177 // Get device ids. |
| 178 std::vector<int> ids; | 178 std::vector<int> ids; |
| 179 provider->GetDeviceIdsByType(DT_ALL, &ids); | 179 provider->GetDeviceIdsByType(DT_ALL, &ids); |
| 180 | 180 |
| 181 // Get current time stamp. | 181 // Get current time stamp. |
| 182 std::string now = GetCurrentTimeForLogging(); | 182 std::string now = GetCurrentTimeForLogging(); |
| 183 | 183 |
| 184 // Dump event logs for gesture devices. | 184 // Dump event logs for gesture devices. |
| 185 scoped_ptr<std::vector<std::string>> log_paths_to_be_compressed( | 185 std::unique_ptr<std::vector<std::string>> log_paths_to_be_compressed( |
| 186 new std::vector<std::string>); | 186 new std::vector<std::string>); |
| 187 for (size_t i = 0; i < ids.size(); ++i) { | 187 for (size_t i = 0; i < ids.size(); ++i) { |
| 188 // First, see if the device actually uses the gesture library by checking | 188 // First, see if the device actually uses the gesture library by checking |
| 189 // if it has any gesture property. | 189 // if it has any gesture property. |
| 190 std::vector<std::string> names = provider->GetPropertyNamesById(ids[i]); | 190 std::vector<std::string> names = provider->GetPropertyNamesById(ids[i]); |
| 191 if (names.size() == 0) | 191 if (names.size() == 0) |
| 192 continue; | 192 continue; |
| 193 | 193 |
| 194 // Set the logging properties to dump event logs. This needs to be done | 194 // Set the logging properties to dump event logs. This needs to be done |
| 195 // synchronously for now or we might have race conditions on the debug | 195 // synchronously for now or we might have race conditions on the debug |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 } | 232 } |
| 233 | 233 |
| 234 // Compress touchpad/mouse logs on another thread and return. | 234 // Compress touchpad/mouse logs on another thread and return. |
| 235 base::WorkerPool::PostTaskAndReply( | 235 base::WorkerPool::PostTaskAndReply( |
| 236 FROM_HERE, | 236 FROM_HERE, |
| 237 base::Bind(&CompressDumpedLog, base::Passed(&log_paths_to_be_compressed)), | 237 base::Bind(&CompressDumpedLog, base::Passed(&log_paths_to_be_compressed)), |
| 238 base::Bind(reply, base::Passed(&log_paths)), true /* task_is_slow */); | 238 base::Bind(reply, base::Passed(&log_paths)), true /* task_is_slow */); |
| 239 } | 239 } |
| 240 | 240 |
| 241 } // namespace ui | 241 } // namespace ui |
| OLD | NEW |