OLD | NEW |
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 #ifndef CHROME_BROWSER_CHROMEOS_SYSTEM_LOGS_DEBUG_DAEMON_LOG_SOURCE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_SYSTEM_LOGS_DEBUG_DAEMON_LOG_SOURCE_H_ |
6 #define CHROME_BROWSER_CHROMEOS_SYSTEM_LOGS_DEBUG_DAEMON_LOG_SOURCE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_SYSTEM_LOGS_DEBUG_DAEMON_LOG_SOURCE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "chrome/browser/chromeos/system_logs/system_logs_fetcher.h" | 13 #include "chrome/browser/chromeos/system_logs/system_logs_fetcher.h" |
14 | 14 |
15 namespace chromeos { | 15 namespace chromeos { |
16 | 16 |
17 // Gathers log data from Debug Daemon. | 17 // Gathers log data from Debug Daemon. |
18 class DebugDaemonLogSource : public SystemLogsSource { | 18 class DebugDaemonLogSource : public SystemLogsSource { |
19 public: | 19 public: |
20 DebugDaemonLogSource(); | 20 DebugDaemonLogSource(); |
21 virtual ~DebugDaemonLogSource(); | 21 virtual ~DebugDaemonLogSource(); |
22 | 22 |
23 // Fetches logs from the daemon over dbus. After the fetch is complete, the | 23 // Fetches logs from the daemon over dbus. After the fetch is complete, the |
24 // results will be forwarded to the request supplied to the constructor and | 24 // results will be forwarded to the request supplied to the constructor and |
25 // this instance will free itself. | 25 // this instance will free itself. |
26 // SystemLogsSource override. | 26 // SystemLogsSource override. |
27 virtual void Fetch(const SysLogsSourceCallback& callback) OVERRIDE; | 27 virtual void Fetch(const SysLogsSourceCallback& callback) OVERRIDE; |
28 | 28 |
29 private: | 29 private: |
30 // Callbacks for the 4 different dbus calls | 30 typedef std::map<std::string, std::string> KeyValueMap; |
| 31 |
| 32 // Callbacks for the 5 different dbus calls to debugd. |
31 void OnGetRoutes(bool succeeded, const std::vector<std::string>& routes); | 33 void OnGetRoutes(bool succeeded, const std::vector<std::string>& routes); |
32 void OnGetNetworkStatus(bool succeeded, const std::string& status); | 34 void OnGetNetworkStatus(bool succeeded, const std::string& status); |
33 void OnGetModemStatus(bool succeeded, const std::string& status); | 35 void OnGetModemStatus(bool succeeded, const std::string& status); |
34 void OnGetLogs(bool succeeded, | 36 void OnGetLogs(bool succeeded, |
35 const std::map<std::string, std::string>& logs); | 37 const KeyValueMap& logs); |
| 38 void OnGetUserLogFiles(bool succeeded, |
| 39 const KeyValueMap& logs); |
| 40 |
| 41 // Read the contents of the specified user logs files and adds it to |
| 42 // the response. |
| 43 void ReadUserLogFiles(const KeyValueMap& user_log_files); |
| 44 |
36 // Sends the data to the callback_ when all the requests are completed | 45 // Sends the data to the callback_ when all the requests are completed |
37 void RequestCompleted(); | 46 void RequestCompleted(); |
38 | 47 |
39 scoped_ptr<SystemLogsResponse> response_; | 48 scoped_ptr<SystemLogsResponse> response_; |
40 SysLogsSourceCallback callback_; | 49 SysLogsSourceCallback callback_; |
41 int num_pending_requests_; | 50 int num_pending_requests_; |
42 base::WeakPtrFactory<DebugDaemonLogSource> weak_ptr_factory_; | 51 base::WeakPtrFactory<DebugDaemonLogSource> weak_ptr_factory_; |
43 | 52 |
44 DISALLOW_COPY_AND_ASSIGN(DebugDaemonLogSource); | 53 DISALLOW_COPY_AND_ASSIGN(DebugDaemonLogSource); |
45 }; | 54 }; |
46 | 55 |
47 | 56 |
48 } // namespace chromeos | 57 } // namespace chromeos |
49 | 58 |
50 #endif // CHROME_BROWSER_CHROMEOS_SYSTEM_LOGS_DEBUG_DAEMON_LOG_SOURCE_H_ | 59 #endif // CHROME_BROWSER_CHROMEOS_SYSTEM_LOGS_DEBUG_DAEMON_LOG_SOURCE_H_ |
OLD | NEW |