| Index: chrome/browser/chromeos/syslogs/syslogs_fetcher.cc
|
| diff --git a/chrome/browser/chromeos/syslogs/syslogs_fetcher.cc b/chrome/browser/chromeos/syslogs/syslogs_fetcher.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..91d1cc83906d71b00244d733b1fd56772b0d1b72
|
| --- /dev/null
|
| +++ b/chrome/browser/chromeos/syslogs/syslogs_fetcher.cc
|
| @@ -0,0 +1,68 @@
|
| +// 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/syslogs/syslogs_fetcher.h"
|
| +
|
| +#include "base/bind.h"
|
| +#include "base/bind_helpers.h"
|
| +#include "chrome/browser/chromeos/syslogs/commandline_fetcher.h"
|
| +#include "chrome/browser/chromeos/syslogs/debugd_log_fetcher.h"
|
| +#include "chrome/browser/chromeos/syslogs/memorydetails_fetcher.h"
|
| +#include "chrome/browser/chromeos/syslogs/lsbrelease_fetcher.h"
|
| +#include "content/public/browser/browser_thread.h"
|
| +
|
| +using content::BrowserThread;
|
| +
|
| +namespace chromeos {
|
| +
|
| +AggregatedSystemLogsFetcher::AggregatedSystemLogsFetcher()
|
| + : response_(new SystemLogsResponse), num_responses_(0),
|
| + ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
|
| +
|
| + // Debug Daemon data source.
|
| + data_sources_.push_back(new DebugDaemonLogFetcher());
|
| +
|
| + // Chrome data sources.
|
| + data_sources_.push_back(new CommandLineFetcher());
|
| + data_sources_.push_back(new LSBReleaseFetcher());
|
| + data_sources_.push_back(new MemoryDetailsFetcher());
|
| + num_responses_ = data_sources_.size();
|
| +}
|
| +
|
| +void AggregatedSystemLogsFetcher::Fetch(const SysLogsFetcherCallback& request) {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| +
|
| + request_ = request;
|
| + SysLogsDataSources::iterator it;
|
| + for (it = data_sources_.begin(); it != data_sources_.end(); ++it) {
|
| + (*it)->Fetch(base::Bind(&AggregatedSystemLogsFetcher::AddData,
|
| + weak_ptr_factory_.GetWeakPtr()));
|
| + }
|
| +}
|
| +
|
| +void AggregatedSystemLogsFetcher::AddData(SystemLogsResponse* response) {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| +
|
| + for (SystemLogsResponse::iterator it = response->begin();
|
| + it != response->end();
|
| + ++it) {
|
| + (*response_)[it->first] = it->second;
|
| + }
|
| + delete response;
|
| +
|
| + if (--num_responses_)
|
| + return;
|
| +
|
| +
|
| + for (SysLogsDataSources::iterator it = data_sources_.begin();
|
| + it != data_sources_.end();
|
| + ++it) {
|
| + delete *it;
|
| + }
|
| + request_.Run(response_);
|
| + BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, this);
|
| +}
|
| +
|
| +} // namespace chromeos
|
| +
|
|
|