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

Side by Side Diff: chrome/browser/chromeos/system_logs/touch_log_source_ozone.cc

Issue 864253002: Dump property values for the touch log source (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use base::WorkerPool to post task in input_controller_evdev 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"
10 #include "base/callback.h"
9 #include "base/command_line.h" 11 #include "base/command_line.h"
10 #include "base/json/json_string_value_serializer.h" 12 #include "base/json/json_string_value_serializer.h"
11 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/message_loop/message_loop.h"
12 #include "base/process/launch.h" 15 #include "base/process/launch.h"
13 #include "components/feedback/feedback_util.h" 16 #include "components/feedback/feedback_util.h"
14 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
18 #include "ui/ozone/public/input_controller.h"
19 #include "ui/ozone/public/ozone_platform.h"
15 20
16 using content::BrowserThread; 21 using content::BrowserThread;
17 22
18 namespace { 23 namespace {
19 24
20 const char kHUDLogDataKey[] = "hud_log"; 25 const char kHUDLogDataKey[] = "hud_log";
21 26
22 void GetTouchLogsOzone(system_logs::SystemLogsResponse* response) { 27 // 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
29 // log processing toolchain.
30 const char kDeviceStatusLogDataKey[] = "hack-33025-touchpad";
31
32 // Token string for the sequenced worker pool.
33 const char kDefaultSequenceName[] = "TouchLogWriter";
34
35 scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner(
36 const std::string sequence_name) {
37 base::SequencedWorkerPool* pool = content::BrowserThread::GetBlockingPool();
38 return pool->GetSequencedTaskRunnerWithShutdownBehavior(
39 pool->GetNamedSequenceToken(sequence_name),
40 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN);
41 }
42
43 // Callback for handing the outcome of CollectStatusLog(). Appends the
44 // collected log to the SystemLogsResponse map.
45 void OnStatusLogCollected(system_logs::SystemLogsResponse* response,
46 const system_logs::SysLogsSourceCallback& callback,
47 std::string* log) {
48 (*response)[kDeviceStatusLogDataKey] = *log;
49
50 GetSequencedTaskRunner(kDefaultSequenceName)
51 ->PostTask(FROM_HERE, base::Bind(callback, base::Owned(response)));
52 }
53
54 // Collect touch device status logs (containing property values).
55 void CollectStatusLog(system_logs::SystemLogsResponse* response,
56 const system_logs::SysLogsSourceCallback& callback) {
57 ui::OzonePlatform::GetInstance()->GetInputController()->GetTouchDeviceStatus(
58 base::Bind(&OnStatusLogCollected, response, callback));
59 }
60
61 // Entry point for the touch log collection tasks.
62 void StartLogRetrieval(system_logs::SystemLogsResponse* response,
63 const system_logs::SysLogsSourceCallback& callback) {
64 // Collect touch HUD logs.
23 scoped_ptr<base::DictionaryValue> dictionary = 65 scoped_ptr<base::DictionaryValue> dictionary =
24 ash::TouchHudDebug::GetAllAsDictionary(); 66 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.
25 if (!dictionary->empty()) { 67 if (!dictionary->empty()) {
26 std::string touch_log; 68 std::string touch_log;
27 JSONStringValueSerializer json(&touch_log); 69 JSONStringValueSerializer json(&touch_log);
28 json.set_pretty_print(true); 70 json.set_pretty_print(true);
29 if (json.Serialize(*dictionary) && !touch_log.empty()) 71 if (json.Serialize(*dictionary) && !touch_log.empty())
30 (*response)[kHUDLogDataKey] = touch_log; 72 (*response)[kHUDLogDataKey] = touch_log;
31 } 73 }
32 74
33 // TODO(sheckylin): Add ozone touch log collection implementation. See 75 // Collect touch device status logs.
34 // http://crbug.com/400022. 76 content::BrowserThread::PostTask(
35 NOTIMPLEMENTED(); 77 content::BrowserThread::UI, FROM_HERE,
78 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.
36 } 79 }
37 80
38 } // namespace 81 } // namespace
39 82
40 namespace system_logs { 83 namespace system_logs {
41 84
42 void TouchLogSource::Fetch(const SysLogsSourceCallback& callback) { 85 void TouchLogSource::Fetch(const SysLogsSourceCallback& callback) {
43 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 86 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
44 DCHECK(!callback.is_null()); 87 DCHECK(!callback.is_null());
45 88
46 SystemLogsResponse* response = new SystemLogsResponse; 89 SystemLogsResponse* response = new SystemLogsResponse;
47 BrowserThread::PostBlockingPoolTaskAndReply( 90 GetSequencedTaskRunner(kDefaultSequenceName)
48 FROM_HERE, base::Bind(&GetTouchLogsOzone, response), 91 ->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.
49 base::Bind(callback, base::Owned(response)));
50 } 92 }
51 93
52 } // namespace system_logs 94 } // namespace system_logs
OLDNEW
« no previous file with comments | « no previous file | ui/events/ozone/evdev/input_controller_evdev.h » ('j') | ui/ozone/public/input_controller.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698