OLD | NEW |
---|---|
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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_POLICY_SYSTEM_LOG_UPLOADER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_SYSTEM_LOG_UPLOADER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_POLICY_SYSTEM_LOG_UPLOADER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_POLICY_SYSTEM_LOG_UPLOADER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/ref_counted_memory.h" | 12 #include "base/memory/ref_counted_memory.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "base/threading/thread_checker.h" | 15 #include "base/threading/thread_checker.h" |
16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
17 #include "chrome/browser/chromeos/policy/upload_job.h" | 17 #include "chrome/browser/chromeos/policy/upload_job.h" |
18 #include "chrome/browser/chromeos/settings/cros_settings.h" | 18 #include "chrome/browser/chromeos/settings/cros_settings.h" |
19 #include "components/feedback/anonymizer_tool.h" | |
19 | 20 |
20 namespace base { | 21 namespace base { |
21 class SequencedTaskRunner; | 22 class SequencedTaskRunner; |
22 } | 23 } |
23 | 24 |
24 namespace policy { | 25 namespace policy { |
25 | 26 |
26 // Class responsible for periodically uploading system logs, it handles the | 27 // Class responsible for periodically uploading system logs, it handles the |
27 // server responses by UploadJob:Delegate callbacks. | 28 // server responses by UploadJob:Delegate callbacks. |
28 class SystemLogUploader : public UploadJob::Delegate { | 29 class SystemLogUploader : public UploadJob::Delegate { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
71 // Returns the time of the last upload attempt, or Time(0) if no upload has | 72 // Returns the time of the last upload attempt, or Time(0) if no upload has |
72 // ever happened. | 73 // ever happened. |
73 base::Time last_upload_attempt() const { return last_upload_attempt_; } | 74 base::Time last_upload_attempt() const { return last_upload_attempt_; } |
74 | 75 |
75 // UploadJob::Delegate: | 76 // UploadJob::Delegate: |
76 // Callbacks handle success and failure results of upload, destroy the | 77 // Callbacks handle success and failure results of upload, destroy the |
77 // upload job. | 78 // upload job. |
78 void OnSuccess() override; | 79 void OnSuccess() override; |
79 void OnFailure(UploadJob::ErrorCode error_code) override; | 80 void OnFailure(UploadJob::ErrorCode error_code) override; |
80 | 81 |
81 // Remove lines from |data| that contain common PII (IP addresses, SSIDs, URLs | 82 // Remove lines from |data| that contain common PII (IP addresses, SSIDs, |
82 // e-mail addresses). | 83 // BSSIDs, URLs, e-mail addresses). |
83 static std::string RemoveSensitiveData(const std::string& data); | 84 std::string RemoveSensitiveData(const std::string& data); |
Thiemo Nagel
2016/01/21 14:22:29
I think this should be a private method.
Polina Bondarenko
2016/01/21 16:16:08
Thinking about this, I decided to remove this meth
| |
84 | 85 |
85 private: | 86 private: |
86 // Updates the system log upload enabled field from settings. | 87 // Updates the system log upload enabled field from settings. |
87 void RefreshUploadSettings(); | 88 void RefreshUploadSettings(); |
88 | 89 |
89 // Starts the system log loading process. | 90 // Starts the system log loading process. |
90 void StartLogUpload(); | 91 void StartLogUpload(); |
91 | 92 |
92 // The callback is invoked by the Delegate if system logs have been loaded | 93 // The callback is invoked by the Delegate if system logs have been loaded |
93 // from disk, uploads system logs. | 94 // from disk, uploads system logs. |
(...skipping 25 matching lines...) Expand all Loading... | |
119 // CrosSettings can switch to an unstrusted state temporarily, and we want to | 120 // CrosSettings can switch to an unstrusted state temporarily, and we want to |
120 // use the last-known trusted values. | 121 // use the last-known trusted values. |
121 bool upload_enabled_; | 122 bool upload_enabled_; |
122 | 123 |
123 // Observer to changes in system log upload settings. | 124 // Observer to changes in system log upload settings. |
124 scoped_ptr<chromeos::CrosSettings::ObserverSubscription> | 125 scoped_ptr<chromeos::CrosSettings::ObserverSubscription> |
125 upload_enabled_observer_; | 126 upload_enabled_observer_; |
126 | 127 |
127 base::ThreadChecker thread_checker_; | 128 base::ThreadChecker thread_checker_; |
128 | 129 |
130 feedback::AnonymizerTool anonymizer_; | |
Thiemo Nagel
2016/01/21 14:22:29
I'd suggest to let the AnonymizerTool live as a lo
Polina Bondarenko
2016/01/21 16:16:08
Done.
| |
131 | |
129 // Note: This should remain the last member so it'll be destroyed and | 132 // Note: This should remain the last member so it'll be destroyed and |
130 // invalidate the weak pointers before any other members are destroyed. | 133 // invalidate the weak pointers before any other members are destroyed. |
131 base::WeakPtrFactory<SystemLogUploader> weak_factory_; | 134 base::WeakPtrFactory<SystemLogUploader> weak_factory_; |
132 | 135 |
133 DISALLOW_COPY_AND_ASSIGN(SystemLogUploader); | 136 DISALLOW_COPY_AND_ASSIGN(SystemLogUploader); |
134 }; | 137 }; |
135 | 138 |
136 } // namespace policy | 139 } // namespace policy |
137 | 140 |
138 #endif // CHROME_BROWSER_CHROMEOS_POLICY_SYSTEM_LOG_UPLOADER_H_ | 141 #endif // CHROME_BROWSER_CHROMEOS_POLICY_SYSTEM_LOG_UPLOADER_H_ |
OLD | NEW |