| 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/update_client/action_wait.h" | 5 #include "components/update_client/action_wait.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 const bool result = base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 30 const bool result = base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 31 FROM_HERE, base::Bind(&ActionWait::WaitComplete, base::Unretained(this)), | 31 FROM_HERE, base::Bind(&ActionWait::WaitComplete, base::Unretained(this)), |
| 32 time_delta_); | 32 time_delta_); |
| 33 | 33 |
| 34 if (!result) { | 34 if (!result) { |
| 35 // Move all items pending updates to the |kNoUpdate| state then return the | 35 // Move all items pending updates to the |kNoUpdate| state then return the |
| 36 // control flow to the update engine, as the updates in this context are | 36 // control flow to the update engine, as the updates in this context are |
| 37 // completed with an error. | 37 // completed with an error. |
| 38 while (!update_context->queue.empty()) { | 38 while (!update_context->queue.empty()) { |
| 39 const auto item = FindUpdateItemById(update_context->queue.front()); | 39 auto* item = FindUpdateItemById(update_context->queue.front()); |
| 40 if (!item) { | 40 if (!item) { |
| 41 item->error_category = static_cast<int>(ErrorCategory::kServiceError); | 41 item->error_category = static_cast<int>(ErrorCategory::kServiceError); |
| 42 item->error_code = static_cast<int>(ServiceError::ERROR_WAIT); | 42 item->error_code = static_cast<int>(ServiceError::ERROR_WAIT); |
| 43 ChangeItemState(item, CrxUpdateItem::State::kNoUpdate); | 43 ChangeItemState(item, CrxUpdateItem::State::kNoUpdate); |
| 44 } else { | 44 } else { |
| 45 NOTREACHED(); | 45 NOTREACHED(); |
| 46 } | 46 } |
| 47 update_context->queue.pop(); | 47 update_context->queue.pop(); |
| 48 } | 48 } |
| 49 callback.Run(static_cast<int>(ServiceError::ERROR_WAIT)); | 49 callback.Run(static_cast<int>(ServiceError::ERROR_WAIT)); |
| 50 } | 50 } |
| 51 | 51 |
| 52 NotifyObservers(UpdateClient::Observer::Events::COMPONENT_WAIT, | 52 NotifyObservers(UpdateClient::Observer::Events::COMPONENT_WAIT, |
| 53 update_context_->queue.front()); | 53 update_context_->queue.front()); |
| 54 } | 54 } |
| 55 | 55 |
| 56 void ActionWait::WaitComplete() { | 56 void ActionWait::WaitComplete() { |
| 57 DCHECK(thread_checker_.CalledOnValidThread()); | 57 DCHECK(thread_checker_.CalledOnValidThread()); |
| 58 UpdateCrx(); | 58 UpdateCrx(); |
| 59 } | 59 } |
| 60 | 60 |
| 61 } // namespace update_client | 61 } // namespace update_client |
| OLD | NEW |