| 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/update_engine.h" | 5 #include "components/update_client/update_engine.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/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 const CompletionCallback& callback) { | 84 const CompletionCallback& callback) { |
| 85 DCHECK(thread_checker_.CalledOnValidThread()); | 85 DCHECK(thread_checker_.CalledOnValidThread()); |
| 86 | 86 |
| 87 scoped_ptr<UpdateContext> update_context(new UpdateContext( | 87 scoped_ptr<UpdateContext> update_context(new UpdateContext( |
| 88 config_, is_foreground, ids, crx_data_callback, | 88 config_, is_foreground, ids, crx_data_callback, |
| 89 notify_observers_callback_, callback, update_checker_factory_, | 89 notify_observers_callback_, callback, update_checker_factory_, |
| 90 crx_downloader_factory_, ping_manager_)); | 90 crx_downloader_factory_, ping_manager_)); |
| 91 | 91 |
| 92 CrxUpdateItem update_item; | 92 CrxUpdateItem update_item; |
| 93 scoped_ptr<ActionUpdateCheck> update_check_action(new ActionUpdateCheck( | 93 scoped_ptr<ActionUpdateCheck> update_check_action(new ActionUpdateCheck( |
| 94 (*update_context->update_checker_factory)(*config_).Pass(), | 94 (*update_context->update_checker_factory)(*config_), |
| 95 config_->GetBrowserVersion(), config_->ExtraRequestParams())); | 95 config_->GetBrowserVersion(), config_->ExtraRequestParams())); |
| 96 | 96 |
| 97 update_context->current_action.reset(update_check_action.release()); | 97 update_context->current_action.reset(update_check_action.release()); |
| 98 update_contexts_.insert(update_context.get()); | 98 update_contexts_.insert(update_context.get()); |
| 99 | 99 |
| 100 update_context->current_action->Run( | 100 update_context->current_action->Run( |
| 101 update_context.get(), | 101 update_context.get(), |
| 102 base::Bind(&UpdateEngine::UpdateComplete, base::Unretained(this), | 102 base::Bind(&UpdateEngine::UpdateComplete, base::Unretained(this), |
| 103 update_context.get())); | 103 update_context.get())); |
| 104 | 104 |
| 105 ignore_result(update_context.release()); | 105 ignore_result(update_context.release()); |
| 106 } | 106 } |
| 107 | 107 |
| 108 void UpdateEngine::UpdateComplete(UpdateContext* update_context, int error) { | 108 void UpdateEngine::UpdateComplete(UpdateContext* update_context, int error) { |
| 109 DCHECK(thread_checker_.CalledOnValidThread()); | 109 DCHECK(thread_checker_.CalledOnValidThread()); |
| 110 DCHECK(update_contexts_.find(update_context) != update_contexts_.end()); | 110 DCHECK(update_contexts_.find(update_context) != update_contexts_.end()); |
| 111 | 111 |
| 112 auto callback = update_context->callback; | 112 auto callback = update_context->callback; |
| 113 | 113 |
| 114 update_contexts_.erase(update_context); | 114 update_contexts_.erase(update_context); |
| 115 delete update_context; | 115 delete update_context; |
| 116 | 116 |
| 117 callback.Run(error); | 117 callback.Run(error); |
| 118 } | 118 } |
| 119 | 119 |
| 120 } // namespace update_client | 120 } // namespace update_client |
| OLD | NEW |