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

Side by Side Diff: chrome/browser/feedback/system_logs/system_logs_fetcher.h

Issue 2968613002: Move some of c/b/feedback/system_logs to //components/feedback (Closed)
Patch Set: fix include Created 3 years, 5 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 2013 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 #ifndef CHROME_BROWSER_FEEDBACK_SYSTEM_LOGS_SYSTEM_LOGS_FETCHER_H_
6 #define CHROME_BROWSER_FEEDBACK_SYSTEM_LOGS_SYSTEM_LOGS_FETCHER_H_
7
8 #include <stddef.h>
9
10 #include <map>
11 #include <memory>
12 #include <string>
13 #include <vector>
14
15 #include "base/callback.h"
16 #include "base/macros.h"
17 #include "base/memory/weak_ptr.h"
18 #include "chrome/browser/feedback/system_logs/system_logs_source.h"
19 #include "components/feedback/anonymizer_tool.h"
20 #include "components/feedback/feedback_common.h"
21
22 namespace system_logs {
23
24 // Callback that the SystemLogsFetcher uses to return data.
25 using SysLogsFetcherCallback =
26 base::Callback<void(std::unique_ptr<SystemLogsResponse>)>;
27
28 // The SystemLogsFetcher fetches key-value data from a list of log sources.
29 //
30 // EXAMPLE:
31 // class Example {
32 // public:
33 // void ProcessLogs(SystemLogsResponse* response) {
34 // // do something with the logs
35 // }
36 // void GetLogs() {
37 // SystemLogsFetcher* fetcher = new SystemLogsFetcher(/*scrub_data=*/ true);
38 // fetcher->AddSource(base::MakeUnique<LogSourceOne>());
39 // fetcher->AddSource(base::MakeUnique<LogSourceTwo>());
40 // fetcher->Fetch(base::Bind(&Example::ProcessLogs, this));
41 // }
42 // };
43 class SystemLogsFetcher {
44 public:
45 // If scrub_data is true, logs will be anonymized.
46 // TODO(battre): This class needs to be expanded to provide better scrubbing
47 // of system logs.
48 explicit SystemLogsFetcher(bool scrub_data);
49 ~SystemLogsFetcher();
50
51 // Adds a source to use when fetching.
52 void AddSource(std::unique_ptr<SystemLogsSource> source);
53
54 // Starts the fetch process.
55 void Fetch(const SysLogsFetcherCallback& callback);
56
57 private:
58 // Callback passed to all the data sources. May call Scrub(), then calls
59 // AddResponse().
60 void OnFetched(const std::string& source_name, SystemLogsResponse* response);
61
62 // Merges the |response| it receives into response_. When all the data sources
63 // have responded, it deletes their objects and returns the response to the
64 // callback_. After this it deletes this instance of the object.
65 void AddResponse(const std::string& source_name,
66 SystemLogsResponse* response);
67
68 std::vector<std::unique_ptr<SystemLogsSource>> data_sources_;
69 SysLogsFetcherCallback callback_;
70
71 std::unique_ptr<SystemLogsResponse> response_; // The actual response data.
72 size_t num_pending_requests_; // The number of callbacks it should get.
73
74 std::unique_ptr<feedback::AnonymizerTool> anonymizer_;
75
76 base::WeakPtrFactory<SystemLogsFetcher> weak_ptr_factory_;
77
78 DISALLOW_COPY_AND_ASSIGN(SystemLogsFetcher);
79 };
80
81 } // namespace system_logs
82
83 #endif // CHROME_BROWSER_FEEDBACK_SYSTEM_LOGS_SYSTEM_LOGS_FETCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698