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

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

Issue 1036723003: favor DCHECK_CURRENTLY_ON for better logs in chrome/browser/chromeos/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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" 9 #include "base/bind_helpers.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 BrowserThread::PostBlockingPoolTask( 112 BrowserThread::PostBlockingPoolTask(
113 FROM_HERE, base::Bind(CleanupEventLog, base::Passed(&log_paths))); 113 FROM_HERE, base::Bind(CleanupEventLog, base::Passed(&log_paths)));
114 } 114 }
115 115
116 // Callback for handing the outcome of GetTouchEventLog(). 116 // Callback for handing the outcome of GetTouchEventLog().
117 // 117 //
118 // This is the end of the whole touch log collection process. 118 // This is the end of the whole touch log collection process.
119 void OnEventLogCollected(scoped_ptr<system_logs::SystemLogsResponse> response, 119 void OnEventLogCollected(scoped_ptr<system_logs::SystemLogsResponse> response,
120 const system_logs::SysLogsSourceCallback& callback, 120 const system_logs::SysLogsSourceCallback& callback,
121 scoped_ptr<std::vector<base::FilePath>> log_paths) { 121 scoped_ptr<std::vector<base::FilePath>> log_paths) {
122 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 122 DCHECK_CURRENTLY_ON(BrowserThread::UI);
123 123
124 // We cannot eliminate these temporaries and inline these closures because the 124 // We cannot eliminate these temporaries and inline these closures because the
125 // compiler may call release() before get(). 125 // compiler may call release() before get().
126 const base::Closure pack_closure = 126 const base::Closure pack_closure =
127 base::Bind(&PackEventLog, base::Unretained(response.get()), 127 base::Bind(&PackEventLog, base::Unretained(response.get()),
128 base::Passed(&log_paths)); 128 base::Passed(&log_paths));
129 const base::Closure callback_closure = 129 const base::Closure callback_closure =
130 base::Bind(callback, base::Owned(response.release())); 130 base::Bind(callback, base::Owned(response.release()));
131 BrowserThread::PostBlockingPoolTaskAndReply(FROM_HERE, pack_closure, 131 BrowserThread::PostBlockingPoolTaskAndReply(FROM_HERE, pack_closure,
132 callback_closure); 132 callback_closure);
133 } 133 }
134 134
135 // Callback for handing the outcome of GetTouchDeviceStatus(). 135 // Callback for handing the outcome of GetTouchDeviceStatus().
136 // 136 //
137 // Appends the collected log to the SystemLogsResponse map. Also goes on to 137 // Appends the collected log to the SystemLogsResponse map. Also goes on to
138 // collect touch event logs. 138 // collect touch event logs.
139 void OnStatusLogCollected(scoped_ptr<system_logs::SystemLogsResponse> response, 139 void OnStatusLogCollected(scoped_ptr<system_logs::SystemLogsResponse> response,
140 const system_logs::SysLogsSourceCallback& callback, 140 const system_logs::SysLogsSourceCallback& callback,
141 scoped_ptr<std::string> log) { 141 scoped_ptr<std::string> log) {
142 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 142 DCHECK_CURRENTLY_ON(BrowserThread::UI);
143 (*response)[kDeviceStatusLogDataKey] = *log; 143 (*response)[kDeviceStatusLogDataKey] = *log;
144 144
145 // Collect touch event logs. 145 // Collect touch event logs.
146 const base::FilePath kBaseLogPath(kTouchEventLogDir); 146 const base::FilePath kBaseLogPath(kTouchEventLogDir);
147 ui::OzonePlatform::GetInstance()->GetInputController()->GetTouchEventLog( 147 ui::OzonePlatform::GetInstance()->GetInputController()->GetTouchEventLog(
148 kBaseLogPath, 148 kBaseLogPath,
149 base::Bind(&OnEventLogCollected, base::Passed(&response), callback)); 149 base::Bind(&OnEventLogCollected, base::Passed(&response), callback));
150 } 150 }
151 151
152 // Collect touch HUD debug logs. This needs to be done on the UI thread. 152 // Collect touch HUD debug logs. This needs to be done on the UI thread.
153 void CollectTouchHudDebugLog(system_logs::SystemLogsResponse* response) { 153 void CollectTouchHudDebugLog(system_logs::SystemLogsResponse* response) {
154 scoped_ptr<base::DictionaryValue> dictionary = 154 scoped_ptr<base::DictionaryValue> dictionary =
155 ash::TouchHudDebug::GetAllAsDictionary(); 155 ash::TouchHudDebug::GetAllAsDictionary();
156 if (!dictionary->empty()) { 156 if (!dictionary->empty()) {
157 std::string touch_log; 157 std::string touch_log;
158 JSONStringValueSerializer json(&touch_log); 158 JSONStringValueSerializer json(&touch_log);
159 json.set_pretty_print(true); 159 json.set_pretty_print(true);
160 if (json.Serialize(*dictionary) && !touch_log.empty()) 160 if (json.Serialize(*dictionary) && !touch_log.empty())
161 (*response)[kHUDLogDataKey] = touch_log; 161 (*response)[kHUDLogDataKey] = touch_log;
162 } 162 }
163 } 163 }
164 164
165 } // namespace 165 } // namespace
166 166
167 namespace system_logs { 167 namespace system_logs {
168 168
169 void TouchLogSource::Fetch(const SysLogsSourceCallback& callback) { 169 void TouchLogSource::Fetch(const SysLogsSourceCallback& callback) {
170 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 170 DCHECK_CURRENTLY_ON(BrowserThread::UI);
171 DCHECK(!callback.is_null()); 171 DCHECK(!callback.is_null());
172 172
173 scoped_ptr<SystemLogsResponse> response(new SystemLogsResponse); 173 scoped_ptr<SystemLogsResponse> response(new SystemLogsResponse);
174 CollectTouchHudDebugLog(response.get()); 174 CollectTouchHudDebugLog(response.get());
175 175
176 // Collect touch device status logs. 176 // Collect touch device status logs.
177 ui::OzonePlatform::GetInstance()->GetInputController()->GetTouchDeviceStatus( 177 ui::OzonePlatform::GetInstance()->GetInputController()->GetTouchDeviceStatus(
178 base::Bind(&OnStatusLogCollected, base::Passed(&response), callback)); 178 base::Bind(&OnStatusLogCollected, base::Passed(&response), callback));
179 } 179 }
180 180
181 } // namespace system_logs 181 } // namespace system_logs
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698