| 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 #include "chrome/browser/chromeos/policy/status_uploader.h" | 5 #include "chrome/browser/chromeos/policy/status_uploader.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> |
| 8 | 9 |
| 9 #include "base/bind.h" | 10 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 11 #include "base/location.h" | 12 #include "base/location.h" |
| 12 #include "base/sequenced_task_runner.h" | 13 #include "base/sequenced_task_runner.h" |
| 13 #include "chrome/browser/chromeos/policy/device_local_account.h" | 14 #include "chrome/browser/chromeos/policy/device_local_account.h" |
| 14 #include "chrome/browser/chromeos/policy/device_status_collector.h" | 15 #include "chrome/browser/chromeos/policy/device_status_collector.h" |
| 15 #include "chromeos/settings/cros_settings_names.h" | 16 #include "chromeos/settings/cros_settings_names.h" |
| 16 #include "chromeos/settings/cros_settings_provider.h" | 17 #include "chromeos/settings/cros_settings_provider.h" |
| 17 #include "components/policy/core/common/cloud/cloud_policy_client.h" | 18 #include "components/policy/core/common/cloud/cloud_policy_client.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 28 namespace policy { | 29 namespace policy { |
| 29 | 30 |
| 30 const int64_t StatusUploader::kDefaultUploadDelayMs = | 31 const int64_t StatusUploader::kDefaultUploadDelayMs = |
| 31 3 * 60 * 60 * 1000; // 3 hours | 32 3 * 60 * 60 * 1000; // 3 hours |
| 32 | 33 |
| 33 StatusUploader::StatusUploader( | 34 StatusUploader::StatusUploader( |
| 34 CloudPolicyClient* client, | 35 CloudPolicyClient* client, |
| 35 scoped_ptr<DeviceStatusCollector> collector, | 36 scoped_ptr<DeviceStatusCollector> collector, |
| 36 const scoped_refptr<base::SequencedTaskRunner>& task_runner) | 37 const scoped_refptr<base::SequencedTaskRunner>& task_runner) |
| 37 : client_(client), | 38 : client_(client), |
| 38 collector_(collector.Pass()), | 39 collector_(std::move(collector)), |
| 39 task_runner_(task_runner), | 40 task_runner_(task_runner), |
| 40 upload_frequency_( | 41 upload_frequency_( |
| 41 base::TimeDelta::FromMilliseconds(kDefaultUploadDelayMs)), | 42 base::TimeDelta::FromMilliseconds(kDefaultUploadDelayMs)), |
| 42 has_captured_media_(false), | 43 has_captured_media_(false), |
| 43 weak_factory_(this) { | 44 weak_factory_(this) { |
| 44 // StatusUploader is currently only created for registered clients, and | 45 // StatusUploader is currently only created for registered clients, and |
| 45 // it is currently safe to assume that the client will not unregister while | 46 // it is currently safe to assume that the client will not unregister while |
| 46 // StatusUploader is alive. | 47 // StatusUploader is alive. |
| 47 // | 48 // |
| 48 // If future changes result in StatusUploader's lifetime extending beyond | 49 // If future changes result in StatusUploader's lifetime extending beyond |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 | 173 |
| 173 // If the upload was successful, tell the collector so it can clear its cache | 174 // If the upload was successful, tell the collector so it can clear its cache |
| 174 // of pending items. | 175 // of pending items. |
| 175 if (success) | 176 if (success) |
| 176 collector_->OnSubmittedSuccessfully(); | 177 collector_->OnSubmittedSuccessfully(); |
| 177 | 178 |
| 178 ScheduleNextStatusUpload(); | 179 ScheduleNextStatusUpload(); |
| 179 } | 180 } |
| 180 | 181 |
| 181 } // namespace policy | 182 } // namespace policy |
| OLD | NEW |