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

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

Issue 2955463002: Add log source to read from one DebugDaemon log (Closed)
Patch Set: Created 3 years, 6 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 2017 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_logs/single_debug_daemon_log_source.h"
6
7 #include "base/bind.h"
8 #include "chromeos/dbus/dbus_thread_manager.h"
9 #include "chromeos/dbus/debug_daemon_client.h"
10 #include "components/feedback/anonymizer_tool.h"
11 #include "content/public/browser/browser_thread.h"
12
13 namespace system_logs {
14
15 namespace {
16
17 using SupportedSource = SingleDebugDaemonLogSource::SupportedSource;
18
19 // Converts a logs source type to the corresponding file path, relative to the
20 // base system log directory path. In the future, if non-file source types are
21 // added, this function should return an empty file path.
afakhry 2017/06/22 22:20:58 Copy-and-paste comment. Please modify! :)
Simon Que 2017/06/22 22:38:27 Done.
22 std::string GetLogName(SupportedSource source_type) {
23 switch (source_type) {
24 case SupportedSource::kModetest:
25 return "modetest";
26 case SupportedSource::kLsusb:
27 return "lsusb";
28 }
29 NOTREACHED();
30 return "";
31 }
32
33 } // namespace
34
35 SingleDebugDaemonLogSource::SingleDebugDaemonLogSource(
36 SupportedSource source_type)
37 : SystemLogsSource(GetLogName(source_type)), weak_ptr_factory_(this) {}
38
39 SingleDebugDaemonLogSource::~SingleDebugDaemonLogSource() {}
40
41 void SingleDebugDaemonLogSource::Fetch(const SysLogsSourceCallback& callback) {
42 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
43 DCHECK(!callback.is_null());
44
45 chromeos::DebugDaemonClient* client =
46 chromeos::DBusThreadManager::Get()->GetDebugDaemonClient();
47
48 client->GetLog(source_name(),
afakhry 2017/06/22 22:20:59 I don't see this function belonging to DebugDaemon
Simon Que 2017/06/22 22:38:27 That function is being added in a CL that this one
49 base::Bind(&SingleDebugDaemonLogSource::OnFetchComplete,
50 weak_ptr_factory_.GetWeakPtr(), callback));
51 }
52
53 void SingleDebugDaemonLogSource::OnFetchComplete(
54 const SysLogsSourceCallback& callback,
55 bool success,
afakhry 2017/06/22 22:20:59 Can you check "success" and add a test for that?
Simon Que 2017/06/22 22:38:27 I can return an empty result on !success, but I do
afakhry 2017/06/22 23:34:15 Forget about this test request. It's not worth it.
56 const std::map<std::string, std::string>& result) const {
57 // |result| and |response| are the same type, but |result| is passed in from
58 // DebugDaemonClient, which does not use the SystemLogsResponse alias.
59 SystemLogsResponse response;
60 feedback::AnonymizerTool anonymizer;
61 for (auto& entry : result)
62 response[entry.first] = anonymizer.Anonymize(entry.second);
afakhry 2017/06/22 22:20:58 Nit: emplace(key, val);
Simon Que 2017/06/22 22:38:27 Done.
63
64 callback.Run(&response);
65 }
66
67 } // namespace system_logs
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698