Chromium Code Reviews| 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 3e9f16524ca3b09afa34f637be703fbd256ced40..49d282e9a454d2a0564884f6fc0a60dcf4af7095 100644 |
| --- a/chrome/browser/chromeos/system_logs/touch_log_source_ozone.cc |
| +++ b/chrome/browser/chromeos/system_logs/touch_log_source_ozone.cc |
| @@ -6,12 +6,17 @@ |
| #include "ash/touch/touch_hud_debug.h" |
| #include "base/bind.h" |
| +#include "base/bind_helpers.h" |
| +#include "base/callback.h" |
| #include "base/command_line.h" |
| #include "base/json/json_string_value_serializer.h" |
| #include "base/logging.h" |
| +#include "base/message_loop/message_loop.h" |
| #include "base/process/launch.h" |
| #include "components/feedback/feedback_util.h" |
| #include "content/public/browser/browser_thread.h" |
| +#include "ui/ozone/public/input_controller.h" |
| +#include "ui/ozone/public/ozone_platform.h" |
| using content::BrowserThread; |
| @@ -19,7 +24,44 @@ namespace { |
| const char kHUDLogDataKey[] = "hud_log"; |
| -void GetTouchLogsOzone(system_logs::SystemLogsResponse* response) { |
| +// The prefix "hack-33025" was historically chosen in http://crbug.com/139715. |
| +// We continue to go with it in order to be compatible with the existing touch |
| +// log processing toolchain. |
| +const char kDeviceStatusLogDataKey[] = "hack-33025-touchpad"; |
| + |
| +// Token string for the sequenced worker pool. |
| +const char kDefaultSequenceName[] = "TouchLogWriter"; |
| + |
| +scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner( |
| + const std::string sequence_name) { |
| + base::SequencedWorkerPool* pool = content::BrowserThread::GetBlockingPool(); |
| + return pool->GetSequencedTaskRunnerWithShutdownBehavior( |
| + pool->GetNamedSequenceToken(sequence_name), |
| + base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); |
| +} |
| + |
| +// Callback for handing the outcome of CollectStatusLog(). Appends the |
| +// collected log to the SystemLogsResponse map. |
| +void OnStatusLogCollected(system_logs::SystemLogsResponse* response, |
| + const system_logs::SysLogsSourceCallback& callback, |
| + std::string* log) { |
| + (*response)[kDeviceStatusLogDataKey] = *log; |
| + |
| + GetSequencedTaskRunner(kDefaultSequenceName) |
| + ->PostTask(FROM_HERE, base::Bind(callback, base::Owned(response))); |
| +} |
| + |
| +// Collect touch device status logs (containing property values). |
| +void CollectStatusLog(system_logs::SystemLogsResponse* response, |
| + const system_logs::SysLogsSourceCallback& callback) { |
| + ui::OzonePlatform::GetInstance()->GetInputController()->GetTouchDeviceStatus( |
| + base::Bind(&OnStatusLogCollected, response, callback)); |
| +} |
| + |
| +// Entry point for the touch log collection tasks. |
| +void StartLogRetrieval(system_logs::SystemLogsResponse* response, |
| + const system_logs::SysLogsSourceCallback& callback) { |
| + // Collect touch HUD logs. |
| scoped_ptr<base::DictionaryValue> dictionary = |
| ash::TouchHudDebug::GetAllAsDictionary(); |
|
spang
2015/01/27 20:15:13
This seems scary.. what makes it safe to call ash
spang
2015/01/27 20:44:56
Can you do this part on UI and pass the results al
Shecky Lin
2015/01/27 23:08:15
Done.
|
| if (!dictionary->empty()) { |
| @@ -30,9 +72,10 @@ void GetTouchLogsOzone(system_logs::SystemLogsResponse* response) { |
| (*response)[kHUDLogDataKey] = touch_log; |
| } |
| - // TODO(sheckylin): Add ozone touch log collection implementation. See |
| - // http://crbug.com/400022. |
| - NOTIMPLEMENTED(); |
| + // Collect touch device status logs. |
| + content::BrowserThread::PostTask( |
| + content::BrowserThread::UI, FROM_HERE, |
| + base::Bind(&CollectStatusLog, response, callback)); |
|
spang
2015/01/27 20:15:12
Do you need this task hop? Aren't we already on UI
spang
2015/01/27 20:42:37
My bad, I misread the code, TouchLogSource::Fetch
Shecky Lin
2015/01/27 23:08:15
Done.
|
| } |
| } // namespace |
| @@ -44,9 +87,8 @@ void TouchLogSource::Fetch(const SysLogsSourceCallback& callback) { |
| DCHECK(!callback.is_null()); |
| SystemLogsResponse* response = new SystemLogsResponse; |
| - BrowserThread::PostBlockingPoolTaskAndReply( |
| - FROM_HERE, base::Bind(&GetTouchLogsOzone, response), |
| - base::Bind(callback, base::Owned(response))); |
| + GetSequencedTaskRunner(kDefaultSequenceName) |
| + ->PostTask(FROM_HERE, base::Bind(&StartLogRetrieval, response, callback)); |
|
spang
2015/01/27 20:15:13
Use base::Passed() to pass ownership of response t
Shecky Lin
2015/01/27 23:08:15
Done.
|
| } |
| } // namespace system_logs |