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 14 matching lines...) Expand all Loading... |
25 Terminate(); | 25 Terminate(); |
26 } | 26 } |
27 | 27 |
28 bool RemoteCommandJob::Init(base::TimeTicks now, | 28 bool RemoteCommandJob::Init(base::TimeTicks now, |
29 const em::RemoteCommand& command) { | 29 const em::RemoteCommand& command) { |
30 DCHECK(thread_checker_.CalledOnValidThread()); | 30 DCHECK(thread_checker_.CalledOnValidThread()); |
31 DCHECK_EQ(NOT_INITIALIZED, status_); | 31 DCHECK_EQ(NOT_INITIALIZED, status_); |
32 | 32 |
33 status_ = INVALID; | 33 status_ = INVALID; |
34 | 34 |
35 if (!command.has_type() || !command.has_unique_id()) | 35 if (!command.has_type() || !command.has_command_id()) |
36 return false; | 36 return false; |
37 DCHECK_EQ(command.type(), GetType()); | 37 DCHECK_EQ(command.type(), GetType()); |
38 | 38 |
39 unique_id_ = command.unique_id(); | 39 unique_id_ = command.command_id(); |
40 | 40 |
41 if (command.has_age_of_command()) { | 41 if (command.has_age_of_command()) { |
42 // Use age of command provided by server to estimate the command issued time | 42 // Use age of command provided by server to estimate the command issued time |
43 // as a local TimeTick. We need to store issued time instead of age of | 43 // as a local TimeTick. We need to store issued time instead of age of |
44 // command, since the execution time of command might be different from the | 44 // command, since the execution time of command might be different from the |
45 // time we got it from server. | 45 // time we got it from server. |
46 // It's just an estimation since we lost the time the response was | 46 // It's just an estimation since we lost the time the response was |
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()); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 DCHECK_EQ(RUNNING, status_); | 168 DCHECK_EQ(RUNNING, status_); |
169 status_ = succeeded ? SUCCEEDED : FAILED; | 169 status_ = succeeded ? SUCCEEDED : FAILED; |
170 | 170 |
171 result_payload_ = std::move(result_payload); | 171 result_payload_ = std::move(result_payload); |
172 | 172 |
173 if (!finished_callback_.is_null()) | 173 if (!finished_callback_.is_null()) |
174 finished_callback_.Run(); | 174 finished_callback_.Run(); |
175 } | 175 } |
176 | 176 |
177 } // namespace policy | 177 } // namespace policy |
OLD | NEW |