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" |
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 // 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) { |
23 scoped_ptr<base::DictionaryValue> dictionary = | 47 scoped_ptr<base::DictionaryValue> dictionary = |
24 ash::TouchHudDebug::GetAllAsDictionary(); | 48 ash::TouchHudDebug::GetAllAsDictionary(); |
25 if (!dictionary->empty()) { | 49 if (!dictionary->empty()) { |
26 std::string touch_log; | 50 std::string touch_log; |
27 JSONStringValueSerializer json(&touch_log); | 51 JSONStringValueSerializer json(&touch_log); |
28 json.set_pretty_print(true); | 52 json.set_pretty_print(true); |
29 if (json.Serialize(*dictionary) && !touch_log.empty()) | 53 if (json.Serialize(*dictionary) && !touch_log.empty()) |
30 (*response)[kHUDLogDataKey] = touch_log; | 54 (*response)[kHUDLogDataKey] = touch_log; |
31 } | 55 } |
32 | |
33 // TODO(sheckylin): Add ozone touch log collection implementation. See | |
34 // http://crbug.com/400022. | |
35 NOTIMPLEMENTED(); | |
36 } | 56 } |
37 | 57 |
38 } // namespace | 58 } // namespace |
39 | 59 |
40 namespace system_logs { | 60 namespace system_logs { |
41 | 61 |
42 void TouchLogSource::Fetch(const SysLogsSourceCallback& callback) { | 62 void TouchLogSource::Fetch(const SysLogsSourceCallback& callback) { |
43 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 63 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
44 DCHECK(!callback.is_null()); | 64 DCHECK(!callback.is_null()); |
45 | 65 |
46 SystemLogsResponse* response = new SystemLogsResponse; | 66 scoped_ptr<SystemLogsResponse> response(new SystemLogsResponse); |
47 BrowserThread::PostBlockingPoolTaskAndReply( | 67 CollectTouchHudDebugLog(response.get()); |
48 FROM_HERE, base::Bind(&GetTouchLogsOzone, response), | 68 |
49 base::Bind(callback, base::Owned(response))); | 69 // Collect touch device status logs. |
| 70 ui::OzonePlatform::GetInstance()->GetInputController()->GetTouchDeviceStatus( |
| 71 base::Bind(&OnStatusLogCollected, base::Passed(&response), callback)); |
50 } | 72 } |
51 | 73 |
52 } // namespace system_logs | 74 } // namespace system_logs |
OLD | NEW |