Chromium Code Reviews| Index: chrome/browser/chromeos/system_logs/user_log_source.cc |
| diff --git a/chrome/browser/chromeos/system_logs/user_log_source.cc b/chrome/browser/chromeos/system_logs/user_log_source.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..807ba3258070ad029ab7bb8b003d4c18c3e17ae8 |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/system_logs/user_log_source.cc |
| @@ -0,0 +1,53 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/chromeos/system_logs/user_log_source.h" |
| + |
| +#include <string> |
| + |
| +#include "base/bind.h" |
| +#include "base/bind_helpers.h" |
| +#include "base/file_path.h" |
| +#include "base/file_util.h" |
| +#include "content/public/browser/browser_thread.h" |
| + |
| +using content::BrowserThread; |
| + |
| +namespace chromeos { |
| + |
| +void UserLogSource::Fetch(const SysLogsSourceCallback& callback) { |
| + DCHECK(!callback.is_null()); |
| + |
| + SystemLogsResponse* response = new SystemLogsResponse; |
| + BrowserThread::PostBlockingPoolTaskAndReply( |
| + FROM_HERE, |
| + base::Bind(&UserLogSource::ReadUserLogs, response), |
| + base::Bind(callback, |
| + base::Owned(response))); |
| +} |
| + |
| +struct KeyFilePair { |
| + const char* key; |
| + const char* file; |
| +}; |
| + |
| +// static |
| +void UserLogSource::ReadUserLogs(SystemLogsResponse* response) { |
| + KeyFilePair user_logs[] = { |
| + {"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
|
| + {"login-times", "/home/chronos/user/login-times"}, |
| + {"logout-times", "/home/chronos/user/logout-times"} |
| + }; |
| + for (size_t i = 0; i < arraysize(user_logs); ++i) { |
| + std::string value; |
| + bool read_success = file_util::ReadFileToString( |
| + FilePath(user_logs[i].file), &value); |
| + if (read_success && !value.empty()) |
| + (*response)[user_logs[i].key] = value; |
| + else |
| + (*response)[user_logs[i].key] = "<no value>"; |
| + } |
| +} |
| + |
| +} // namespace chromeos |