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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/policy/remote_commands/device_command_fetch_status_job.cc
diff --git a/chrome/browser/chromeos/policy/remote_commands/device_command_fetch_status_job.cc b/chrome/browser/chromeos/policy/remote_commands/device_command_fetch_status_job.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a744f9652cb18b1a3d7e2ed91bbeb8136cbb519e
--- /dev/null
+++ b/chrome/browser/chromeos/policy/remote_commands/device_command_fetch_status_job.cc
@@ -0,0 +1,67 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/policy/remote_commands/device_command_fetch_status_job.h"
+
+#include <memory>
+#include <utility>
+
+#include "base/bind.h"
+#include "base/syslog_logging.h"
+#include "base/threading/thread_task_runner_handle.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
+#include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h"
+#include "chrome/browser/chromeos/policy/status_uploader.h"
+#include "components/policy/proto/device_management_backend.pb.h"
+
+namespace policy {
+
+namespace {
+
+// Determines the time, measured from the time of issue, after which the command
+// queue will consider this command expired if the command has not been started.
+const int kCommandExpirationTimeInMinutes = 10;
+
+} // namespace
+
+DeviceCommandFetchStatusJob::DeviceCommandFetchStatusJob() {}
+
+DeviceCommandFetchStatusJob::~DeviceCommandFetchStatusJob() {}
+
+enterprise_management::RemoteCommand_Type
+DeviceCommandFetchStatusJob::GetType() const {
+ return enterprise_management::RemoteCommand_Type_DEVICE_FETCH_STATUS;
+}
+
+base::TimeDelta DeviceCommandFetchStatusJob::GetCommmandTimeout() const {
+ return base::TimeDelta::FromMinutes(kCommandExpirationTimeInMinutes);
+}
+
+bool DeviceCommandFetchStatusJob::IsExpired(base::TimeTicks now) {
+ return now > issued_time() + GetCommmandTimeout();
+}
+
+void DeviceCommandFetchStatusJob::RunImpl(
+ const CallbackWithResult& succeeded_callback,
+ const CallbackWithResult& failed_callback) {
+ SYSLOG(INFO) << "Fetching device status";
+ BrowserPolicyConnectorChromeOS* connector =
+ g_browser_process->platform_part()->browser_policy_connector_chromeos();
+ DeviceCloudPolicyManagerChromeOS* manager =
+ connector->GetDeviceCloudPolicyManager();
+ // DeviceCloudPolicyManagerChromeOS and StatusUploader can be null during
+ // shutdown (and unit tests).
+ if (manager && manager->GetStatusUploader()) {
+ manager->GetStatusUploader()->ScheduleNextStatusUploadImmediately();
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::Bind(succeeded_callback, nullptr));
+ return;
+ }
+
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::Bind(failed_callback, nullptr));
+}
+
+} // namespace policy

Powered by Google App Engine
This is Rietveld 408576698