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

Side by Side Diff: chrome/browser/feedback/system_logs/system_logs_fetcher_base.cc

Issue 1530403003: Add anonymizer tool (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase to ToT Created 4 years, 11 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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/feedback/system_logs/system_logs_fetcher_base.h" 5 #include "chrome/browser/feedback/system_logs/system_logs_fetcher_base.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 18 matching lines...) Expand all
29 SystemLogsFetcherBase::~SystemLogsFetcherBase() {} 29 SystemLogsFetcherBase::~SystemLogsFetcherBase() {}
30 30
31 void SystemLogsFetcherBase::Fetch(const SysLogsFetcherCallback& callback) { 31 void SystemLogsFetcherBase::Fetch(const SysLogsFetcherCallback& callback) {
32 DCHECK_CURRENTLY_ON(BrowserThread::UI); 32 DCHECK_CURRENTLY_ON(BrowserThread::UI);
33 DCHECK(callback_.is_null()); 33 DCHECK(callback_.is_null());
34 DCHECK(!callback.is_null()); 34 DCHECK(!callback.is_null());
35 35
36 callback_ = callback; 36 callback_ = callback;
37 for (size_t i = 0; i < data_sources_.size(); ++i) { 37 for (size_t i = 0; i < data_sources_.size(); ++i) {
38 VLOG(1) << "Fetching SystemLogSource: " << data_sources_[i]->source_name(); 38 VLOG(1) << "Fetching SystemLogSource: " << data_sources_[i]->source_name();
39 data_sources_[i]->Fetch(base::Bind(&SystemLogsFetcherBase::AddResponse, 39 data_sources_[i]->Fetch(base::Bind(&SystemLogsFetcherBase::OnFetched,
40 AsWeakPtr(), 40 AsWeakPtr(),
41 data_sources_[i]->source_name())); 41 data_sources_[i]->source_name()));
42 } 42 }
43 } 43 }
44 44
45 void SystemLogsFetcherBase::AddResponse(const std::string& source_name, 45 void SystemLogsFetcherBase::OnFetched(const std::string& source_name,
46 SystemLogsResponse* response) { 46 SystemLogsResponse* response) {
47 DCHECK_CURRENTLY_ON(BrowserThread::UI); 47 DCHECK_CURRENTLY_ON(BrowserThread::UI);
48 48
49 VLOG(1) << "Received SystemLogSource: " << source_name; 49 VLOG(1) << "Received SystemLogSource: " << source_name;
50 50
51 Rewrite(source_name, response);
52 AddResponse(source_name, response);
53 }
54
55 void SystemLogsFetcherBase::Rewrite(const std::string& /* source_name */,
56 SystemLogsResponse* /* response */) {
57 // This implementation in the base class is intentionally empty.
58 }
59
60 void SystemLogsFetcherBase::AddResponse(const std::string& source_name,
61 SystemLogsResponse* response) {
51 for (SystemLogsResponse::const_iterator it = response->begin(); 62 for (SystemLogsResponse::const_iterator it = response->begin();
52 it != response->end(); 63 it != response->end();
53 ++it) { 64 ++it) {
54 // It is an error to insert an element with a pre-existing key. 65 // It is an error to insert an element with a pre-existing key.
55 bool ok = response_->insert(*it).second; 66 bool ok = response_->insert(*it).second;
56 DCHECK(ok) << "Duplicate key found: " << it->first; 67 DCHECK(ok) << "Duplicate key found: " << it->first;
57 } 68 }
58 69
59 --num_pending_requests_; 70 --num_pending_requests_;
60 if (num_pending_requests_ > 0) 71 if (num_pending_requests_ > 0)
61 return; 72 return;
62 73
63 callback_.Run(std::move(response_)); 74 callback_.Run(std::move(response_));
64 BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, this); 75 BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, this);
65 } 76 }
66 77
67 } // namespace system_logs 78 } // namespace system_logs
OLDNEW
« no previous file with comments | « chrome/browser/feedback/system_logs/system_logs_fetcher_base.h ('k') | components/components_tests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698