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 "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" | |
11 #include "base/command_line.h" | 9 #include "base/command_line.h" |
12 #include "base/json/json_string_value_serializer.h" | 10 #include "base/json/json_string_value_serializer.h" |
13 #include "base/logging.h" | 11 #include "base/logging.h" |
14 #include "base/message_loop/message_loop.h" | |
15 #include "base/process/launch.h" | 12 #include "base/process/launch.h" |
16 #include "components/feedback/feedback_util.h" | 13 #include "components/feedback/feedback_util.h" |
17 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
18 #include "ui/ozone/public/input_controller.h" | |
19 #include "ui/ozone/public/ozone_platform.h" | |
20 | 15 |
21 using content::BrowserThread; | 16 using content::BrowserThread; |
22 | 17 |
23 namespace { | 18 namespace { |
24 | 19 |
25 const char kHUDLogDataKey[] = "hud_log"; | 20 const char kHUDLogDataKey[] = "hud_log"; |
26 | 21 |
27 // The prefix "hack-33025" was historically chosen in http://crbug.com/139715. | 22 void GetTouchLogsOzone(system_logs::SystemLogsResponse* response) { |
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 // Callback for handing the outcome of GetTouchDeviceStatus(). Appends the | |
33 // collected log to the SystemLogsResponse map. | |
34 void OnStatusLogCollected(scoped_ptr<system_logs::SystemLogsResponse> response, | |
35 const system_logs::SysLogsSourceCallback& callback, | |
36 scoped_ptr<std::string> log) { | |
37 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
38 (*response)[kDeviceStatusLogDataKey] = *log; | |
39 | |
40 BrowserThread::PostTask( | |
41 BrowserThread::UI, FROM_HERE, | |
42 base::Bind(callback, base::Owned(response.release()))); | |
43 } | |
44 | |
45 // Collect touch HUD debug logs. This needs to be done on the UI thread. | |
46 void CollectTouchHudDebugLog(system_logs::SystemLogsResponse* response) { | |
47 scoped_ptr<base::DictionaryValue> dictionary = | 23 scoped_ptr<base::DictionaryValue> dictionary = |
48 ash::TouchHudDebug::GetAllAsDictionary(); | 24 ash::TouchHudDebug::GetAllAsDictionary(); |
49 if (!dictionary->empty()) { | 25 if (!dictionary->empty()) { |
50 std::string touch_log; | 26 std::string touch_log; |
51 JSONStringValueSerializer json(&touch_log); | 27 JSONStringValueSerializer json(&touch_log); |
52 json.set_pretty_print(true); | 28 json.set_pretty_print(true); |
53 if (json.Serialize(*dictionary) && !touch_log.empty()) | 29 if (json.Serialize(*dictionary) && !touch_log.empty()) |
54 (*response)[kHUDLogDataKey] = touch_log; | 30 (*response)[kHUDLogDataKey] = touch_log; |
55 } | 31 } |
| 32 |
| 33 // TODO(sheckylin): Add ozone touch log collection implementation. See |
| 34 // http://crbug.com/400022. |
| 35 NOTIMPLEMENTED(); |
56 } | 36 } |
57 | 37 |
58 } // namespace | 38 } // namespace |
59 | 39 |
60 namespace system_logs { | 40 namespace system_logs { |
61 | 41 |
62 void TouchLogSource::Fetch(const SysLogsSourceCallback& callback) { | 42 void TouchLogSource::Fetch(const SysLogsSourceCallback& callback) { |
63 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 43 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
64 DCHECK(!callback.is_null()); | 44 DCHECK(!callback.is_null()); |
65 | 45 |
66 scoped_ptr<SystemLogsResponse> response(new SystemLogsResponse); | 46 SystemLogsResponse* response = new SystemLogsResponse; |
67 CollectTouchHudDebugLog(response.get()); | 47 BrowserThread::PostBlockingPoolTaskAndReply( |
68 | 48 FROM_HERE, base::Bind(&GetTouchLogsOzone, response), |
69 // Collect touch device status logs. | 49 base::Bind(callback, base::Owned(response))); |
70 ui::OzonePlatform::GetInstance()->GetInputController()->GetTouchDeviceStatus( | |
71 base::Bind(&OnStatusLogCollected, base::Passed(&response), callback)); | |
72 } | 50 } |
73 | 51 |
74 } // namespace system_logs | 52 } // namespace system_logs |
OLD | NEW |