Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 "chrome/browser/chromeos/policy/system_log_uploader.h" | |
| 18 #include "components/policy/proto/device_management_backend.pb.h" | |
| 19 | |
| 20 namespace policy { | |
| 21 | |
| 22 namespace { | |
| 23 | |
| 24 // Determines the time, measured from the time of issue, after which the command | |
| 25 // queue will consider this command expired if the command has not been started. | |
| 26 const int kCommandExpirationTimeInMinutes = 10; | |
| 27 | |
| 28 } // namespace | |
| 29 | |
| 30 DeviceCommandFetchStatusJob::DeviceCommandFetchStatusJob() {} | |
| 31 | |
| 32 DeviceCommandFetchStatusJob::~DeviceCommandFetchStatusJob() {} | |
| 33 | |
| 34 enterprise_management::RemoteCommand_Type | |
| 35 DeviceCommandFetchStatusJob::GetType() const { | |
| 36 return enterprise_management::RemoteCommand_Type_DEVICE_FETCH_STATUS; | |
| 37 } | |
| 38 | |
| 39 base::TimeDelta DeviceCommandFetchStatusJob::GetCommmandTimeout() const { | |
| 40 return base::TimeDelta::FromMinutes(kCommandExpirationTimeInMinutes); | |
| 41 } | |
| 42 | |
| 43 bool DeviceCommandFetchStatusJob::IsExpired(base::TimeTicks now) { | |
| 44 return now > issued_time() + GetCommmandTimeout(); | |
| 45 } | |
| 46 | |
| 47 void DeviceCommandFetchStatusJob::RunImpl( | |
| 48 const CallbackWithResult& succeeded_callback, | |
| 49 const CallbackWithResult& failed_callback) { | |
| 50 SYSLOG(INFO) << "Fetching device status"; | |
| 51 BrowserPolicyConnectorChromeOS* connector = | |
| 52 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | |
| 53 DeviceCloudPolicyManagerChromeOS* manager = | |
| 54 connector->GetDeviceCloudPolicyManager(); | |
| 55 // DeviceCloudPolicyManagerChromeOS, StatusUploader and SysLogUploader can be | |
| 56 // null during shutdown (and unit tests). | |
| 57 if (manager) { | |
| 58 if (manager->GetStatusUploader()) | |
| 59 manager->GetStatusUploader()->ScheduleNextStatusUploadImmediately(); | |
| 60 if (manager->GetSysLogUploader()) | |
| 61 manager->GetSysLogUploader()->ScheduleNextSystemLogUploadImmediately(); | |
| 62 base::ThreadTaskRunnerHandle::Get()->PostTask( | |
| 63 FROM_HERE, base::Bind(succeeded_callback, nullptr)); | |
| 64 return; | |
| 65 } | |
| 66 | |
| 67 base::ThreadTaskRunnerHandle::Get()->PostTask( | |
| 68 FROM_HERE, base::Bind(failed_callback, nullptr)); | |
|
Andrew T Wilson (Slow)
2017/03/21 18:03:42
OK, you no longer fail if status uploader and syst
Ivan Šandrk
2017/03/22 20:20:01
It took me some time to clean up my thoughts on th
| |
| 69 } | |
| 70 | |
| 71 } // namespace policy | |
| OLD | NEW |