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

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

Issue 22532012: Use scrubbed logs for sending with feedback reports. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge 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.
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/debug_daemon_log_source.h" 5 #include "chrome/browser/chromeos/system_logs/debug_daemon_log_source.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 "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
15 #include "chrome/browser/chromeos/system_logs/system_logs_fetcher.h"
16 #include "chrome/browser/profiles/profile_manager.h" 15 #include "chrome/browser/profiles/profile_manager.h"
17 #include "chrome/common/chrome_switches.h" 16 #include "chrome/common/chrome_switches.h"
18 #include "chromeos/dbus/dbus_thread_manager.h" 17 #include "chromeos/dbus/dbus_thread_manager.h"
19 #include "chromeos/dbus/debug_daemon_client.h" 18 #include "chromeos/dbus/debug_daemon_client.h"
20 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
21 20
22 const char kNotAvailable[] = "<not available>"; 21 const char kNotAvailable[] = "<not available>";
23 const char kRoutesKeyName[] = "routes"; 22 const char kRoutesKeyName[] = "routes";
24 const char kNetworkStatusKeyName[] = "network-status"; 23 const char kNetworkStatusKeyName[] = "network-status";
25 const char kModemStatusKeyName[] = "modem-status"; 24 const char kModemStatusKeyName[] = "modem-status";
26 const char kWiMaxStatusKeyName[] = "wimax-status"; 25 const char kWiMaxStatusKeyName[] = "wimax-status";
27 const char kUserLogFileKeyName[] = "user_log_files"; 26 const char kUserLogFileKeyName[] = "user_log_files";
28 27
29 namespace chromeos { 28 namespace chromeos {
30 29
31 DebugDaemonLogSource::DebugDaemonLogSource() 30 DebugDaemonLogSource::DebugDaemonLogSource(bool scrub)
32 : response_(new SystemLogsResponse()), 31 : response_(new SystemLogsResponse()),
33 num_pending_requests_(0), 32 num_pending_requests_(0),
33 scrub_(scrub),
34 weak_ptr_factory_(this) {} 34 weak_ptr_factory_(this) {}
35 35
36 DebugDaemonLogSource::~DebugDaemonLogSource() {} 36 DebugDaemonLogSource::~DebugDaemonLogSource() {}
37 37
38 void DebugDaemonLogSource::Fetch(const SysLogsSourceCallback& callback) { 38 void DebugDaemonLogSource::Fetch(const SysLogsSourceCallback& callback) {
39 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 39 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
40 DCHECK(!callback.is_null()); 40 DCHECK(!callback.is_null());
41 DCHECK(callback_.is_null()); 41 DCHECK(callback_.is_null());
42 42
43 callback_ = callback; 43 callback_ = callback;
44 DebugDaemonClient* client = DBusThreadManager::Get()->GetDebugDaemonClient(); 44 DebugDaemonClient* client = DBusThreadManager::Get()->GetDebugDaemonClient();
45 45
46 client->GetRoutes(true, // Numeric 46 client->GetRoutes(true, // Numeric
47 false, // No IPv6 47 false, // No IPv6
48 base::Bind(&DebugDaemonLogSource::OnGetRoutes, 48 base::Bind(&DebugDaemonLogSource::OnGetRoutes,
49 weak_ptr_factory_.GetWeakPtr())); 49 weak_ptr_factory_.GetWeakPtr()));
50 ++num_pending_requests_; 50 ++num_pending_requests_;
51 client->GetNetworkStatus(base::Bind(&DebugDaemonLogSource::OnGetNetworkStatus, 51 client->GetNetworkStatus(base::Bind(&DebugDaemonLogSource::OnGetNetworkStatus,
52 weak_ptr_factory_.GetWeakPtr())); 52 weak_ptr_factory_.GetWeakPtr()));
53 ++num_pending_requests_; 53 ++num_pending_requests_;
54 client->GetModemStatus(base::Bind(&DebugDaemonLogSource::OnGetModemStatus, 54 client->GetModemStatus(base::Bind(&DebugDaemonLogSource::OnGetModemStatus,
55 weak_ptr_factory_.GetWeakPtr())); 55 weak_ptr_factory_.GetWeakPtr()));
56 ++num_pending_requests_; 56 ++num_pending_requests_;
57 client->GetWiMaxStatus(base::Bind(&DebugDaemonLogSource::OnGetWiMaxStatus, 57 client->GetWiMaxStatus(base::Bind(&DebugDaemonLogSource::OnGetWiMaxStatus,
58 weak_ptr_factory_.GetWeakPtr())); 58 weak_ptr_factory_.GetWeakPtr()));
59 ++num_pending_requests_; 59 ++num_pending_requests_;
60 client->GetAllLogs(base::Bind(&DebugDaemonLogSource::OnGetLogs,
61 weak_ptr_factory_.GetWeakPtr()));
62 ++num_pending_requests_;
63 client->GetUserLogFiles(base::Bind(&DebugDaemonLogSource::OnGetUserLogFiles, 60 client->GetUserLogFiles(base::Bind(&DebugDaemonLogSource::OnGetUserLogFiles,
64 weak_ptr_factory_.GetWeakPtr())); 61 weak_ptr_factory_.GetWeakPtr()));
65 ++num_pending_requests_; 62 ++num_pending_requests_;
63
64 if (scrub_) {
65 client->GetScrubbedLogs(base::Bind(&DebugDaemonLogSource::OnGetLogs,
66 weak_ptr_factory_.GetWeakPtr()));
67 } else {
68 client->GetAllLogs(base::Bind(&DebugDaemonLogSource::OnGetLogs,
69 weak_ptr_factory_.GetWeakPtr()));
70 }
71 ++num_pending_requests_;
66 } 72 }
67 73
68 void DebugDaemonLogSource::OnGetRoutes(bool succeeded, 74 void DebugDaemonLogSource::OnGetRoutes(bool succeeded,
69 const std::vector<std::string>& routes) { 75 const std::vector<std::string>& routes) {
70 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 76 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
71 77
72 if (succeeded) 78 if (succeeded)
73 (*response_)[kRoutesKeyName] = JoinString(routes, '\n'); 79 (*response_)[kRoutesKeyName] = JoinString(routes, '\n');
74 else 80 else
75 (*response_)[kRoutesKeyName] = kNotAvailable; 81 (*response_)[kRoutesKeyName] = kNotAvailable;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 172 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
167 DCHECK(!callback_.is_null()); 173 DCHECK(!callback_.is_null());
168 174
169 --num_pending_requests_; 175 --num_pending_requests_;
170 if (num_pending_requests_ > 0) 176 if (num_pending_requests_ > 0)
171 return; 177 return;
172 callback_.Run(response_.get()); 178 callback_.Run(response_.get());
173 } 179 }
174 180
175 } // namespace chromeos 181 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698