Commit 92a4cfcf authored by Luigi Semenzato's avatar Luigi Semenzato Committed by Commit Bot

chromeos log collection: collect user logs last

Chrome OS feedback reports often have missing sections, but it is
difficult to understand why because errors in fetching those sections
are logged in the chrome user logs, but those logs may be connected
before the failures occur.  This change forces the chrome user logs
to be collected after all the other logs.
    
BUG=chromium:753398
TEST=enabled feedbacks by adding these gn args:
TEST=is_official_build=true is_chrome_branded=true
TEST=then sent a report, and verified that it arrived with all files.

Change-Id: Ib08c3bfa5b89dd3afd050abaf52bcf231a5ba79d
Reviewed-on: https://chromium-review.googlesource.com/683336
Commit-Queue: Luigi Semenzato <semenzato@chromium.org>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#505202}
parent 5814c192
......@@ -65,9 +65,6 @@ void DebugDaemonLogSource::Fetch(const SysLogsSourceCallback& callback) {
client->GetWiMaxStatus(base::Bind(&DebugDaemonLogSource::OnGetWiMaxStatus,
weak_ptr_factory_.GetWeakPtr()));
++num_pending_requests_;
client->GetUserLogFiles(base::Bind(&DebugDaemonLogSource::OnGetUserLogFiles,
weak_ptr_factory_.GetWeakPtr()));
++num_pending_requests_;
if (scrub_) {
client->GetScrubbedBigLogs(base::Bind(&DebugDaemonLogSource::OnGetLogs,
......@@ -155,11 +152,11 @@ void DebugDaemonLogSource::OnGetUserLogFiles(
FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND},
base::Bind(&DebugDaemonLogSource::ReadUserLogFiles, user_log_files,
profile_dirs, response),
base::Bind(&DebugDaemonLogSource::MergeResponse,
base::Bind(&DebugDaemonLogSource::MergeUserLogFilesResponse,
weak_ptr_factory_.GetWeakPtr(), base::Owned(response)));
} else {
(*response_)[kUserLogFileKeyName] = kNotAvailable;
RequestCompleted();
callback_.Run(response_.get());
}
}
......@@ -187,11 +184,12 @@ void DebugDaemonLogSource::ReadUserLogFiles(
}
}
void DebugDaemonLogSource::MergeResponse(SystemLogsResponse* response) {
void DebugDaemonLogSource::MergeUserLogFilesResponse(
SystemLogsResponse* response) {
for (SystemLogsResponse::const_iterator it = response->begin();
it != response->end(); ++it)
response_->insert(*it);
RequestCompleted();
callback_.Run(response_.get());
}
void DebugDaemonLogSource::RequestCompleted() {
......@@ -201,7 +199,12 @@ void DebugDaemonLogSource::RequestCompleted() {
--num_pending_requests_;
if (num_pending_requests_ > 0)
return;
callback_.Run(response_.get());
// When all other logs are collected, fetch the user logs, because any errors
// fetching the other logs is reported in the user logs.
chromeos::DebugDaemonClient* client =
chromeos::DBusThreadManager::Get()->GetDebugDaemonClient();
client->GetUserLogFiles(base::Bind(&DebugDaemonLogSource::OnGetUserLogFiles,
weak_ptr_factory_.GetWeakPtr()));
}
} // namespace system_logs
......@@ -49,10 +49,13 @@ class DebugDaemonLogSource : public SystemLogsSource {
SystemLogsResponse* response);
// Merge the responses from ReadUserLogFiles into the main response dict and
// call RequestComplete to indicate that the user log files read is complete.
void MergeResponse(SystemLogsResponse* response);
// invoke the callback_.Run method with the assumption that all other logs
// have already been collected.
void MergeUserLogFilesResponse(SystemLogsResponse* response);
// Sends the data to the callback_ when all the requests are completed
// When all the requests are completed, send one last request to collect the
// user logs and complete the collection by invoking the callback's Run
// method.
void RequestCompleted();
std::unique_ptr<SystemLogsResponse> response_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment