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