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 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 const int kMinUploadDelayMs = 60 * 1000; // 60 seconds | 26 const int kMinUploadDelayMs = 60 * 1000; // 60 seconds |
27 } // namespace | 27 } // namespace |
28 | 28 |
29 namespace policy { | 29 namespace policy { |
30 | 30 |
31 const int64_t StatusUploader::kDefaultUploadDelayMs = | 31 const int64_t StatusUploader::kDefaultUploadDelayMs = |
32 3 * 60 * 60 * 1000; // 3 hours | 32 3 * 60 * 60 * 1000; // 3 hours |
33 | 33 |
34 StatusUploader::StatusUploader( | 34 StatusUploader::StatusUploader( |
35 CloudPolicyClient* client, | 35 CloudPolicyClient* client, |
36 scoped_ptr<DeviceStatusCollector> collector, | 36 std::unique_ptr<DeviceStatusCollector> collector, |
37 const scoped_refptr<base::SequencedTaskRunner>& task_runner) | 37 const scoped_refptr<base::SequencedTaskRunner>& task_runner) |
38 : client_(client), | 38 : client_(client), |
39 collector_(std::move(collector)), | 39 collector_(std::move(collector)), |
40 task_runner_(task_runner), | 40 task_runner_(task_runner), |
41 upload_frequency_( | 41 upload_frequency_( |
42 base::TimeDelta::FromMilliseconds(kDefaultUploadDelayMs)), | 42 base::TimeDelta::FromMilliseconds(kDefaultUploadDelayMs)), |
43 has_captured_media_(false), | 43 has_captured_media_(false), |
44 weak_factory_(this) { | 44 weak_factory_(this) { |
45 // StatusUploader is currently only created for registered clients, and | 45 // StatusUploader is currently only created for registered clients, and |
46 // 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 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 | 113 |
114 // Schedule a new upload with the new frequency - only do this if we've | 114 // Schedule a new upload with the new frequency - only do this if we've |
115 // already performed the initial upload, because we want the initial upload | 115 // already performed the initial upload, because we want the initial upload |
116 // to happen immediately on startup and not get cancelled by settings changes. | 116 // to happen immediately on startup and not get cancelled by settings changes. |
117 if (!last_upload_.is_null()) | 117 if (!last_upload_.is_null()) |
118 ScheduleNextStatusUpload(); | 118 ScheduleNextStatusUpload(); |
119 } | 119 } |
120 | 120 |
121 bool StatusUploader::IsSessionDataUploadAllowed() { | 121 bool StatusUploader::IsSessionDataUploadAllowed() { |
122 // Check if we're in an auto-launched kiosk session. | 122 // Check if we're in an auto-launched kiosk session. |
123 scoped_ptr<DeviceLocalAccount> account = | 123 std::unique_ptr<DeviceLocalAccount> account = |
124 collector_->GetAutoLaunchedKioskSessionInfo(); | 124 collector_->GetAutoLaunchedKioskSessionInfo(); |
125 if (!account) | 125 if (!account) |
126 return false; | 126 return false; |
127 | 127 |
128 // Check if there has been any user input. | 128 // Check if there has been any user input. |
129 if (!ui::UserActivityDetector::Get()->last_activity_time().is_null()) | 129 if (!ui::UserActivityDetector::Get()->last_activity_time().is_null()) |
130 return false; | 130 return false; |
131 | 131 |
132 // Screenshot is allowed as long as we have not captured media. | 132 // Screenshot is allowed as long as we have not captured media. |
133 return !has_captured_media_; | 133 return !has_captured_media_; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 | 181 |
182 // If the upload was successful, tell the collector so it can clear its cache | 182 // If the upload was successful, tell the collector so it can clear its cache |
183 // of pending items. | 183 // of pending items. |
184 if (success) | 184 if (success) |
185 collector_->OnSubmittedSuccessfully(); | 185 collector_->OnSubmittedSuccessfully(); |
186 | 186 |
187 ScheduleNextStatusUpload(); | 187 ScheduleNextStatusUpload(); |
188 } | 188 } |
189 | 189 |
190 } // namespace policy | 190 } // namespace policy |
OLD | NEW |