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

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

Powered by Google App Engine
This is Rietveld 408576698