Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: chrome/browser/chromeos/syslogs/syslogs_fetcher.cc

Issue 10827130: Refactoring the SysInfoProvider. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 "content/public/browser/browser_thread.h"
10
11 using content::BrowserThread;
12
13 namespace chromeos {
14
15
16 SysLogsFetcher::SysLogsFetcher(SysLogsDataSources backends)
17 : data_sources_(backends), response_(new SysLogsResponse),
18 responses_(backends.size()),
19 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {}
20
21 void SysLogsFetcher::Fetch(SysLogsFetcherCallback request) {
22 request_ = request;
23 SysLogsDataSources::iterator it;
24 responses_ = data_sources_.size();
25 for (it = data_sources_.begin(); it != data_sources_.end(); ++it) {
26 (*it)->Fetch(base::Bind(&SysLogsFetcher::AddData,
27 weak_ptr_factory_.GetWeakPtr()));
28 }
29 }
30
31 void SysLogsFetcher::AddData(SysLogsResponse* data) {
32 base::AutoLock lock(response_lock_);
satorux1 2012/08/07 01:15:07 why is Lock needed? On what thread this function i
tudalex(Chromium) 2012/08/07 23:46:54 Lock was not needed. Added checks and also moved t
satorux1 2012/08/08 22:01:03 I'd suggest add more of these DCHECKs in other fil
33
34 SysLogsResponse::iterator it;
35 for (it = data->begin(); it != data->end(); ++it){
36 (*response_)[it->first] = it->second;
37 }
38 delete data;
39
40 if (--responses_)
41 return;
42
43 SysLogsDataSources::iterator ds_it;
44 for (ds_it = data_sources_.begin(); ds_it != data_sources_.end(); ++ds_it) {
45 delete *ds_it;
46 }
47 request_.Run(response_);
48 BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, this);
49 }
50
51 } // namespace chromeos
52
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698