summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgauravsh@chromium.org <gauravsh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-05 23:07:05 +0000
committergauravsh@chromium.org <gauravsh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-05 23:07:05 +0000
commite45fb1adac21011c19c462f4e61e6bb8a3429aca (patch)
treea8325b4cb2aa4c5ab8eda2f60c91e1545c4b1d54
parent9fa87eda479a80faffe61d75135bd6d6036440a6 (diff)
downloadchromium_src-e45fb1adac21011c19c462f4e61e6bb8a3429aca.zip
chromium_src-e45fb1adac21011c19c462f4e61e6bb8a3429aca.tar.gz
chromium_src-e45fb1adac21011c19c462f4e61e6bb8a3429aca.tar.bz2
Collect user logs that debugd can not access
Debugd can't access anything inside a user's cryptohome. So, get a list of user logs files to collect from debugd, and then read them. BUG=chromium-os:34817 TEST=Navigate to chrome://system and verify chrome_user_log, login-times and logout-times now show up. Review URL: https://chromiumcodereview.appspot.com/11035014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@166065 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/system_logs/debug_daemon_log_source.cc41
-rw-r--r--chrome/browser/chromeos/system_logs/debug_daemon_log_source.h13
-rw-r--r--chrome/browser/chromeos/system_logs/system_logs_fetcher.cc1
-rw-r--r--chromeos/dbus/debug_daemon_client.cc31
-rw-r--r--chromeos/dbus/debug_daemon_client.h11
-rw-r--r--chromeos/dbus/mock_debug_daemon_client.h3
6 files changed, 87 insertions, 13 deletions
diff --git a/chrome/browser/chromeos/system_logs/debug_daemon_log_source.cc b/chrome/browser/chromeos/system_logs/debug_daemon_log_source.cc
index d642fbd..22f4ea8 100644
--- a/chrome/browser/chromeos/system_logs/debug_daemon_log_source.cc
+++ b/chrome/browser/chromeos/system_logs/debug_daemon_log_source.cc
@@ -6,6 +6,7 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
+#include "base/file_util.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
@@ -22,6 +23,7 @@ const char kNotAvailable[] = "<not available>";
const char kRoutesKeyName[] = "routes";
const char kNetworkStatusKeyName[] = "network-status";
const char kModemStatusKeyName[] = "modem-status";
+const char kUserLogFileKeyName[] = "user_log_files";
} // namespace
namespace chromeos {
@@ -63,6 +65,9 @@ void DebugDaemonLogSource::Fetch(const SysLogsSourceCallback& callback) {
client->GetAllLogs(base::Bind(&DebugDaemonLogSource::OnGetLogs,
weak_ptr_factory_.GetWeakPtr()));
++num_pending_requests_;
+ client->GetUserLogFiles(base::Bind(&DebugDaemonLogSource::OnGetUserLogFiles,
+ weak_ptr_factory_.GetWeakPtr()));
+ ++num_pending_requests_;
}
void DebugDaemonLogSource::OnGetRoutes(bool succeeded,
@@ -99,8 +104,7 @@ void DebugDaemonLogSource::OnGetModemStatus(bool succeeded,
}
void DebugDaemonLogSource::OnGetLogs(bool /* succeeded */,
- const std::map<std::string,
- std::string>& logs) {
+ const KeyValueMap& logs) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
// We ignore 'succeeded' for this callback - we want to display as much of the
@@ -110,6 +114,39 @@ void DebugDaemonLogSource::OnGetLogs(bool /* succeeded */,
RequestCompleted();
}
+void DebugDaemonLogSource::OnGetUserLogFiles(
+ bool succeeded,
+ const KeyValueMap& user_log_files) {
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+ if (succeeded) {
+ content::BrowserThread::PostBlockingPoolTaskAndReply(
+ FROM_HERE,
+ base::Bind(
+ &DebugDaemonLogSource::ReadUserLogFiles,
+ weak_ptr_factory_.GetWeakPtr(),
+ user_log_files),
+ base::Bind(&DebugDaemonLogSource::RequestCompleted,
+ weak_ptr_factory_.GetWeakPtr()));
+ } else {
+ (*response_)[kUserLogFileKeyName] = kNotAvailable;
+ RequestCompleted();
+ }
+}
+
+void DebugDaemonLogSource::ReadUserLogFiles(const KeyValueMap& user_log_files) {
+ for (KeyValueMap::const_iterator it = user_log_files.begin();
+ it != user_log_files.end();
+ ++it) {
+ std::string value;
+ bool read_success = file_util::ReadFileToString(
+ FilePath(it->second), &value);
+ if (read_success && !value.empty())
+ (*response_)[it->first] = value;
+ else
+ (*response_)[it->second] = kNotAvailable;
+ }
+}
+
void DebugDaemonLogSource::RequestCompleted() {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
DCHECK(!callback_.is_null());
diff --git a/chrome/browser/chromeos/system_logs/debug_daemon_log_source.h b/chrome/browser/chromeos/system_logs/debug_daemon_log_source.h
index dd483d5..1e51958 100644
--- a/chrome/browser/chromeos/system_logs/debug_daemon_log_source.h
+++ b/chrome/browser/chromeos/system_logs/debug_daemon_log_source.h
@@ -27,12 +27,21 @@ class DebugDaemonLogSource : public SystemLogsSource {
virtual void Fetch(const SysLogsSourceCallback& callback) OVERRIDE;
private:
- // Callbacks for the 4 different dbus calls
+ typedef std::map<std::string, std::string> KeyValueMap;
+
+ // Callbacks for the 5 different dbus calls to debugd.
void OnGetRoutes(bool succeeded, const std::vector<std::string>& routes);
void OnGetNetworkStatus(bool succeeded, const std::string& status);
void OnGetModemStatus(bool succeeded, const std::string& status);
void OnGetLogs(bool succeeded,
- const std::map<std::string, std::string>& logs);
+ const KeyValueMap& logs);
+ void OnGetUserLogFiles(bool succeeded,
+ const KeyValueMap& logs);
+
+ // Read the contents of the specified user logs files and adds it to
+ // the response.
+ void ReadUserLogFiles(const KeyValueMap& user_log_files);
+
// Sends the data to the callback_ when all the requests are completed
void RequestCompleted();
diff --git a/chrome/browser/chromeos/system_logs/system_logs_fetcher.cc b/chrome/browser/chromeos/system_logs/system_logs_fetcher.cc
index e3b2add..ea7fa9e 100644
--- a/chrome/browser/chromeos/system_logs/system_logs_fetcher.cc
+++ b/chrome/browser/chromeos/system_logs/system_logs_fetcher.cc
@@ -27,6 +27,7 @@ SystemLogsFetcher::SystemLogsFetcher()
data_sources_.push_back(new CommandLineLogSource());
data_sources_.push_back(new LsbReleaseLogSource());
data_sources_.push_back(new MemoryDetailsLogSource());
+
num_pending_requests_ = data_sources_.size();
}
diff --git a/chromeos/dbus/debug_daemon_client.cc b/chromeos/dbus/debug_daemon_client.cc
index 05d3b39..4bd6464 100644
--- a/chromeos/dbus/debug_daemon_client.cc
+++ b/chromeos/dbus/debug_daemon_client.cc
@@ -246,10 +246,10 @@ class DebugDaemonClientImpl : public DebugDaemonClient {
callback));
}
- virtual void GetAllLogs(const GetAllLogsCallback& callback)
+ virtual void GetAllLogs(const GetLogsCallback& callback)
OVERRIDE {
dbus::MethodCall method_call(debugd::kDebugdInterface,
- "GetAllLogs");
+ debugd::kGetAllLogs);
debugdaemon_proxy_->CallMethod(
&method_call,
dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
@@ -258,6 +258,18 @@ class DebugDaemonClientImpl : public DebugDaemonClient {
callback));
}
+ virtual void GetUserLogFiles(
+ const GetLogsCallback& callback) OVERRIDE {
+ dbus::MethodCall method_call(debugd::kDebugdInterface,
+ debugd::kGetUserLogFiles);
+ debugdaemon_proxy_->CallMethod(
+ &method_call,
+ dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
+ base::Bind(&DebugDaemonClientImpl::OnGetUserLogFiles,
+ weak_ptr_factory_.GetWeakPtr(),
+ callback));
+ }
+
virtual void StartSystemTracing() OVERRIDE {
dbus::MethodCall method_call(
debugd::kDebugdInterface,
@@ -395,7 +407,7 @@ class DebugDaemonClientImpl : public DebugDaemonClient {
}
void OnGetModemStatus(const GetModemStatusCallback& callback,
- dbus::Response* response) {
+ dbus::Response* response) {
std::string status;
if (response && dbus::MessageReader(response).PopString(&status))
callback.Run(true, status);
@@ -412,7 +424,7 @@ class DebugDaemonClientImpl : public DebugDaemonClient {
callback.Run(false, "");
}
- void OnGetAllLogs(const GetAllLogsCallback& callback,
+ void OnGetAllLogs(const GetLogsCallback& callback,
dbus::Response* response) {
std::map<std::string, std::string> logs;
bool broken = false; // did we see a broken (k,v) pair?
@@ -435,6 +447,11 @@ class DebugDaemonClientImpl : public DebugDaemonClient {
callback.Run(!sub_reader.HasMoreData() && !broken, logs);
}
+ void OnGetUserLogFiles(const GetLogsCallback& callback,
+ dbus::Response* response) {
+ return OnGetAllLogs(callback, response);
+ }
+
// Called when a response for StartSystemTracing() is received.
void OnStartSystemTracing(dbus::Response* response) {
if (!response) {
@@ -536,7 +553,11 @@ class DebugDaemonClientStubImpl : public DebugDaemonClient {
const GetNetworkInterfacesCallback& callback) OVERRIDE {
callback.Run(false, "");
}
- virtual void GetAllLogs(const GetAllLogsCallback& callback) OVERRIDE {
+ virtual void GetAllLogs(const GetLogsCallback& callback) OVERRIDE {
+ std::map<std::string, std::string> empty;
+ callback.Run(false, empty);
+ }
+ virtual void GetUserLogFiles(const GetLogsCallback& callback) OVERRIDE {
std::map<std::string, std::string> empty;
callback.Run(false, empty);
}
diff --git a/chromeos/dbus/debug_daemon_client.h b/chromeos/dbus/debug_daemon_client.h
index 8159354..073189c 100644
--- a/chromeos/dbus/debug_daemon_client.h
+++ b/chromeos/dbus/debug_daemon_client.h
@@ -75,11 +75,16 @@ class CHROMEOS_EXPORT DebugDaemonClient {
virtual void GetNetworkInterfaces(
const GetNetworkInterfacesCallback& callback) = 0;
- // Called once GetAllLogs() is complete.
+ // Callback type for GetAllLogs() or GetUserLogFiles().
typedef base::Callback<void(bool succeeded,
const std::map<std::string, std::string>& logs)>
- GetAllLogsCallback;
- virtual void GetAllLogs(const GetAllLogsCallback& callback) = 0;
+ GetLogsCallback;
+
+ // Gets all logs collected by debugd.
+ virtual void GetAllLogs(const GetLogsCallback& callback) = 0;
+
+ // Gets list of user log files that must be read by Chrome.
+ virtual void GetUserLogFiles(const GetLogsCallback& callback) = 0;
// Requests to start system/kernel tracing.
virtual void StartSystemTracing() = 0;
diff --git a/chromeos/dbus/mock_debug_daemon_client.h b/chromeos/dbus/mock_debug_daemon_client.h
index fe8d933..56cd2c4 100644
--- a/chromeos/dbus/mock_debug_daemon_client.h
+++ b/chromeos/dbus/mock_debug_daemon_client.h
@@ -23,7 +23,8 @@ class MockDebugDaemonClient : public DebugDaemonClient {
MOCK_METHOD1(GetNetworkStatus, void(const GetNetworkStatusCallback&));
MOCK_METHOD1(GetModemStatus, void(const GetModemStatusCallback&));
MOCK_METHOD1(GetNetworkInterfaces, void(const GetNetworkInterfacesCallback&));
- MOCK_METHOD1(GetAllLogs, void(const GetAllLogsCallback&));
+ MOCK_METHOD1(GetAllLogs, void(const GetLogsCallback&));
+ MOCK_METHOD1(GetUserLogFiles, void(const GetLogsCallback&));
MOCK_METHOD1(RequestStopSystemTracing,
bool(const StopSystemTracingCallback&));
MOCK_METHOD0(StartSystemTracing, void());