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

Unified Diff: components/policy/core/common/cloud/cloud_policy_client.cc

Issue 879233003: Initial RemoteCommandService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remote-commands
Patch Set: WIP Created 5 years, 10 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: components/policy/core/common/cloud/cloud_policy_client.cc
diff --git a/components/policy/core/common/cloud/cloud_policy_client.cc b/components/policy/core/common/cloud/cloud_policy_client.cc
index 6f7fbf931c2f28f4de5b44f83d147bf8cd7d8337..6307855ea97f5bccce8b44aefdb4efbd1e3cfa84 100644
--- a/components/policy/core/common/cloud/cloud_policy_client.cc
+++ b/components/policy/core/common/cloud/cloud_policy_client.cc
@@ -299,6 +299,32 @@ void CloudPolicyClient::UploadDeviceStatus(
request_jobs_.back()->Start(job_callback);
}
+void CloudPolicyClient::FetchRemoteCommands(
+ RemoteCommandJob::UniqueIDType last_command_id,
+ const std::vector<em::RemoteCommandResult>& command_results,
+ const RemoteCommandCallback& callback) {
+ CHECK(is_registered());
+ scoped_ptr<DeviceManagementRequestJob> request_job(service_->CreateJob(
+ DeviceManagementRequestJob::TYPE_REMOTE_COMMANDS, GetRequestContext()));
+
+ request_job->SetDMToken(dm_token_);
+ request_job->SetClientID(client_id_);
+
+ em::DeviceRemoteCommandRequest* request =
+ request_job->GetRequest()->mutable_remote_command_request();
+
+ request->set_last_command_unique_id(last_command_id);
+ request->clear_command_results();
bartfab (slow) 2015/02/12 14:29:19 This is unnecessary. The command results will alwa
binjin 2015/02/16 22:46:23 Done.
+
+ for (const auto& command_result : command_results)
+ *request->add_command_results() = command_result;
+
+ request_jobs_.push_back(request_job.Pass());
+ request_jobs_.back()->Start(
+ base::Bind(&CloudPolicyClient::OnRemoteCommandsFetched,
+ base::Unretained(this), request_job.get(), callback));
+}
+
void CloudPolicyClient::AddObserver(Observer* observer) {
observers_.AddObserver(observer);
}
@@ -516,6 +542,22 @@ void CloudPolicyClient::OnStatusUploadCompleted(
RemoveJob(job);
}
+void CloudPolicyClient::OnRemoteCommandsFetched(
+ const DeviceManagementRequestJob* job,
+ const RemoteCommandCallback& callback,
+ DeviceManagementStatus status,
+ int net_error,
+ const enterprise_management::DeviceManagementResponse& response) {
+ std::vector<enterprise_management::RemoteCommand> commands;
+ if (status == DM_STATUS_SUCCESS && response.has_remote_command_response()) {
+ for (const auto& command : response.remote_command_response().commands())
+ commands.push_back(command);
+ } else {
+ NotifyClientError();
+ }
+ callback.Run(commands);
+}
bartfab (slow) 2015/02/12 14:29:19 You forgot to RemoveJob(job).
binjin 2015/02/16 22:46:23 Done.
+
void CloudPolicyClient::NotifyPolicyFetched() {
FOR_EACH_OBSERVER(Observer, observers_, OnPolicyFetched(this));
}

Powered by Google App Engine
This is Rietveld 408576698