| 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.h" | 5 #include "components/update_client/action.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 NotifyObservers(Events::COMPONENT_UPDATED, id); | 82 NotifyObservers(Events::COMPONENT_UPDATED, id); |
| 83 break; | 83 break; |
| 84 case CrxUpdateItem::State::kUpToDate: | 84 case CrxUpdateItem::State::kUpToDate: |
| 85 case CrxUpdateItem::State::kNoUpdate: | 85 case CrxUpdateItem::State::kNoUpdate: |
| 86 NotifyObservers(Events::COMPONENT_NOT_UPDATED, id); | 86 NotifyObservers(Events::COMPONENT_NOT_UPDATED, id); |
| 87 break; | 87 break; |
| 88 case CrxUpdateItem::State::kNew: | 88 case CrxUpdateItem::State::kNew: |
| 89 case CrxUpdateItem::State::kDownloading: | 89 case CrxUpdateItem::State::kDownloading: |
| 90 case CrxUpdateItem::State::kDownloadingDiff: | 90 case CrxUpdateItem::State::kDownloadingDiff: |
| 91 case CrxUpdateItem::State::kDownloaded: | 91 case CrxUpdateItem::State::kDownloaded: |
| 92 case CrxUpdateItem::State::kUninstalled: |
| 92 case CrxUpdateItem::State::kLastStatus: | 93 case CrxUpdateItem::State::kLastStatus: |
| 93 // No notification for these states. | 94 // No notification for these states. |
| 94 break; | 95 break; |
| 95 } | 96 } |
| 96 } | 97 } |
| 97 | 98 |
| 98 size_t ActionImpl::ChangeAllItemsState(CrxUpdateItem::State from, | 99 size_t ActionImpl::ChangeAllItemsState(CrxUpdateItem::State from, |
| 99 CrxUpdateItem::State to) { | 100 CrxUpdateItem::State to) { |
| 100 DCHECK(thread_checker_.CalledOnValidThread()); | 101 DCHECK(thread_checker_.CalledOnValidThread()); |
| 101 size_t count = 0; | 102 size_t count = 0; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 128 : ActionUpdateFull::Create()); | 129 : ActionUpdateFull::Create()); |
| 129 | 130 |
| 130 base::ThreadTaskRunnerHandle::Get()->PostTask( | 131 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 131 FROM_HERE, base::Bind(&Action::Run, base::Unretained(update_action.get()), | 132 FROM_HERE, base::Bind(&Action::Run, base::Unretained(update_action.get()), |
| 132 update_context_, callback_)); | 133 update_context_, callback_)); |
| 133 | 134 |
| 134 update_context_->current_action.reset(update_action.release()); | 135 update_context_->current_action.reset(update_action.release()); |
| 135 } | 136 } |
| 136 | 137 |
| 137 void ActionImpl::UpdateCrxComplete(CrxUpdateItem* item) { | 138 void ActionImpl::UpdateCrxComplete(CrxUpdateItem* item) { |
| 138 update_context_->ping_manager->OnUpdateComplete(item); | 139 update_context_->ping_manager->SendPing(item); |
| 139 | 140 |
| 140 update_context_->queue.pop(); | 141 update_context_->queue.pop(); |
| 141 | 142 |
| 142 if (update_context_->queue.empty()) { | 143 if (update_context_->queue.empty()) { |
| 143 UpdateComplete(0); | 144 UpdateComplete(0); |
| 144 } else { | 145 } else { |
| 145 // TODO(sorin): the value of timing interval between CRX updates might have | 146 // TODO(sorin): the value of timing interval between CRX updates might have |
| 146 // to be injected at the call site of update_client::UpdateClient::Update. | 147 // to be injected at the call site of update_client::UpdateClient::Update. |
| 147 const int wait_sec = update_context_->config->UpdateDelay(); | 148 const int wait_sec = update_context_->config->UpdateDelay(); |
| 148 | 149 |
| 149 scoped_ptr<ActionWait> action_wait( | 150 scoped_ptr<ActionWait> action_wait( |
| 150 new ActionWait(base::TimeDelta::FromSeconds(wait_sec))); | 151 new ActionWait(base::TimeDelta::FromSeconds(wait_sec))); |
| 151 | 152 |
| 152 base::ThreadTaskRunnerHandle::Get()->PostTask( | 153 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 153 FROM_HERE, base::Bind(&Action::Run, base::Unretained(action_wait.get()), | 154 FROM_HERE, base::Bind(&Action::Run, base::Unretained(action_wait.get()), |
| 154 update_context_, callback_)); | 155 update_context_, callback_)); |
| 155 | 156 |
| 156 update_context_->current_action.reset(action_wait.release()); | 157 update_context_->current_action.reset(action_wait.release()); |
| 157 } | 158 } |
| 158 } | 159 } |
| 159 | 160 |
| 160 void ActionImpl::UpdateComplete(int error) { | 161 void ActionImpl::UpdateComplete(int error) { |
| 161 DCHECK(thread_checker_.CalledOnValidThread()); | 162 DCHECK(thread_checker_.CalledOnValidThread()); |
| 162 | 163 |
| 163 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, | 164 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, |
| 164 base::Bind(callback_, error)); | 165 base::Bind(callback_, error)); |
| 165 } | 166 } |
| 166 | 167 |
| 167 } // namespace update_client | 168 } // namespace update_client |
| OLD | NEW |