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

Side by Side Diff: chrome/browser/chromeos/policy/status_uploader.h

Issue 845313008: Refactored device status uploading out of policy fetch infrastructure. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Test fixes and review feedback Created 5 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_STATUS_UPLOADER_H_
6 #define CHROME_BROWSER_CHROMEOS_POLICY_STATUS_UPLOADER_H_
7
8 #include "base/cancelable_callback.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/prefs/pref_member.h"
12 #include "base/time/time.h"
13 #include "components/policy/core/common/cloud/cloud_policy_constants.h"
14 #include "policy/proto/device_management_backend.pb.h"
15
16 namespace base {
17 class PrefService;
18 class SequencedTaskRunner;
19 }
20
21 namespace policy {
22
23 class CloudPolicyClient;
24 class DeviceManagementRequestJob;
25 class DeviceStatusCollector;
26
27 // Class responsible for periodically uploading device status from the
28 // passed DeviceStatusCollector.
29 class StatusUploader {
30 public:
31 // Refresh constants.
32 static const int64 kDefaultUploadDelayMs;
33
34 // Constructor. |client| must be registered and must stay
35 // valid and registered hrough the lifetime of this StatusUploader
Mattias Nissler (ping if slow) 2015/01/26 10:37:02 typo
Andrew T Wilson (Slow) 2015/01/28 13:19:12 Done.
36 // object.
37 StatusUploader(
38 PrefService* local_state,
39 CloudPolicyClient* client,
40 scoped_ptr<DeviceStatusCollector> collector,
41 const scoped_refptr<base::SequencedTaskRunner>& task_runner);
42
43 ~StatusUploader();
44
45 private:
46 // Callback invoked periodically to upload the device status from the
47 // DeviceStatusCollector.
48 void UploadStatus();
49
50 // Invoked once a status upload has completed.
51 void OnUploadCompleted(
52 DeviceManagementStatus status, int net_error,
53 const enterprise_management::DeviceManagementResponse& response);
54
55 // Helper method that figures out when the next status upload should
56 // be scheduled.
57 void ScheduleNextStatusUpload();
58
59 // CloudPolicyClient used to issue requests to the server.
60 CloudPolicyClient* client_;
61
62 // The job associated with any ongoing requests to the cloud. We currently
63 // only support a single active request at a time.
64 scoped_ptr<DeviceManagementRequestJob> request_job_;
65
66 // DeviceStatusCollector that provides status for uploading.
67 scoped_ptr<DeviceStatusCollector> collector_;
68
69 // TaskRunner used for scheduling upload tasks.
70 const scoped_refptr<base::SequencedTaskRunner> task_runner_;
71
72 // Pref item that specifies what our upload delay is currently.
73 scoped_ptr<IntegerPrefMember> upload_delay_;
74
75 // The time the last upload was performed.
76 base::Time last_upload_;
77
78 // Callback invoked via a delay to upload device status.
79 base::CancelableClosure upload_callback_;
80 };
81
82 } // namespace policy
83
84 #endif // CHROME_BROWSER_CHROMEOS_POLICY_STATUS_UPLOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698