| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/chromeos/syslogs/syslogs_fetcher.h" |
| 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" |
| 9 #include "chrome/browser/chromeos/syslogs/commandline_fetcher.h" |
| 10 #include "chrome/browser/chromeos/syslogs/debugd_log_fetcher.h" |
| 11 #include "chrome/browser/chromeos/syslogs/memorydetails_fetcher.h" |
| 12 #include "chrome/browser/chromeos/syslogs/lsbrelease_fetcher.h" |
| 13 #include "content/public/browser/browser_thread.h" |
| 14 |
| 15 using content::BrowserThread; |
| 16 |
| 17 namespace chromeos { |
| 18 |
| 19 AggregatedSystemLogsFetcher::AggregatedSystemLogsFetcher() |
| 20 : response_(new SystemLogsResponse), num_responses_(0), |
| 21 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { |
| 22 |
| 23 // Debug Daemon data source. |
| 24 data_sources_.push_back(new DebugDaemonLogFetcher()); |
| 25 |
| 26 // Chrome data sources. |
| 27 data_sources_.push_back(new CommandLineFetcher()); |
| 28 data_sources_.push_back(new LSBReleaseFetcher()); |
| 29 data_sources_.push_back(new MemoryDetailsFetcher()); |
| 30 num_responses_ = data_sources_.size(); |
| 31 } |
| 32 |
| 33 void AggregatedSystemLogsFetcher::Fetch(const SysLogsFetcherCallback& request) { |
| 34 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 35 |
| 36 request_ = request; |
| 37 SysLogsDataSources::iterator it; |
| 38 for (it = data_sources_.begin(); it != data_sources_.end(); ++it) { |
| 39 (*it)->Fetch(base::Bind(&AggregatedSystemLogsFetcher::AddData, |
| 40 weak_ptr_factory_.GetWeakPtr())); |
| 41 } |
| 42 } |
| 43 |
| 44 void AggregatedSystemLogsFetcher::AddData(SystemLogsResponse* response) { |
| 45 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 46 |
| 47 for (SystemLogsResponse::iterator it = response->begin(); |
| 48 it != response->end(); |
| 49 ++it) { |
| 50 (*response_)[it->first] = it->second; |
| 51 } |
| 52 delete response; |
| 53 |
| 54 if (--num_responses_) |
| 55 return; |
| 56 |
| 57 |
| 58 for (SysLogsDataSources::iterator it = data_sources_.begin(); |
| 59 it != data_sources_.end(); |
| 60 ++it) { |
| 61 delete *it; |
| 62 } |
| 63 request_.Run(response_); |
| 64 BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, this); |
| 65 } |
| 66 |
| 67 } // namespace chromeos |
| 68 |
| OLD | NEW |