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.
5 #ifndef CHROME_BROWSER_CHROMEOS_SYSTEM_LOGS_DEBUG_DAEMON_LOG_SOURCE_H_
6 #define CHROME_BROWSER_CHROMEOS_SYSTEM_LOGS_DEBUG_DAEMON_LOG_SOURCE_H_
12 #include "base/files/file_path.h"
13 #include "base/memory/weak_ptr.h"
14 #include "chrome/browser/feedback/system_logs/system_logs_fetcher_base.h"
18 namespace system_logs
{
20 // Gathers log data from Debug Daemon.
21 class DebugDaemonLogSource
: public SystemLogsSource
{
23 explicit DebugDaemonLogSource(bool scrub
);
24 ~DebugDaemonLogSource() override
;
26 // SystemLogsSource override:
27 // Fetches logs from the daemon over dbus. After the fetch is complete, the
28 // results will be forwarded to the request supplied to the constructor and
29 // this instance will free itself.
30 void Fetch(const SysLogsSourceCallback
& callback
) override
;
33 typedef std::map
<std::string
, std::string
> KeyValueMap
;
35 // Callbacks for the 5 different dbus calls to debugd.
36 void OnGetRoutes(bool succeeded
, const std::vector
<std::string
>& routes
);
37 void OnGetNetworkStatus(bool succeeded
, const std::string
& status
);
38 void OnGetModemStatus(bool succeeded
, const std::string
& status
);
39 void OnGetWiMaxStatus(bool succeeded
, const std::string
& status
);
40 void OnGetLogs(bool succeeded
,
41 const KeyValueMap
& logs
);
42 void OnGetUserLogFiles(bool succeeded
,
43 const KeyValueMap
& logs
);
45 // Read the contents of the specified user logs files and adds it to
46 // the response parameter.
47 static void ReadUserLogFiles(
48 const KeyValueMap
& user_log_files
,
49 const std::vector
<base::FilePath
>& profile_dirs
,
50 SystemLogsResponse
* response
);
52 // Merge the responses from ReadUserLogFiles into the main response dict and
53 // call RequestComplete to indicate that the user log files read is complete.
54 void MergeResponse(SystemLogsResponse
* response
);
56 // Sends the data to the callback_ when all the requests are completed
57 void RequestCompleted();
59 scoped_ptr
<SystemLogsResponse
> response_
;
60 SysLogsSourceCallback callback_
;
61 int num_pending_requests_
;
63 base::WeakPtrFactory
<DebugDaemonLogSource
> weak_ptr_factory_
;
65 DISALLOW_COPY_AND_ASSIGN(DebugDaemonLogSource
);
69 } // namespace system_logs
71 #endif // CHROME_BROWSER_CHROMEOS_SYSTEM_LOGS_DEBUG_DAEMON_LOG_SOURCE_H_