Chromium Code Reviews| Index: chrome/browser/chromeos/system/syslogs_fetcher.cc |
| diff --git a/chrome/browser/chromeos/system/syslogs_fetcher.cc b/chrome/browser/chromeos/system/syslogs_fetcher.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..efe888203cba91a72cea58a380734b19b3570d1f |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/system/syslogs_fetcher.cc |
| @@ -0,0 +1,56 @@ |
| +// 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/syslogs_fetcher.h" |
| + |
| +#include "base/bind.h" |
| +#include "base/bind_helpers.h" |
| +#include "base/command_line.h" |
| +#include "base/file_path.h" |
| +#include "base/file_util.h" |
| +#include "base/logging.h" |
| +#include "base/string_util.h" |
| +#include "base/memory/singleton.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "base/synchronization/lock.h" |
| +#include "base/threading/thread.h" |
| +#include "chrome/browser/chromeos/system/debugd_log_fetcher.h" |
| +#include "chrome/browser/memory_details.h" |
| +#include "content/public/browser/browser_thread.h" |
| + |
| +using content::BrowserThread; |
| + |
| +namespace chromeos { |
| +namespace system { |
| + |
| +SysLogsFetcher::SysLogsFetcher(SysLogsDataSources backends) |
| + : data_sources_(backends), response_(new SysInfoResponse), |
| + weak_ptr_factory_(this), responses_(backends.size()) { } |
| + |
| +void SysLogsFetcher::Fetch(SysLogsFetcherCallback request) { |
| + request_ = request; |
| + SysLogsDataSources::iterator it; |
| + responses_ = data_sources_.size(); |
| + for (it = data_sources_.begin(); it != data_sources_.end(); ++it) { |
| + (*it)->Fetch(base::Bind(&SysLogsFetcher::AddData, |
| + weak_ptr_factory_.GetWeakPtr())); |
| + LOG(ERROR)<<"Called fetcher."; |
|
rkc1
2012/08/04 01:15:05
Not error; maybe info?
and ) << "
tudalex(Chromium)
2012/08/05 01:15:12
Done.
|
| + } |
| +} |
| + |
| +void SysLogsFetcher::AddData(SysInfoResponse *data) { |
| + base::AutoLock lock(response_lock_); |
| + |
| + SysInfoResponse::iterator it; |
| + for (it = data->begin(); it != data->end(); ++it) |
| + (*response_)[it->first] = it->second; |
| + delete data; |
| + if (--responses_) |
|
rkc1
2012/08/04 01:15:05
Return but also delete all your data source instan
tudalex(Chromium)
2012/08/05 01:15:12
Done.
|
| + return; |
| + request_.Run(response_); |
| + BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, this); |
| +} |
| + |
| +} // namespace system |
| +} // namespace chromeos |