| 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 <memory> | 10 #include <memory> |
| 11 #include <string> |
| 12 #include <utility> |
| 13 #include <vector> |
| 11 | 14 |
| 12 #include "base/macros.h" | 15 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/ref_counted_memory.h" | 17 #include "base/memory/ref_counted_memory.h" |
| 15 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
| 16 #include "base/threading/thread_checker.h" | 19 #include "base/threading/thread_checker.h" |
| 17 #include "base/time/time.h" | 20 #include "base/time/time.h" |
| 18 #include "chrome/browser/chromeos/policy/upload_job.h" | 21 #include "chrome/browser/chromeos/policy/upload_job.h" |
| 19 #include "chrome/browser/chromeos/settings/cros_settings.h" | 22 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 20 | 23 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 // upload job. | 85 // upload job. |
| 83 void OnSuccess() override; | 86 void OnSuccess() override; |
| 84 void OnFailure(UploadJob::ErrorCode error_code) override; | 87 void OnFailure(UploadJob::ErrorCode error_code) override; |
| 85 | 88 |
| 86 // Remove lines from |data| that contain common PII (IP addresses, BSSIDs, | 89 // Remove lines from |data| that contain common PII (IP addresses, BSSIDs, |
| 87 // SSIDs, URLs, e-mail addresses). | 90 // SSIDs, URLs, e-mail addresses). |
| 88 static std::string RemoveSensitiveData( | 91 static std::string RemoveSensitiveData( |
| 89 feedback::AnonymizerTool* const anonymizer, | 92 feedback::AnonymizerTool* const anonymizer, |
| 90 const std::string& data); | 93 const std::string& data); |
| 91 | 94 |
| 95 void ScheduleNextSystemLogUploadImmediately(); |
| 96 |
| 92 private: | 97 private: |
| 93 // Updates the system log upload enabled field from settings. | 98 // Updates the system log upload enabled field from settings. |
| 94 void RefreshUploadSettings(); | 99 void RefreshUploadSettings(); |
| 95 | 100 |
| 96 // Starts the system log loading process. | 101 // Starts the system log loading process. |
| 97 void StartLogUpload(); | 102 void StartLogUpload(); |
| 98 | 103 |
| 99 // The callback is invoked by the Delegate if system logs have been loaded | 104 // The callback is invoked by the Delegate if system logs have been loaded |
| 100 // from disk, uploads system logs. | 105 // from disk, uploads system logs. |
| 101 void UploadSystemLogs(std::unique_ptr<SystemLogs> system_logs); | 106 void UploadSystemLogs(std::unique_ptr<SystemLogs> system_logs); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 126 // CrosSettings can switch to an unstrusted state temporarily, and we want to | 131 // CrosSettings can switch to an unstrusted state temporarily, and we want to |
| 127 // use the last-known trusted values. | 132 // use the last-known trusted values. |
| 128 bool upload_enabled_; | 133 bool upload_enabled_; |
| 129 | 134 |
| 130 // Observer to changes in system log upload settings. | 135 // Observer to changes in system log upload settings. |
| 131 std::unique_ptr<chromeos::CrosSettings::ObserverSubscription> | 136 std::unique_ptr<chromeos::CrosSettings::ObserverSubscription> |
| 132 upload_enabled_observer_; | 137 upload_enabled_observer_; |
| 133 | 138 |
| 134 base::ThreadChecker thread_checker_; | 139 base::ThreadChecker thread_checker_; |
| 135 | 140 |
| 141 // Used to prevent a race condition where two log uploads are being executed |
| 142 // in parallel. |
| 143 bool log_upload_in_progress_ = false; |
| 144 |
| 136 // Note: This should remain the last member so it'll be destroyed and | 145 // Note: This should remain the last member so it'll be destroyed and |
| 137 // invalidate the weak pointers before any other members are destroyed. | 146 // invalidate the weak pointers before any other members are destroyed. |
| 138 base::WeakPtrFactory<SystemLogUploader> weak_factory_; | 147 base::WeakPtrFactory<SystemLogUploader> weak_factory_; |
| 139 | 148 |
| 140 DISALLOW_COPY_AND_ASSIGN(SystemLogUploader); | 149 DISALLOW_COPY_AND_ASSIGN(SystemLogUploader); |
| 141 }; | 150 }; |
| 142 | 151 |
| 143 } // namespace policy | 152 } // namespace policy |
| 144 | 153 |
| 145 #endif // CHROME_BROWSER_CHROMEOS_POLICY_SYSTEM_LOG_UPLOADER_H_ | 154 #endif // CHROME_BROWSER_CHROMEOS_POLICY_SYSTEM_LOG_UPLOADER_H_ |
| OLD | NEW |