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

Side by Side Diff: chrome/browser/chromeos/policy/remote_commands/device_command_fetch_status_job.cc

Issue 2765463002: Remote fetch device status (attributes and logs) command (Closed)
Patch Set: Created 3 years, 9 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 2017 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 #include "chrome/browser/chromeos/policy/remote_commands/device_command_fetch_st atus_job.h"
6
7 #include <memory>
8 #include <utility>
9
10 #include "base/bind.h"
11 #include "base/syslog_logging.h"
12 #include "base/threading/thread_task_runner_handle.h"
13 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
15 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h"
16 #include "chrome/browser/chromeos/policy/status_uploader.h"
17 #include "components/policy/proto/device_management_backend.pb.h"
18
19 namespace policy {
20
21 namespace {
22
23 // Determines the time, measured from the time of issue, after which the command
24 // queue will consider this command expired if the command has not been started.
25 const int kCommandExpirationTimeInMinutes = 10;
26
27 } // namespace
28
29 DeviceCommandFetchStatusJob::DeviceCommandFetchStatusJob() {}
30
31 DeviceCommandFetchStatusJob::~DeviceCommandFetchStatusJob() {}
32
33 enterprise_management::RemoteCommand_Type
34 DeviceCommandFetchStatusJob::GetType() const {
35 return enterprise_management::RemoteCommand_Type_DEVICE_FETCH_STATUS;
36 }
37
38 base::TimeDelta DeviceCommandFetchStatusJob::GetCommmandTimeout() const {
39 return base::TimeDelta::FromMinutes(kCommandExpirationTimeInMinutes);
40 }
41
42 bool DeviceCommandFetchStatusJob::IsExpired(base::TimeTicks now) {
43 return now > issued_time() + GetCommmandTimeout();
44 }
45
46 void DeviceCommandFetchStatusJob::RunImpl(
47 const CallbackWithResult& succeeded_callback,
48 const CallbackWithResult& failed_callback) {
49 SYSLOG(INFO) << "Fetching device status";
50 BrowserPolicyConnectorChromeOS* connector =
51 g_browser_process->platform_part()->browser_policy_connector_chromeos();
52 DeviceCloudPolicyManagerChromeOS* manager =
53 connector->GetDeviceCloudPolicyManager();
54 // DeviceCloudPolicyManagerChromeOS and StatusUploader can be null during
55 // shutdown (and unit tests).
56 if (manager && manager->GetStatusUploader()) {
57 manager->GetStatusUploader()->ScheduleNextStatusUploadImmediately();
58 base::ThreadTaskRunnerHandle::Get()->PostTask(
59 FROM_HERE, base::Bind(succeeded_callback, nullptr));
60 return;
61 }
62
63 base::ThreadTaskRunnerHandle::Get()->PostTask(
64 FROM_HERE, base::Bind(failed_callback, nullptr));
65 }
66
67 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698