| Alex Deymo | aea4c1c | 2015-08-19 20:24:43 -0700 | [diff] [blame] | 1 | // | 
|  | 2 | // Copyright (C) 2014 The Android Open Source Project | 
|  | 3 | // | 
|  | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | 5 | // you may not use this file except in compliance with the License. | 
|  | 6 | // You may obtain a copy of the License at | 
|  | 7 | // | 
|  | 8 | //      http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 9 | // | 
|  | 10 | // Unless required by applicable law or agreed to in writing, software | 
|  | 11 | // distributed under the License is distributed on an "AS IS" BASIS, | 
|  | 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 13 | // See the License for the specific language governing permissions and | 
|  | 14 | // limitations under the License. | 
|  | 15 | // | 
| Alex Deymo | 23949d4 | 2014-02-05 15:20:59 -0800 | [diff] [blame] | 16 |  | 
| Alex Deymo | 63784a5 | 2014-05-28 10:46:14 -0700 | [diff] [blame] | 17 | #include "update_engine/update_manager/evaluation_context.h" | 
| Alex Deymo | 23949d4 | 2014-02-05 15:20:59 -0800 | [diff] [blame] | 18 |  | 
| Gilad Arnold | f9f85d6 | 2014-06-19 18:07:01 -0700 | [diff] [blame] | 19 | #include <algorithm> | 
| Ben Chan | 02f7c1d | 2014-10-18 15:18:02 -0700 | [diff] [blame] | 20 | #include <memory> | 
| David Zeuthen | c149028 | 2014-04-29 16:25:03 -0700 | [diff] [blame] | 21 | #include <string> | 
| Ben Chan | 067053e | 2017-02-07 15:33:32 -0800 | [diff] [blame] | 22 | #include <utility> | 
| David Zeuthen | c149028 | 2014-04-29 16:25:03 -0700 | [diff] [blame] | 23 |  | 
| Alex Deymo | 53556ec | 2014-03-17 10:05:57 -0700 | [diff] [blame] | 24 | #include <base/bind.h> | 
| David Zeuthen | c149028 | 2014-04-29 16:25:03 -0700 | [diff] [blame] | 25 | #include <base/json/json_writer.h> | 
| Alex Deymo | 0bb2341 | 2015-06-19 00:04:46 -0700 | [diff] [blame] | 26 | #include <base/location.h> | 
| Ben Chan | 067053e | 2017-02-07 15:33:32 -0800 | [diff] [blame] | 27 | #include <base/memory/ptr_util.h> | 
| Gilad Arnold | 6e5ab5c | 2014-06-23 15:13:56 -0700 | [diff] [blame] | 28 | #include <base/strings/string_util.h> | 
| David Zeuthen | c149028 | 2014-04-29 16:25:03 -0700 | [diff] [blame] | 29 | #include <base/values.h> | 
|  | 30 |  | 
| Alex Deymo | 39910dc | 2015-11-09 17:04:30 -0800 | [diff] [blame] | 31 | #include "update_engine/common/utils.h" | 
| Alex Deymo | 53556ec | 2014-03-17 10:05:57 -0700 | [diff] [blame] | 32 |  | 
| Gilad Arnold | 83ffdda | 2014-08-08 13:30:31 -0700 | [diff] [blame] | 33 | using base::Callback; | 
| Alex Deymo | 53556ec | 2014-03-17 10:05:57 -0700 | [diff] [blame] | 34 | using base::Closure; | 
| Alex Deymo | 41a75a7 | 2014-04-15 15:36:22 -0700 | [diff] [blame] | 35 | using base::Time; | 
| Alex Deymo | 23949d4 | 2014-02-05 15:20:59 -0800 | [diff] [blame] | 36 | using base::TimeDelta; | 
| Alex Vakulenko | 3f39d5c | 2015-10-13 09:27:13 -0700 | [diff] [blame] | 37 | using brillo::MessageLoop; | 
| Alex Deymo | 41a75a7 | 2014-04-15 15:36:22 -0700 | [diff] [blame] | 38 | using chromeos_update_engine::ClockInterface; | 
| David Zeuthen | c149028 | 2014-04-29 16:25:03 -0700 | [diff] [blame] | 39 | using std::string; | 
| Ben Chan | 02f7c1d | 2014-10-18 15:18:02 -0700 | [diff] [blame] | 40 | using std::unique_ptr; | 
| Alex Deymo | 23949d4 | 2014-02-05 15:20:59 -0800 | [diff] [blame] | 41 |  | 
| Gilad Arnold | a65fced | 2014-07-23 09:01:31 -0700 | [diff] [blame] | 42 | namespace { | 
|  | 43 |  | 
|  | 44 | // Returns whether |curr_time| surpassed |ref_time|; if not, also checks whether | 
|  | 45 | // |ref_time| is sooner than the current value of |*reeval_time|, in which case | 
|  | 46 | // the latter is updated to the former. | 
| Alex Deymo | f329b93 | 2014-10-30 01:37:48 -0700 | [diff] [blame] | 47 | bool IsTimeGreaterThanHelper(Time ref_time, Time curr_time, | 
|  | 48 | Time* reeval_time) { | 
| Gilad Arnold | a65fced | 2014-07-23 09:01:31 -0700 | [diff] [blame] | 49 | if (curr_time > ref_time) | 
|  | 50 | return true; | 
|  | 51 | // Remember the nearest reference we've checked against in this evaluation. | 
|  | 52 | if (*reeval_time > ref_time) | 
|  | 53 | *reeval_time = ref_time; | 
|  | 54 | return false; | 
|  | 55 | } | 
|  | 56 |  | 
|  | 57 | // If |expires| never happens (maximal value), returns the maximal interval; | 
|  | 58 | // otherwise, returns the difference between |expires| and |curr|. | 
| Alex Deymo | f329b93 | 2014-10-30 01:37:48 -0700 | [diff] [blame] | 59 | TimeDelta GetTimeout(Time curr, Time expires) { | 
| Gilad Arnold | a65fced | 2014-07-23 09:01:31 -0700 | [diff] [blame] | 60 | if (expires.is_max()) | 
|  | 61 | return TimeDelta::Max(); | 
|  | 62 | return expires - curr; | 
|  | 63 | } | 
|  | 64 |  | 
|  | 65 | }  // namespace | 
|  | 66 |  | 
| Alex Deymo | 63784a5 | 2014-05-28 10:46:14 -0700 | [diff] [blame] | 67 | namespace chromeos_update_manager { | 
| Alex Deymo | 23949d4 | 2014-02-05 15:20:59 -0800 | [diff] [blame] | 68 |  | 
| Gilad Arnold | 83ffdda | 2014-08-08 13:30:31 -0700 | [diff] [blame] | 69 | EvaluationContext::EvaluationContext( | 
|  | 70 | ClockInterface* clock, | 
|  | 71 | TimeDelta evaluation_timeout, | 
|  | 72 | TimeDelta expiration_timeout, | 
| Ben Chan | 02f7c1d | 2014-10-18 15:18:02 -0700 | [diff] [blame] | 73 | unique_ptr<Callback<void(EvaluationContext*)>> unregister_cb) | 
| Alex Deymo | 41a75a7 | 2014-04-15 15:36:22 -0700 | [diff] [blame] | 74 | : clock_(clock), | 
| Gilad Arnold | b227199 | 2014-06-19 12:35:24 -0700 | [diff] [blame] | 75 | evaluation_timeout_(evaluation_timeout), | 
| Gilad Arnold | fd45a73 | 2014-08-07 15:53:46 -0700 | [diff] [blame] | 76 | expiration_timeout_(expiration_timeout), | 
| Ben Chan | 02f7c1d | 2014-10-18 15:18:02 -0700 | [diff] [blame] | 77 | unregister_cb_(std::move(unregister_cb)), | 
| Alex Deymo | 41a75a7 | 2014-04-15 15:36:22 -0700 | [diff] [blame] | 78 | weak_ptr_factory_(this) { | 
|  | 79 | ResetEvaluation(); | 
| Gilad Arnold | fd45a73 | 2014-08-07 15:53:46 -0700 | [diff] [blame] | 80 | ResetExpiration(); | 
| Alex Deymo | 41a75a7 | 2014-04-15 15:36:22 -0700 | [diff] [blame] | 81 | } | 
|  | 82 |  | 
| Alex Deymo | 53556ec | 2014-03-17 10:05:57 -0700 | [diff] [blame] | 83 | EvaluationContext::~EvaluationContext() { | 
|  | 84 | RemoveObserversAndTimeout(); | 
| Gilad Arnold | 83ffdda | 2014-08-08 13:30:31 -0700 | [diff] [blame] | 85 | if (unregister_cb_.get()) | 
|  | 86 | unregister_cb_->Run(this); | 
| Alex Deymo | 53556ec | 2014-03-17 10:05:57 -0700 | [diff] [blame] | 87 | } | 
|  | 88 |  | 
| Ben Chan | 02f7c1d | 2014-10-18 15:18:02 -0700 | [diff] [blame] | 89 | unique_ptr<Closure> EvaluationContext::RemoveObserversAndTimeout() { | 
| Alex Deymo | 53556ec | 2014-03-17 10:05:57 -0700 | [diff] [blame] | 90 | for (auto& it : value_cache_) { | 
|  | 91 | if (it.first->GetMode() == kVariableModeAsync) | 
|  | 92 | it.first->RemoveObserver(this); | 
|  | 93 | } | 
| Alex Deymo | 509dd53 | 2015-06-10 14:11:05 -0700 | [diff] [blame] | 94 | MessageLoop::current()->CancelTask(timeout_event_); | 
|  | 95 | timeout_event_ = MessageLoop::kTaskIdNull; | 
| Gilad Arnold | 83ffdda | 2014-08-08 13:30:31 -0700 | [diff] [blame] | 96 |  | 
| Alex Vakulenko | ce8c8ee | 2016-04-08 08:59:26 -0700 | [diff] [blame] | 97 | return std::move(callback_); | 
| Alex Deymo | 53556ec | 2014-03-17 10:05:57 -0700 | [diff] [blame] | 98 | } | 
|  | 99 |  | 
| Gilad Arnold | f9f85d6 | 2014-06-19 18:07:01 -0700 | [diff] [blame] | 100 | TimeDelta EvaluationContext::RemainingTime(Time monotonic_deadline) const { | 
|  | 101 | if (monotonic_deadline.is_max()) | 
|  | 102 | return TimeDelta::Max(); | 
|  | 103 | TimeDelta remaining = monotonic_deadline - clock_->GetMonotonicTime(); | 
|  | 104 | return std::max(remaining, TimeDelta()); | 
|  | 105 | } | 
|  | 106 |  | 
|  | 107 | Time EvaluationContext::MonotonicDeadline(TimeDelta timeout) { | 
|  | 108 | return (timeout.is_max() ? Time::Max() : | 
|  | 109 | clock_->GetMonotonicTime() + timeout); | 
| Alex Deymo | 23949d4 | 2014-02-05 15:20:59 -0800 | [diff] [blame] | 110 | } | 
|  | 111 |  | 
| Alex Deymo | 53556ec | 2014-03-17 10:05:57 -0700 | [diff] [blame] | 112 | void EvaluationContext::ValueChanged(BaseVariable* var) { | 
| Gilad Arnold | f9f85d6 | 2014-06-19 18:07:01 -0700 | [diff] [blame] | 113 | DLOG(INFO) << "ValueChanged() called for variable " << var->GetName(); | 
|  | 114 | OnValueChangedOrTimeout(); | 
| Alex Deymo | 53556ec | 2014-03-17 10:05:57 -0700 | [diff] [blame] | 115 | } | 
|  | 116 |  | 
| Gilad Arnold | f9f85d6 | 2014-06-19 18:07:01 -0700 | [diff] [blame] | 117 | void EvaluationContext::OnTimeout() { | 
|  | 118 | DLOG(INFO) << "OnTimeout() called due to " | 
|  | 119 | << (timeout_marks_expiration_ ? "expiration" : "poll interval"); | 
| Alex Deymo | 509dd53 | 2015-06-10 14:11:05 -0700 | [diff] [blame] | 120 | timeout_event_ = MessageLoop::kTaskIdNull; | 
| Gilad Arnold | f9f85d6 | 2014-06-19 18:07:01 -0700 | [diff] [blame] | 121 | is_expired_ = timeout_marks_expiration_; | 
|  | 122 | OnValueChangedOrTimeout(); | 
| Alex Deymo | 53556ec | 2014-03-17 10:05:57 -0700 | [diff] [blame] | 123 | } | 
|  | 124 |  | 
| Gilad Arnold | f9f85d6 | 2014-06-19 18:07:01 -0700 | [diff] [blame] | 125 | void EvaluationContext::OnValueChangedOrTimeout() { | 
| Gilad Arnold | f9f85d6 | 2014-06-19 18:07:01 -0700 | [diff] [blame] | 126 | // Copy the callback handle locally, allowing it to be reassigned. | 
| Ben Chan | 02f7c1d | 2014-10-18 15:18:02 -0700 | [diff] [blame] | 127 | unique_ptr<Closure> callback = RemoveObserversAndTimeout(); | 
| Gilad Arnold | f9f85d6 | 2014-06-19 18:07:01 -0700 | [diff] [blame] | 128 |  | 
|  | 129 | if (callback.get()) | 
| Gilad Arnold | fb794f4 | 2014-07-01 15:36:31 -0700 | [diff] [blame] | 130 | callback->Run(); | 
| Alex Deymo | 41a75a7 | 2014-04-15 15:36:22 -0700 | [diff] [blame] | 131 | } | 
|  | 132 |  | 
| Alex Deymo | f329b93 | 2014-10-30 01:37:48 -0700 | [diff] [blame] | 133 | bool EvaluationContext::IsWallclockTimeGreaterThan(Time timestamp) { | 
| Gilad Arnold | a65fced | 2014-07-23 09:01:31 -0700 | [diff] [blame] | 134 | return IsTimeGreaterThanHelper(timestamp, evaluation_start_wallclock_, | 
|  | 135 | &reevaluation_time_wallclock_); | 
|  | 136 | } | 
|  | 137 |  | 
| Alex Deymo | f329b93 | 2014-10-30 01:37:48 -0700 | [diff] [blame] | 138 | bool EvaluationContext::IsMonotonicTimeGreaterThan(Time timestamp) { | 
| Gilad Arnold | a65fced | 2014-07-23 09:01:31 -0700 | [diff] [blame] | 139 | return IsTimeGreaterThanHelper(timestamp, evaluation_start_monotonic_, | 
|  | 140 | &reevaluation_time_monotonic_); | 
| Alex Deymo | 41a75a7 | 2014-04-15 15:36:22 -0700 | [diff] [blame] | 141 | } | 
|  | 142 |  | 
|  | 143 | void EvaluationContext::ResetEvaluation() { | 
| Gilad Arnold | a65fced | 2014-07-23 09:01:31 -0700 | [diff] [blame] | 144 | evaluation_start_wallclock_ = clock_->GetWallclockTime(); | 
|  | 145 | evaluation_start_monotonic_ = clock_->GetMonotonicTime(); | 
|  | 146 | reevaluation_time_wallclock_ = Time::Max(); | 
|  | 147 | reevaluation_time_monotonic_ = Time::Max(); | 
| Gilad Arnold | f9f85d6 | 2014-06-19 18:07:01 -0700 | [diff] [blame] | 148 | evaluation_monotonic_deadline_ = MonotonicDeadline(evaluation_timeout_); | 
| Alex Deymo | 41a75a7 | 2014-04-15 15:36:22 -0700 | [diff] [blame] | 149 |  | 
| Alex Deymo | 53556ec | 2014-03-17 10:05:57 -0700 | [diff] [blame] | 150 | // Remove the cached values of non-const variables | 
|  | 151 | for (auto it = value_cache_.begin(); it != value_cache_.end(); ) { | 
|  | 152 | if (it->first->GetMode() == kVariableModeConst) { | 
|  | 153 | ++it; | 
|  | 154 | } else { | 
|  | 155 | it = value_cache_.erase(it); | 
|  | 156 | } | 
|  | 157 | } | 
| Alex Deymo | 53556ec | 2014-03-17 10:05:57 -0700 | [diff] [blame] | 158 | } | 
|  | 159 |  | 
| Gilad Arnold | fd45a73 | 2014-08-07 15:53:46 -0700 | [diff] [blame] | 160 | void EvaluationContext::ResetExpiration() { | 
|  | 161 | expiration_monotonic_deadline_ = MonotonicDeadline(expiration_timeout_); | 
|  | 162 | is_expired_ = false; | 
|  | 163 | } | 
|  | 164 |  | 
| Alex Deymo | 53556ec | 2014-03-17 10:05:57 -0700 | [diff] [blame] | 165 | bool EvaluationContext::RunOnValueChangeOrTimeout(Closure callback) { | 
| Gilad Arnold | f9f85d6 | 2014-06-19 18:07:01 -0700 | [diff] [blame] | 166 | // Check that the method was not called more than once. | 
| Alex Vakulenko | 88b591f | 2014-08-28 16:48:57 -0700 | [diff] [blame] | 167 | if (callback_.get()) { | 
| Alex Deymo | 53556ec | 2014-03-17 10:05:57 -0700 | [diff] [blame] | 168 | LOG(ERROR) << "RunOnValueChangeOrTimeout called more than once."; | 
|  | 169 | return false; | 
|  | 170 | } | 
|  | 171 |  | 
| Gilad Arnold | f9f85d6 | 2014-06-19 18:07:01 -0700 | [diff] [blame] | 172 | // Check that the context did not yet expire. | 
|  | 173 | if (is_expired()) { | 
|  | 174 | LOG(ERROR) << "RunOnValueChangeOrTimeout called on an expired context."; | 
|  | 175 | return false; | 
|  | 176 | } | 
|  | 177 |  | 
| Gilad Arnold | a65fced | 2014-07-23 09:01:31 -0700 | [diff] [blame] | 178 | // Handle reevaluation due to a Is{Wallclock,Monotonic}TimeGreaterThan(). We | 
|  | 179 | // choose the smaller of the differences between evaluation start time and | 
|  | 180 | // reevaluation time among the wallclock and monotonic scales. | 
|  | 181 | TimeDelta timeout = std::min( | 
|  | 182 | GetTimeout(evaluation_start_wallclock_, reevaluation_time_wallclock_), | 
|  | 183 | GetTimeout(evaluation_start_monotonic_, reevaluation_time_monotonic_)); | 
| Gilad Arnold | f9f85d6 | 2014-06-19 18:07:01 -0700 | [diff] [blame] | 184 |  | 
|  | 185 | // Handle reevaluation due to async or poll variables. | 
| Gilad Arnold | a65fced | 2014-07-23 09:01:31 -0700 | [diff] [blame] | 186 | bool waiting_for_value_change = false; | 
| Alex Deymo | 53556ec | 2014-03-17 10:05:57 -0700 | [diff] [blame] | 187 | for (auto& it : value_cache_) { | 
|  | 188 | switch (it.first->GetMode()) { | 
|  | 189 | case kVariableModeAsync: | 
| Alex Deymo | 53556ec | 2014-03-17 10:05:57 -0700 | [diff] [blame] | 190 | DLOG(INFO) << "Waiting for value on " << it.first->GetName(); | 
|  | 191 | it.first->AddObserver(this); | 
| Gilad Arnold | f9f85d6 | 2014-06-19 18:07:01 -0700 | [diff] [blame] | 192 | waiting_for_value_change = true; | 
| Alex Deymo | 53556ec | 2014-03-17 10:05:57 -0700 | [diff] [blame] | 193 | break; | 
|  | 194 | case kVariableModePoll: | 
| Gilad Arnold | f9f85d6 | 2014-06-19 18:07:01 -0700 | [diff] [blame] | 195 | timeout = std::min(timeout, it.first->GetPollInterval()); | 
| Alex Deymo | 53556ec | 2014-03-17 10:05:57 -0700 | [diff] [blame] | 196 | break; | 
|  | 197 | case kVariableModeConst: | 
|  | 198 | // Ignored. | 
|  | 199 | break; | 
|  | 200 | } | 
|  | 201 | } | 
| Gilad Arnold | f9f85d6 | 2014-06-19 18:07:01 -0700 | [diff] [blame] | 202 |  | 
| Alex Deymo | 53556ec | 2014-03-17 10:05:57 -0700 | [diff] [blame] | 203 | // Check if the re-evaluation is actually being scheduled. If there are no | 
|  | 204 | // events waited for, this function should return false. | 
| Gilad Arnold | f9f85d6 | 2014-06-19 18:07:01 -0700 | [diff] [blame] | 205 | if (!waiting_for_value_change && timeout.is_max()) | 
| Alex Deymo | 53556ec | 2014-03-17 10:05:57 -0700 | [diff] [blame] | 206 | return false; | 
| Gilad Arnold | f9f85d6 | 2014-06-19 18:07:01 -0700 | [diff] [blame] | 207 |  | 
|  | 208 | // Ensure that we take into account the expiration timeout. | 
|  | 209 | TimeDelta expiration = RemainingTime(expiration_monotonic_deadline_); | 
|  | 210 | timeout_marks_expiration_ = expiration < timeout; | 
|  | 211 | if (timeout_marks_expiration_) | 
|  | 212 | timeout = expiration; | 
|  | 213 |  | 
|  | 214 | // Store the reevaluation callback. | 
|  | 215 | callback_.reset(new Closure(callback)); | 
|  | 216 |  | 
|  | 217 | // Schedule a timeout event, if one is set. | 
|  | 218 | if (!timeout.is_max()) { | 
|  | 219 | DLOG(INFO) << "Waiting for timeout in " | 
|  | 220 | << chromeos_update_engine::utils::FormatTimeDelta(timeout); | 
| Alex Deymo | 509dd53 | 2015-06-10 14:11:05 -0700 | [diff] [blame] | 221 | timeout_event_ = MessageLoop::current()->PostDelayedTask( | 
| Alex Deymo | 0bb2341 | 2015-06-19 00:04:46 -0700 | [diff] [blame] | 222 | FROM_HERE, | 
| Gilad Arnold | f9f85d6 | 2014-06-19 18:07:01 -0700 | [diff] [blame] | 223 | base::Bind(&EvaluationContext::OnTimeout, | 
| Alex Deymo | db79953 | 2014-03-21 13:00:00 -0700 | [diff] [blame] | 224 | weak_ptr_factory_.GetWeakPtr()), | 
| Gilad Arnold | f9f85d6 | 2014-06-19 18:07:01 -0700 | [diff] [blame] | 225 | timeout); | 
| Alex Deymo | 53556ec | 2014-03-17 10:05:57 -0700 | [diff] [blame] | 226 | } | 
|  | 227 |  | 
| Alex Deymo | 53556ec | 2014-03-17 10:05:57 -0700 | [diff] [blame] | 228 | return true; | 
|  | 229 | } | 
|  | 230 |  | 
| David Zeuthen | c149028 | 2014-04-29 16:25:03 -0700 | [diff] [blame] | 231 | string EvaluationContext::DumpContext() const { | 
| Ben Chan | 067053e | 2017-02-07 15:33:32 -0800 | [diff] [blame] | 232 | auto variables = base::MakeUnique<base::DictionaryValue>(); | 
| David Zeuthen | c149028 | 2014-04-29 16:25:03 -0700 | [diff] [blame] | 233 | for (auto& it : value_cache_) { | 
|  | 234 | variables->SetString(it.first->GetName(), it.second.ToString()); | 
|  | 235 | } | 
|  | 236 |  | 
|  | 237 | base::DictionaryValue value; | 
| Ben Chan | 067053e | 2017-02-07 15:33:32 -0800 | [diff] [blame] | 238 | value.Set("variables", std::move(variables)); | 
| Gilad Arnold | a65fced | 2014-07-23 09:01:31 -0700 | [diff] [blame] | 239 | value.SetString( | 
|  | 240 | "evaluation_start_wallclock", | 
|  | 241 | chromeos_update_engine::utils::ToString(evaluation_start_wallclock_)); | 
|  | 242 | value.SetString( | 
|  | 243 | "evaluation_start_monotonic", | 
|  | 244 | chromeos_update_engine::utils::ToString(evaluation_start_monotonic_)); | 
| David Zeuthen | c149028 | 2014-04-29 16:25:03 -0700 | [diff] [blame] | 245 |  | 
|  | 246 | string json_str; | 
| Alex Vakulenko | 6a9d349 | 2015-06-15 12:53:22 -0700 | [diff] [blame] | 247 | base::JSONWriter::WriteWithOptions( | 
|  | 248 | value, base::JSONWriter::OPTIONS_PRETTY_PRINT, &json_str); | 
| Gilad Arnold | 6e5ab5c | 2014-06-23 15:13:56 -0700 | [diff] [blame] | 249 | base::TrimWhitespaceASCII(json_str, base::TRIM_TRAILING, &json_str); | 
| David Zeuthen | c149028 | 2014-04-29 16:25:03 -0700 | [diff] [blame] | 250 |  | 
|  | 251 | return json_str; | 
|  | 252 | } | 
|  | 253 |  | 
| Alex Deymo | 63784a5 | 2014-05-28 10:46:14 -0700 | [diff] [blame] | 254 | }  // namespace chromeos_update_manager |