Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/chromeos/system_logs/user_log_source.h" | |
| 6 | |
| 7 #include <string> | |
| 8 | |
| 9 #include "base/bind.h" | |
| 10 #include "base/bind_helpers.h" | |
| 11 #include "base/file_path.h" | |
| 12 #include "base/file_util.h" | |
| 13 #include "content/public/browser/browser_thread.h" | |
| 14 | |
| 15 using content::BrowserThread; | |
| 16 | |
| 17 namespace chromeos { | |
| 18 | |
| 19 void UserLogSource::Fetch(const SysLogsSourceCallback& callback) { | |
| 20 DCHECK(!callback.is_null()); | |
| 21 | |
| 22 SystemLogsResponse* response = new SystemLogsResponse; | |
| 23 BrowserThread::PostBlockingPoolTaskAndReply( | |
| 24 FROM_HERE, | |
| 25 base::Bind(&UserLogSource::ReadUserLogs, response), | |
| 26 base::Bind(callback, | |
| 27 base::Owned(response))); | |
| 28 } | |
| 29 | |
| 30 struct KeyFilePair { | |
| 31 const char* key; | |
| 32 const char* file; | |
| 33 }; | |
| 34 | |
| 35 // static | |
| 36 void UserLogSource::ReadUserLogs(SystemLogsResponse* response) { | |
| 37 KeyFilePair user_logs[] = { | |
| 38 {"chrome_user_log", "/home/chronos/user/log/chrome"}, | |
|
DaveMoore
2012/10/08 18:10:28
I would prefer that the knowledge about exactly wh
gauravsh
2012/10/08 18:13:59
When you say server, do you mean the feedback serv
| |
| 39 {"login-times", "/home/chronos/user/login-times"}, | |
| 40 {"logout-times", "/home/chronos/user/logout-times"} | |
| 41 }; | |
| 42 for (size_t i = 0; i < arraysize(user_logs); ++i) { | |
| 43 std::string value; | |
| 44 bool read_success = file_util::ReadFileToString( | |
| 45 FilePath(user_logs[i].file), &value); | |
| 46 if (read_success && !value.empty()) | |
| 47 (*response)[user_logs[i].key] = value; | |
| 48 else | |
| 49 (*response)[user_logs[i].key] = "<no value>"; | |
| 50 } | |
| 51 } | |
| 52 | |
| 53 } // namespace chromeos | |
| OLD | NEW |