OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/policy/core/common/remote_commands/remote_command_job.h" | 5 #include "components/policy/core/common/remote_commands/remote_command_job.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/syslog_logging.h" | 10 #include "base/syslog_logging.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 // transmitted over the network. | 47 // transmitted over the network. |
48 issued_time_ = | 48 issued_time_ = |
49 now - base::TimeDelta::FromMilliseconds(command.age_of_command()); | 49 now - base::TimeDelta::FromMilliseconds(command.age_of_command()); |
50 } else { | 50 } else { |
51 SYSLOG(WARNING) << "No age_of_command provided by server for command " | 51 SYSLOG(WARNING) << "No age_of_command provided by server for command " |
52 << unique_id_ << "."; | 52 << unique_id_ << "."; |
53 // Otherwise, assuming the command was issued just now. | 53 // Otherwise, assuming the command was issued just now. |
54 issued_time_ = now; | 54 issued_time_ = now; |
55 } | 55 } |
56 | 56 |
57 if (!ParseCommandPayload(command.payload())) | 57 if (!ParseCommandPayload(command.payload())) { |
| 58 SYSLOG(ERROR) << "Unable to parse command payload for type " |
| 59 << command.type() << ": " << command.payload(); |
58 return false; | 60 return false; |
| 61 } |
59 | 62 |
60 switch (command.type()) { | 63 switch (command.type()) { |
61 case em::RemoteCommand_Type_COMMAND_ECHO_TEST: { | 64 case em::RemoteCommand_Type_COMMAND_ECHO_TEST: { |
62 SYSLOG(INFO) << "Remote echo test command " << unique_id_ | 65 SYSLOG(INFO) << "Remote echo test command " << unique_id_ |
63 << " initialized."; | 66 << " initialized."; |
64 break; | 67 break; |
65 } | 68 } |
66 case em::RemoteCommand_Type_DEVICE_REBOOT: { | 69 case em::RemoteCommand_Type_DEVICE_REBOOT: { |
67 SYSLOG(INFO) << "Remote reboot command " << unique_id_ << " initialized."; | 70 SYSLOG(INFO) << "Remote reboot command " << unique_id_ << " initialized."; |
68 break; | 71 break; |
69 } | 72 } |
70 case em::RemoteCommand_Type_DEVICE_SCREENSHOT: { | 73 case em::RemoteCommand_Type_DEVICE_SCREENSHOT: { |
71 SYSLOG(INFO) << "Remote screenshot command " << unique_id_ | 74 SYSLOG(INFO) << "Remote screenshot command " << unique_id_ |
72 << " initialized."; | 75 << " initialized."; |
73 break; | 76 break; |
74 } | 77 } |
| 78 case em::RemoteCommand_Type_DEVICE_SET_VOLUME: { |
| 79 SYSLOG(INFO) << "Remote set volume command " << unique_id_ |
| 80 << " initialized."; |
| 81 break; |
| 82 } |
75 } | 83 } |
76 status_ = NOT_STARTED; | 84 status_ = NOT_STARTED; |
77 return true; | 85 return true; |
78 } | 86 } |
79 | 87 |
80 bool RemoteCommandJob::Run(base::TimeTicks now, | 88 bool RemoteCommandJob::Run(base::TimeTicks now, |
81 const FinishedCallback& finished_callback) { | 89 const FinishedCallback& finished_callback) { |
82 DCHECK(thread_checker_.CalledOnValidThread()); | 90 DCHECK(thread_checker_.CalledOnValidThread()); |
83 | 91 |
84 if (status_ == INVALID) { | 92 if (status_ == INVALID) { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 DCHECK_EQ(RUNNING, status_); | 176 DCHECK_EQ(RUNNING, status_); |
169 status_ = succeeded ? SUCCEEDED : FAILED; | 177 status_ = succeeded ? SUCCEEDED : FAILED; |
170 | 178 |
171 result_payload_ = std::move(result_payload); | 179 result_payload_ = std::move(result_payload); |
172 | 180 |
173 if (!finished_callback_.is_null()) | 181 if (!finished_callback_.is_null()) |
174 finished_callback_.Run(); | 182 finished_callback_.Run(); |
175 } | 183 } |
176 | 184 |
177 } // namespace policy | 185 } // namespace policy |
OLD | NEW |