Chromium Code Reviews| 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/system/syslogs_fetcher.h" | |
| 6 | |
| 7 #include "base/bind.h" | |
| 8 #include "base/bind_helpers.h" | |
| 9 #include "base/command_line.h" | |
| 10 #include "base/file_path.h" | |
| 11 #include "base/file_util.h" | |
| 12 #include "base/logging.h" | |
| 13 #include "base/string_util.h" | |
| 14 #include "base/memory/singleton.h" | |
| 15 #include "base/memory/weak_ptr.h" | |
| 16 #include "base/synchronization/lock.h" | |
| 17 #include "base/threading/thread.h" | |
| 18 #include "chrome/browser/chromeos/system/debugd_log_fetcher.h" | |
| 19 #include "chrome/browser/memory_details.h" | |
| 20 #include "content/public/browser/browser_thread.h" | |
| 21 | |
| 22 using content::BrowserThread; | |
| 23 | |
| 24 namespace chromeos { | |
| 25 namespace system { | |
| 26 | |
| 27 SysLogsFetcher::SysLogsFetcher(SysLogsDataSources backends) | |
| 28 : data_sources_(backends), response_(new SysInfoResponse), | |
| 29 weak_ptr_factory_(this), responses_(backends.size()) { } | |
| 30 | |
| 31 void SysLogsFetcher::Fetch(SysLogsFetcherCallback request) { | |
| 32 request_ = request; | |
| 33 SysLogsDataSources::iterator it; | |
| 34 responses_ = data_sources_.size(); | |
| 35 for (it = data_sources_.begin(); it != data_sources_.end(); ++it) { | |
| 36 (*it)->Fetch(base::Bind(&SysLogsFetcher::AddData, | |
| 37 weak_ptr_factory_.GetWeakPtr())); | |
| 38 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.
| |
| 39 } | |
| 40 } | |
| 41 | |
| 42 void SysLogsFetcher::AddData(SysInfoResponse *data) { | |
| 43 base::AutoLock lock(response_lock_); | |
| 44 | |
| 45 SysInfoResponse::iterator it; | |
| 46 for (it = data->begin(); it != data->end(); ++it) | |
| 47 (*response_)[it->first] = it->second; | |
| 48 delete data; | |
| 49 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.
| |
| 50 return; | |
| 51 request_.Run(response_); | |
| 52 BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, this); | |
| 53 } | |
| 54 | |
| 55 } // namespace system | |
| 56 } // namespace chromeos | |
| OLD | NEW |