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

Side by Side Diff: chrome/browser/chromeos/system_logs/scrubbed_system_logs_fetcher.cc

Issue 22532012: Use scrubbed logs for sending with feedback reports. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
stevenjb 2013/08/09 02:18:51 New files should be 2013 (other new files should b
rkc 2013/08/09 18:24:18 Done.
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/chromeos/system_logs/system_logs_fetcher.h" 5 #include "chrome/browser/chromeos/system_logs/scrubbed_system_logs_fetcher.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "chrome/browser/chromeos/system_logs/chrome_internal_log_source.h" 9 #include "chrome/browser/chromeos/system_logs/chrome_internal_log_source.h"
10 #include "chrome/browser/chromeos/system_logs/command_line_log_source.h" 10 #include "chrome/browser/chromeos/system_logs/command_line_log_source.h"
11 #include "chrome/browser/chromeos/system_logs/dbus_log_source.h" 11 #include "chrome/browser/chromeos/system_logs/dbus_log_source.h"
12 #include "chrome/browser/chromeos/system_logs/debug_daemon_log_source.h" 12 #include "chrome/browser/chromeos/system_logs/debug_daemon_log_source.h"
13 #include "chrome/browser/chromeos/system_logs/lsb_release_log_source.h" 13 #include "chrome/browser/chromeos/system_logs/lsb_release_log_source.h"
14 #include "chrome/browser/chromeos/system_logs/memory_details_log_source.h" 14 #include "chrome/browser/chromeos/system_logs/memory_details_log_source.h"
15 #include "chrome/browser/chromeos/system_logs/network_event_log_source.h" 15 #include "chrome/browser/chromeos/system_logs/network_event_log_source.h"
16 #include "chrome/browser/chromeos/system_logs/touch_log_source.h" 16 #include "chrome/browser/chromeos/system_logs/touch_log_source.h"
17 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
18 18
19 using content::BrowserThread; 19 using content::BrowserThread;
20 20
21 namespace chromeos { 21 namespace chromeos {
22 22
23 SystemLogsFetcher::SystemLogsFetcher() 23 ScrubbedSystemLogsFetcher::ScrubbedSystemLogsFetcher() {
24 : response_(new SystemLogsResponse),
25 num_pending_requests_(0),
26 weak_ptr_factory_(this) {
27 // Debug Daemon data source. 24 // Debug Daemon data source.
28 data_sources_.push_back(new DebugDaemonLogSource()); 25 data_sources_.push_back(new DebugDaemonLogSource(true));
stevenjb 2013/08/09 02:18:51 Is this the only difference between Scrubbed and A
rkc 2013/08/09 18:24:18 Currently this is the only difference, but scrubbi
stevenjb 2013/08/09 18:52:44 OK, fair enough. Maybe add as a TODO here? Also, d
rkc 2013/08/09 20:17:36 Added the TODO to the class header itself. Done.
29 26
30 // Chrome data sources. 27 // Chrome data sources.
31 data_sources_.push_back(new ChromeInternalLogSource()); 28 data_sources_.push_back(new ChromeInternalLogSource());
32 data_sources_.push_back(new CommandLineLogSource()); 29 data_sources_.push_back(new CommandLineLogSource());
33 data_sources_.push_back(new DBusLogSource()); 30 data_sources_.push_back(new DBusLogSource());
34 data_sources_.push_back(new LsbReleaseLogSource()); 31 data_sources_.push_back(new LsbReleaseLogSource());
35 data_sources_.push_back(new MemoryDetailsLogSource()); 32 data_sources_.push_back(new MemoryDetailsLogSource());
36 data_sources_.push_back(new NetworkEventLogSource()); 33 data_sources_.push_back(new NetworkEventLogSource());
37 data_sources_.push_back(new TouchLogSource()); 34 data_sources_.push_back(new TouchLogSource());
38 35
39 num_pending_requests_ = data_sources_.size(); 36 num_pending_requests_ = data_sources_.size();
40 } 37 }
41 38
42 SystemLogsFetcher::~SystemLogsFetcher() {} 39 ScrubbedSystemLogsFetcher::~ScrubbedSystemLogsFetcher() {}
stevenjb 2013/08/09 02:18:51 nit: } on next line
rkc 2013/08/09 18:24:18 Done.
43 40
44 void SystemLogsFetcher::Fetch(const SysLogsFetcherCallback& callback) { 41 base::WeakPtr<SystemLogsFetcherBase> ScrubbedSystemLogsFetcher::GetWeakPtr() {
45 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 42 return AsWeakPtr();
46 DCHECK(callback_.is_null());
47 DCHECK(!callback.is_null());
48
49 callback_ = callback;
50 for (size_t i = 0; i < data_sources_.size(); ++i) {
51 data_sources_[i]->Fetch(base::Bind(&SystemLogsFetcher::AddResponse,
52 weak_ptr_factory_.GetWeakPtr()));
53 }
54 }
55
56 void SystemLogsFetcher::AddResponse(SystemLogsResponse* response) {
57 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
58
59 for (SystemLogsResponse::const_iterator it = response->begin();
60 it != response->end();
61 ++it) {
62 // It is an error to insert an element with a pre-existing key.
63 bool ok = response_->insert(*it).second;
64 DCHECK(ok) << "Duplicate key found: " << it->first;
65 }
66
67 --num_pending_requests_;
68 if (num_pending_requests_ > 0)
69 return;
70
71 callback_.Run(response_.Pass());
72 BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, this);
73 } 43 }
74 44
75 } // namespace chromeos 45 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698