1aea4c1cea20dda7ae7e85fc8924a2d784f70d806Alex Deymo// 2aea4c1cea20dda7ae7e85fc8924a2d784f70d806Alex Deymo// Copyright (C) 2014 The Android Open Source Project 3aea4c1cea20dda7ae7e85fc8924a2d784f70d806Alex Deymo// 4aea4c1cea20dda7ae7e85fc8924a2d784f70d806Alex Deymo// Licensed under the Apache License, Version 2.0 (the "License"); 5aea4c1cea20dda7ae7e85fc8924a2d784f70d806Alex Deymo// you may not use this file except in compliance with the License. 6aea4c1cea20dda7ae7e85fc8924a2d784f70d806Alex Deymo// You may obtain a copy of the License at 7aea4c1cea20dda7ae7e85fc8924a2d784f70d806Alex Deymo// 8aea4c1cea20dda7ae7e85fc8924a2d784f70d806Alex Deymo// http://www.apache.org/licenses/LICENSE-2.0 9aea4c1cea20dda7ae7e85fc8924a2d784f70d806Alex Deymo// 10aea4c1cea20dda7ae7e85fc8924a2d784f70d806Alex Deymo// Unless required by applicable law or agreed to in writing, software 11aea4c1cea20dda7ae7e85fc8924a2d784f70d806Alex Deymo// distributed under the License is distributed on an "AS IS" BASIS, 12aea4c1cea20dda7ae7e85fc8924a2d784f70d806Alex Deymo// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13aea4c1cea20dda7ae7e85fc8924a2d784f70d806Alex Deymo// See the License for the specific language governing permissions and 14aea4c1cea20dda7ae7e85fc8924a2d784f70d806Alex Deymo// limitations under the License. 15aea4c1cea20dda7ae7e85fc8924a2d784f70d806Alex Deymo// 1623949d4e086ca984ca2ce07efb6d4ae2bc5daf42Alex Deymo 1748415f1f6c6c356bfa9ac85b76d8ebcf053f7157Gilad Arnold#ifndef UPDATE_ENGINE_UPDATE_MANAGER_EVALUATION_CONTEXT_H_ 1848415f1f6c6c356bfa9ac85b76d8ebcf053f7157Gilad Arnold#define UPDATE_ENGINE_UPDATE_MANAGER_EVALUATION_CONTEXT_H_ 1923949d4e086ca984ca2ce07efb6d4ae2bc5daf42Alex Deymo 2023949d4e086ca984ca2ce07efb6d4ae2bc5daf42Alex Deymo#include <map> 2102f7c1dee242f490143791dbb73fa23fa3007cfaBen Chan#include <memory> 2248415f1f6c6c356bfa9ac85b76d8ebcf053f7157Gilad Arnold#include <string> 2323949d4e086ca984ca2ce07efb6d4ae2bc5daf42Alex Deymo 2483ffddaa3b09ceb4361e5c01ba300d57ab697a7eGilad Arnold#include <base/bind.h> 2553556eccd206bacd5c9c8bb6605bcceb1bcb6190Alex Deymo#include <base/callback.h> 267b948f060281eb1f9ab198bce67da5aadf03df60Alex Deymo#include <base/memory/ref_counted.h> 27db799534a8f6ae061ed6d6a46ed800f55d50325bAlex Deymo#include <base/memory/weak_ptr.h> 2875039d7397f03dff77bdf4e26398049ff88edc4cAlex Vakulenko#include <base/time/time.h> 293f39d5cc753905874d8d93bef94f857b8808f19eAlex Vakulenko#include <brillo/message_loops/message_loop.h> 307b948f060281eb1f9ab198bce67da5aadf03df60Alex Deymo 3139910dcd1d68987ccee7c3031dc269233a8490bbAlex Deymo#include "update_engine/common/clock_interface.h" 3263784a578dd26880454d70797519358a2326291bAlex Deymo#include "update_engine/update_manager/boxed_value.h" 3363784a578dd26880454d70797519358a2326291bAlex Deymo#include "update_engine/update_manager/variable.h" 3423949d4e086ca984ca2ce07efb6d4ae2bc5daf42Alex Deymo 3563784a578dd26880454d70797519358a2326291bAlex Deymonamespace chromeos_update_manager { 3623949d4e086ca984ca2ce07efb6d4ae2bc5daf42Alex Deymo 3723949d4e086ca984ca2ce07efb6d4ae2bc5daf42Alex Deymo// The EvaluationContext class is the interface between a policy implementation 3823949d4e086ca984ca2ce07efb6d4ae2bc5daf42Alex Deymo// and the state. The EvaluationContext tracks the variables used by a policy 3923949d4e086ca984ca2ce07efb6d4ae2bc5daf42Alex Deymo// request and caches the returned values, owning those cached values. 4041a75a7ca3f0252f2c9f991dd465aa332e7ce4d1Alex Deymo// The same EvaluationContext should be re-used for all the evaluations of the 4141a75a7ca3f0252f2c9f991dd465aa332e7ce4d1Alex Deymo// same policy request (an AsyncPolicyRequest might involve several 4241a75a7ca3f0252f2c9f991dd465aa332e7ce4d1Alex Deymo// re-evaluations). Each evaluation of the EvaluationContext is run at a given 4341a75a7ca3f0252f2c9f991dd465aa332e7ce4d1Alex Deymo// point in time, which is used as a reference for the evaluation timeout and 44a65fced5f4c2b551616b26ee90a800b44090735fGilad Arnold// the time based queries of the policy, such as 45a65fced5f4c2b551616b26ee90a800b44090735fGilad Arnold// Is{Wallclock,Monotonic}TimeGreaterThan(). 4641a75a7ca3f0252f2c9f991dd465aa332e7ce4d1Alex Deymo// 4741a75a7ca3f0252f2c9f991dd465aa332e7ce4d1Alex Deymo// Example: 4841a75a7ca3f0252f2c9f991dd465aa332e7ce4d1Alex Deymo// 49f9f85d6680164064648ce3ed1d31589e1f1b7a29Gilad Arnold// scoped_refptr<EvaluationContext> ec = new EvaluationContext(...); 5041a75a7ca3f0252f2c9f991dd465aa332e7ce4d1Alex Deymo// 5141a75a7ca3f0252f2c9f991dd465aa332e7ce4d1Alex Deymo// ... 5241a75a7ca3f0252f2c9f991dd465aa332e7ce4d1Alex Deymo// // The following call to ResetEvaluation() is optional. Use it to reset the 5341a75a7ca3f0252f2c9f991dd465aa332e7ce4d1Alex Deymo// // evaluation time if the EvaluationContext isn't used right after its 5441a75a7ca3f0252f2c9f991dd465aa332e7ce4d1Alex Deymo// // construction. 5541a75a7ca3f0252f2c9f991dd465aa332e7ce4d1Alex Deymo// ec->ResetEvaluation(); 5641a75a7ca3f0252f2c9f991dd465aa332e7ce4d1Alex Deymo// EvalStatus status = policy->SomeMethod(ec, state, &result, args...); 5741a75a7ca3f0252f2c9f991dd465aa332e7ce4d1Alex Deymo// 5841a75a7ca3f0252f2c9f991dd465aa332e7ce4d1Alex Deymo// ... 5941a75a7ca3f0252f2c9f991dd465aa332e7ce4d1Alex Deymo// // Run a closure when any of the used async variables changes its value or 60072359ca138504065e1e0c1189eb38c09576d324Alex Vakulenko// // the timeout for re-query the values happens again. 6141a75a7ca3f0252f2c9f991dd465aa332e7ce4d1Alex Deymo// ec->RunOnValueChangeOrTimeout(closure); 6241a75a7ca3f0252f2c9f991dd465aa332e7ce4d1Alex Deymo// // If the provided |closure| wants to re-evaluate the policy, it should 6341a75a7ca3f0252f2c9f991dd465aa332e7ce4d1Alex Deymo// // call ec->ResetEvaluation() to start a new evaluation. 6441a75a7ca3f0252f2c9f991dd465aa332e7ce4d1Alex Deymo// 6548415f1f6c6c356bfa9ac85b76d8ebcf053f7157Gilad Arnoldclass EvaluationContext : public base::RefCounted<EvaluationContext>, 6648415f1f6c6c356bfa9ac85b76d8ebcf053f7157Gilad Arnold private BaseVariable::ObserverInterface { 6723949d4e086ca984ca2ce07efb6d4ae2bc5daf42Alex Deymo public: 6883ffddaa3b09ceb4361e5c01ba300d57ab697a7eGilad Arnold EvaluationContext( 6983ffddaa3b09ceb4361e5c01ba300d57ab697a7eGilad Arnold chromeos_update_engine::ClockInterface* clock, 7083ffddaa3b09ceb4361e5c01ba300d57ab697a7eGilad Arnold base::TimeDelta evaluation_timeout, 7183ffddaa3b09ceb4361e5c01ba300d57ab697a7eGilad Arnold base::TimeDelta expiration_timeout, 7202f7c1dee242f490143791dbb73fa23fa3007cfaBen Chan std::unique_ptr<base::Callback<void(EvaluationContext*)>> unregister_cb); 73f9f85d6680164064648ce3ed1d31589e1f1b7a29Gilad Arnold EvaluationContext(chromeos_update_engine::ClockInterface* clock, 74f9f85d6680164064648ce3ed1d31589e1f1b7a29Gilad Arnold base::TimeDelta evaluation_timeout) 7583ffddaa3b09ceb4361e5c01ba300d57ab697a7eGilad Arnold : EvaluationContext( 7683ffddaa3b09ceb4361e5c01ba300d57ab697a7eGilad Arnold clock, evaluation_timeout, base::TimeDelta::Max(), 7702f7c1dee242f490143791dbb73fa23fa3007cfaBen Chan std::unique_ptr<base::Callback<void(EvaluationContext*)>>()) {} 7853556eccd206bacd5c9c8bb6605bcceb1bcb6190Alex Deymo ~EvaluationContext(); 7923949d4e086ca984ca2ce07efb6d4ae2bc5daf42Alex Deymo 8023949d4e086ca984ca2ce07efb6d4ae2bc5daf42Alex Deymo // Returns a pointer to the value returned by the passed variable |var|. The 8123949d4e086ca984ca2ce07efb6d4ae2bc5daf42Alex Deymo // EvaluationContext instance keeps the ownership of the returned object. The 8241a75a7ca3f0252f2c9f991dd465aa332e7ce4d1Alex Deymo // returned object is valid during the life of the evaluation, even if the 8341a75a7ca3f0252f2c9f991dd465aa332e7ce4d1Alex Deymo // passed Variable changes it. 8423949d4e086ca984ca2ce07efb6d4ae2bc5daf42Alex Deymo // 8588b591f24cb3f94f982d7024c2e8ed25c2cc26a2Alex Vakulenko // In case of error, a null value is returned. 8623949d4e086ca984ca2ce07efb6d4ae2bc5daf42Alex Deymo template<typename T> 8723949d4e086ca984ca2ce07efb6d4ae2bc5daf42Alex Deymo const T* GetValue(Variable<T>* var); 8823949d4e086ca984ca2ce07efb6d4ae2bc5daf42Alex Deymo 89a65fced5f4c2b551616b26ee90a800b44090735fGilad Arnold // Returns whether the evaluation time has surpassed |timestamp|, on either 90a65fced5f4c2b551616b26ee90a800b44090735fGilad Arnold // the ClockInterface::GetWallclockTime() or 91a65fced5f4c2b551616b26ee90a800b44090735fGilad Arnold // ClockInterface::GetMonotonicTime() scales, respectively. 92a65fced5f4c2b551616b26ee90a800b44090735fGilad Arnold bool IsWallclockTimeGreaterThan(base::Time timestamp); 93a65fced5f4c2b551616b26ee90a800b44090735fGilad Arnold bool IsMonotonicTimeGreaterThan(base::Time timestamp); 9441a75a7ca3f0252f2c9f991dd465aa332e7ce4d1Alex Deymo 95f9f85d6680164064648ce3ed1d31589e1f1b7a29Gilad Arnold // Returns whether the evaluation context has expired. 96f9f85d6680164064648ce3ed1d31589e1f1b7a29Gilad Arnold bool is_expired() const { return is_expired_; } 97f9f85d6680164064648ce3ed1d31589e1f1b7a29Gilad Arnold 9841a75a7ca3f0252f2c9f991dd465aa332e7ce4d1Alex Deymo // TODO(deymo): Move the following methods to an interface only visible by the 9963784a578dd26880454d70797519358a2326291bAlex Deymo // UpdateManager class and not the policy implementations. 10041a75a7ca3f0252f2c9f991dd465aa332e7ce4d1Alex Deymo 10141a75a7ca3f0252f2c9f991dd465aa332e7ce4d1Alex Deymo // Resets the EvaluationContext to its initial state removing all the 10241a75a7ca3f0252f2c9f991dd465aa332e7ce4d1Alex Deymo // non-const cached variables and re-setting the evaluation time. This should 10341a75a7ca3f0252f2c9f991dd465aa332e7ce4d1Alex Deymo // be called right before any new evaluation starts. 10441a75a7ca3f0252f2c9f991dd465aa332e7ce4d1Alex Deymo void ResetEvaluation(); 10541a75a7ca3f0252f2c9f991dd465aa332e7ce4d1Alex Deymo 106fd45a731d9f9176ce134b34e2a84acc0cf403d1dGilad Arnold // Clears the expiration status of the EvaluationContext and resets its 107fd45a731d9f9176ce134b34e2a84acc0cf403d1dGilad Arnold // expiration timeout based on |expiration_timeout_|. This should be called if 108fd45a731d9f9176ce134b34e2a84acc0cf403d1dGilad Arnold // expiration occurred, prior to re-evaluating the policy. 109fd45a731d9f9176ce134b34e2a84acc0cf403d1dGilad Arnold void ResetExpiration(); 110fd45a731d9f9176ce134b34e2a84acc0cf403d1dGilad Arnold 11153556eccd206bacd5c9c8bb6605bcceb1bcb6190Alex Deymo // Schedules the passed |callback| closure to be called when a cached 112f9f85d6680164064648ce3ed1d31589e1f1b7a29Gilad Arnold // variable changes its value, a polling interval passes, or the context 113f9f85d6680164064648ce3ed1d31589e1f1b7a29Gilad Arnold // expiration occurs. If none of these events can happen, for example if 114f9f85d6680164064648ce3ed1d31589e1f1b7a29Gilad Arnold // there's no cached variable, this method returns false. 11553556eccd206bacd5c9c8bb6605bcceb1bcb6190Alex Deymo // 11653556eccd206bacd5c9c8bb6605bcceb1bcb6190Alex Deymo // Right before the passed closure is called the EvaluationContext is 11753556eccd206bacd5c9c8bb6605bcceb1bcb6190Alex Deymo // reseted, removing all the non-const cached values. 11853556eccd206bacd5c9c8bb6605bcceb1bcb6190Alex Deymo bool RunOnValueChangeOrTimeout(base::Closure callback); 11953556eccd206bacd5c9c8bb6605bcceb1bcb6190Alex Deymo 120c14902888be0b8d41759e6ff0a7100af4097fd09David Zeuthen // Returns a textual representation of the evaluation context, 121c14902888be0b8d41759e6ff0a7100af4097fd09David Zeuthen // including the variables and their values. This is intended only 122c14902888be0b8d41759e6ff0a7100af4097fd09David Zeuthen // to help with debugging and the format may change in the future. 123c14902888be0b8d41759e6ff0a7100af4097fd09David Zeuthen std::string DumpContext() const; 124c14902888be0b8d41759e6ff0a7100af4097fd09David Zeuthen 12583ffddaa3b09ceb4361e5c01ba300d57ab697a7eGilad Arnold // Removes all the Observers callbacks and timeout events scheduled by 12683ffddaa3b09ceb4361e5c01ba300d57ab697a7eGilad Arnold // RunOnValueChangeOrTimeout(). Also releases and returns the closure 12783ffddaa3b09ceb4361e5c01ba300d57ab697a7eGilad Arnold // associated with these events. This method is idempotent. 12802f7c1dee242f490143791dbb73fa23fa3007cfaBen Chan std::unique_ptr<base::Closure> RemoveObserversAndTimeout(); 12983ffddaa3b09ceb4361e5c01ba300d57ab697a7eGilad Arnold 13023949d4e086ca984ca2ce07efb6d4ae2bc5daf42Alex Deymo private: 131fb794f4b7274576e10b0df291655ad6c88a97df4Gilad Arnold friend class UmEvaluationContextTest; 132fb794f4b7274576e10b0df291655ad6c88a97df4Gilad Arnold 13353556eccd206bacd5c9c8bb6605bcceb1bcb6190Alex Deymo // BaseVariable::ObserverInterface override. 134610277efc6f7e5239158dfa4bb3b1021804326e0Alex Deymo void ValueChanged(BaseVariable* var) override; 13553556eccd206bacd5c9c8bb6605bcceb1bcb6190Alex Deymo 136f9f85d6680164064648ce3ed1d31589e1f1b7a29Gilad Arnold // Called from the main loop when a scheduled timeout has passed. 137f9f85d6680164064648ce3ed1d31589e1f1b7a29Gilad Arnold void OnTimeout(); 138f9f85d6680164064648ce3ed1d31589e1f1b7a29Gilad Arnold 139f9f85d6680164064648ce3ed1d31589e1f1b7a29Gilad Arnold // Removes the observers from the used Variables and cancels the timeout, 140f9f85d6680164064648ce3ed1d31589e1f1b7a29Gilad Arnold // then executes the scheduled callback. 141f9f85d6680164064648ce3ed1d31589e1f1b7a29Gilad Arnold void OnValueChangedOrTimeout(); 14253556eccd206bacd5c9c8bb6605bcceb1bcb6190Alex Deymo 143f9f85d6680164064648ce3ed1d31589e1f1b7a29Gilad Arnold // If |monotonic_deadline| is not Time::Max(), returns the remaining time 144f9f85d6680164064648ce3ed1d31589e1f1b7a29Gilad Arnold // until it is reached, or zero if it has passed. Otherwise, returns 145f9f85d6680164064648ce3ed1d31589e1f1b7a29Gilad Arnold // TimeDelta::Max(). 146f9f85d6680164064648ce3ed1d31589e1f1b7a29Gilad Arnold base::TimeDelta RemainingTime(base::Time monotonic_deadline) const; 14753556eccd206bacd5c9c8bb6605bcceb1bcb6190Alex Deymo 148f9f85d6680164064648ce3ed1d31589e1f1b7a29Gilad Arnold // Returns a monotonic clock timestamp at which |timeout| will have elapsed 149f9f85d6680164064648ce3ed1d31589e1f1b7a29Gilad Arnold // since the current time. 150f9f85d6680164064648ce3ed1d31589e1f1b7a29Gilad Arnold base::Time MonotonicDeadline(base::TimeDelta timeout); 15123949d4e086ca984ca2ce07efb6d4ae2bc5daf42Alex Deymo 15223949d4e086ca984ca2ce07efb6d4ae2bc5daf42Alex Deymo // A map to hold the cached values for every variable. 15323949d4e086ca984ca2ce07efb6d4ae2bc5daf42Alex Deymo typedef std::map<BaseVariable*, BoxedValue> ValueCacheMap; 15423949d4e086ca984ca2ce07efb6d4ae2bc5daf42Alex Deymo 15523949d4e086ca984ca2ce07efb6d4ae2bc5daf42Alex Deymo // The cached values of the called Variables. 15623949d4e086ca984ca2ce07efb6d4ae2bc5daf42Alex Deymo ValueCacheMap value_cache_; 15723949d4e086ca984ca2ce07efb6d4ae2bc5daf42Alex Deymo 158f9f85d6680164064648ce3ed1d31589e1f1b7a29Gilad Arnold // A callback used for triggering re-evaluation upon a value change or poll 159f9f85d6680164064648ce3ed1d31589e1f1b7a29Gilad Arnold // timeout, or notifying about the evaluation context expiration. It is up to 160072359ca138504065e1e0c1189eb38c09576d324Alex Vakulenko // the caller to determine whether or not expiration occurred via 161072359ca138504065e1e0c1189eb38c09576d324Alex Vakulenko // is_expired(). 16202f7c1dee242f490143791dbb73fa23fa3007cfaBen Chan std::unique_ptr<base::Closure> callback_; 16353556eccd206bacd5c9c8bb6605bcceb1bcb6190Alex Deymo 164509dd5376f47e38d18fe7d29da776e3dc9a9786dAlex Deymo // The TaskId returned by the message loop identifying the timeout callback. 165f9f85d6680164064648ce3ed1d31589e1f1b7a29Gilad Arnold // Used for canceling the timeout callback. 1663f39d5cc753905874d8d93bef94f857b8808f19eAlex Vakulenko brillo::MessageLoop::TaskId timeout_event_ = 1673f39d5cc753905874d8d93bef94f857b8808f19eAlex Vakulenko brillo::MessageLoop::kTaskIdNull; 168f9f85d6680164064648ce3ed1d31589e1f1b7a29Gilad Arnold 169f9f85d6680164064648ce3ed1d31589e1f1b7a29Gilad Arnold // Whether a timeout event firing marks the expiration of the evaluation 170f9f85d6680164064648ce3ed1d31589e1f1b7a29Gilad Arnold // context. 171f9f85d6680164064648ce3ed1d31589e1f1b7a29Gilad Arnold bool timeout_marks_expiration_; 172f9f85d6680164064648ce3ed1d31589e1f1b7a29Gilad Arnold 173f9f85d6680164064648ce3ed1d31589e1f1b7a29Gilad Arnold // Whether the evaluation context has indeed expired. 174f9f85d6680164064648ce3ed1d31589e1f1b7a29Gilad Arnold bool is_expired_ = false; 17553556eccd206bacd5c9c8bb6605bcceb1bcb6190Alex Deymo 17641a75a7ca3f0252f2c9f991dd465aa332e7ce4d1Alex Deymo // Pointer to the mockable clock interface; 177f9f85d6680164064648ce3ed1d31589e1f1b7a29Gilad Arnold chromeos_update_engine::ClockInterface* const clock_; 17841a75a7ca3f0252f2c9f991dd465aa332e7ce4d1Alex Deymo 179a65fced5f4c2b551616b26ee90a800b44090735fGilad Arnold // The timestamps when the evaluation of this EvaluationContext started, 180a65fced5f4c2b551616b26ee90a800b44090735fGilad Arnold // corresponding to ClockInterface::GetWallclockTime() and 181a65fced5f4c2b551616b26ee90a800b44090735fGilad Arnold // ClockInterface::GetMonotonicTime(), respectively. These values are reset 182a65fced5f4c2b551616b26ee90a800b44090735fGilad Arnold // every time ResetEvaluation() is called. 183a65fced5f4c2b551616b26ee90a800b44090735fGilad Arnold base::Time evaluation_start_wallclock_; 184a65fced5f4c2b551616b26ee90a800b44090735fGilad Arnold base::Time evaluation_start_monotonic_; 185a65fced5f4c2b551616b26ee90a800b44090735fGilad Arnold 186a65fced5f4c2b551616b26ee90a800b44090735fGilad Arnold // The timestamps when a reevaluation should be triggered due to various 187a65fced5f4c2b551616b26ee90a800b44090735fGilad Arnold // expected value changes, corresponding to ClockInterface::GetWallclockTime() 188a65fced5f4c2b551616b26ee90a800b44090735fGilad Arnold // and ClockInterface::GetMonotonicTIme(), respectively. These timestamps are 189a65fced5f4c2b551616b26ee90a800b44090735fGilad Arnold // greater or equal to corresponding |evaluation_start_{wallclock,monotonic}_| 190a65fced5f4c2b551616b26ee90a800b44090735fGilad Arnold // counterparts since they are in the future; however, they may be smaller 191a65fced5f4c2b551616b26ee90a800b44090735fGilad Arnold // than the current corresponding times during the course of evaluation. 192a65fced5f4c2b551616b26ee90a800b44090735fGilad Arnold base::Time reevaluation_time_wallclock_; 193a65fced5f4c2b551616b26ee90a800b44090735fGilad Arnold base::Time reevaluation_time_monotonic_; 19441a75a7ca3f0252f2c9f991dd465aa332e7ce4d1Alex Deymo 195f9f85d6680164064648ce3ed1d31589e1f1b7a29Gilad Arnold // The timeout of an evaluation. 196b227199133f2d694414293697c67599a761f23beGilad Arnold const base::TimeDelta evaluation_timeout_; 19741a75a7ca3f0252f2c9f991dd465aa332e7ce4d1Alex Deymo 19841a75a7ca3f0252f2c9f991dd465aa332e7ce4d1Alex Deymo // The timestamp in the ClockInterface::GetMonotonicTime() scale at which the 199f9f85d6680164064648ce3ed1d31589e1f1b7a29Gilad Arnold // current evaluation should finish. 20041a75a7ca3f0252f2c9f991dd465aa332e7ce4d1Alex Deymo base::Time evaluation_monotonic_deadline_; 20141a75a7ca3f0252f2c9f991dd465aa332e7ce4d1Alex Deymo 202fd45a731d9f9176ce134b34e2a84acc0cf403d1dGilad Arnold // The expiration timeout of the evaluation context. 203fd45a731d9f9176ce134b34e2a84acc0cf403d1dGilad Arnold const base::TimeDelta expiration_timeout_; 204fd45a731d9f9176ce134b34e2a84acc0cf403d1dGilad Arnold 205fd45a731d9f9176ce134b34e2a84acc0cf403d1dGilad Arnold // The monotonic clock deadline at which expiration occurs. 206fd45a731d9f9176ce134b34e2a84acc0cf403d1dGilad Arnold base::Time expiration_monotonic_deadline_; 207f9f85d6680164064648ce3ed1d31589e1f1b7a29Gilad Arnold 20883ffddaa3b09ceb4361e5c01ba300d57ab697a7eGilad Arnold // A callback for unregistering the context upon destruction. 20902f7c1dee242f490143791dbb73fa23fa3007cfaBen Chan std::unique_ptr<base::Callback<void(EvaluationContext*)>> unregister_cb_; 21083ffddaa3b09ceb4361e5c01ba300d57ab697a7eGilad Arnold 211db799534a8f6ae061ed6d6a46ed800f55d50325bAlex Deymo base::WeakPtrFactory<EvaluationContext> weak_ptr_factory_; 212db799534a8f6ae061ed6d6a46ed800f55d50325bAlex Deymo 21323949d4e086ca984ca2ce07efb6d4ae2bc5daf42Alex Deymo DISALLOW_COPY_AND_ASSIGN(EvaluationContext); 21423949d4e086ca984ca2ce07efb6d4ae2bc5daf42Alex Deymo}; 21523949d4e086ca984ca2ce07efb6d4ae2bc5daf42Alex Deymo 21663784a578dd26880454d70797519358a2326291bAlex Deymo} // namespace chromeos_update_manager 21723949d4e086ca984ca2ce07efb6d4ae2bc5daf42Alex Deymo 21823949d4e086ca984ca2ce07efb6d4ae2bc5daf42Alex Deymo// Include the implementation of the template methods. 21963784a578dd26880454d70797519358a2326291bAlex Deymo#include "update_engine/update_manager/evaluation_context-inl.h" 22023949d4e086ca984ca2ce07efb6d4ae2bc5daf42Alex Deymo 22148415f1f6c6c356bfa9ac85b76d8ebcf053f7157Gilad Arnold#endif // UPDATE_ENGINE_UPDATE_MANAGER_EVALUATION_CONTEXT_H_ 222