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

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

Issue 1530403003: Add anonymizer tool (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase to ToT Created 4 years, 11 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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 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_FEEDBACK_SYSTEM_LOGS_SYSTEM_LOGS_FETCHER_BASE_H_ 5 #ifndef CHROME_BROWSER_FEEDBACK_SYSTEM_LOGS_SYSTEM_LOGS_FETCHER_BASE_H_
6 #define CHROME_BROWSER_FEEDBACK_SYSTEM_LOGS_SYSTEM_LOGS_FETCHER_BASE_H_ 6 #define CHROME_BROWSER_FEEDBACK_SYSTEM_LOGS_SYSTEM_LOGS_FETCHER_BASE_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 // //do something with the logs 56 // //do something with the logs
57 // } 57 // }
58 // void GetLogs() { 58 // void GetLogs() {
59 // SystemLogsFetcherBase* fetcher = new SystemLogsFetcherBase(); 59 // SystemLogsFetcherBase* fetcher = new SystemLogsFetcherBase();
60 // fetcher->Fetch(base::Bind(&Example::ProcessLogs, this)); 60 // fetcher->Fetch(base::Bind(&Example::ProcessLogs, this));
61 // } 61 // }
62 class SystemLogsFetcherBase 62 class SystemLogsFetcherBase
63 : public base::SupportsWeakPtr<SystemLogsFetcherBase> { 63 : public base::SupportsWeakPtr<SystemLogsFetcherBase> {
64 public: 64 public:
65 SystemLogsFetcherBase(); 65 SystemLogsFetcherBase();
66 ~SystemLogsFetcherBase(); 66 virtual ~SystemLogsFetcherBase();
67 67
68 void Fetch(const SysLogsFetcherCallback& callback); 68 void Fetch(const SysLogsFetcherCallback& callback);
69 69
70 protected: 70 protected:
71 // Callback passed to all the data sources. It merges the |data| it receives 71 // Callback passed to all the data sources. Calls Rewrite() and AddResponse().
72 // into response_. When all the data sources have responded, it deletes their 72 void OnFetched(const std::string& source_name, SystemLogsResponse* response);
73 // objects and returns the response to the callback_. After this it 73
74 // deletes this instance of the object. 74 // Virtual function that allows derived classes to modify the response before
75 // it gets added to the output.
76 virtual void Rewrite(const std::string& source_name,
77 SystemLogsResponse* response);
78
79 // Merges the |data| it receives into response_. When all the data sources
80 // have responded, it deletes their objects and returns the response to the
81 // callback_. After this it deletes this instance of the object.
75 void AddResponse(const std::string& source_name, 82 void AddResponse(const std::string& source_name,
76 SystemLogsResponse* response); 83 SystemLogsResponse* response);
77 84
78 ScopedVector<SystemLogsSource> data_sources_; 85 ScopedVector<SystemLogsSource> data_sources_;
79 SysLogsFetcherCallback callback_; 86 SysLogsFetcherCallback callback_;
80 87
81 scoped_ptr<SystemLogsResponse> response_; // The actual response data. 88 scoped_ptr<SystemLogsResponse> response_; // The actual response data.
82 size_t num_pending_requests_; // The number of callbacks it should get. 89 size_t num_pending_requests_; // The number of callbacks it should get.
83 90
84 private: 91 private:
85 92
86 DISALLOW_COPY_AND_ASSIGN(SystemLogsFetcherBase); 93 DISALLOW_COPY_AND_ASSIGN(SystemLogsFetcherBase);
87 }; 94 };
88 95
89 } // namespace system_logs 96 } // namespace system_logs
90 97
91 #endif // CHROME_BROWSER_FEEDBACK_SYSTEM_LOGS_SYSTEM_LOGS_FETCHER_BASE_H_ 98 #endif // CHROME_BROWSER_FEEDBACK_SYSTEM_LOGS_SYSTEM_LOGS_FETCHER_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698