| 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" |
| 11 #include "base/thread_task_runner_handle.h" | 11 #include "base/thread_task_runner_handle.h" |
| 12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 13 #include "components/update_client/action_update_check.h" | 13 #include "components/update_client/action_update_check.h" |
| 14 #include "components/update_client/component_metadata.h" |
| 14 #include "components/update_client/configurator.h" | 15 #include "components/update_client/configurator.h" |
| 15 #include "components/update_client/crx_update_item.h" | 16 #include "components/update_client/crx_update_item.h" |
| 16 #include "components/update_client/update_checker.h" | 17 #include "components/update_client/update_checker.h" |
| 17 | 18 |
| 18 namespace update_client { | 19 namespace update_client { |
| 19 | 20 |
| 20 UpdateContext::UpdateContext( | 21 UpdateContext::UpdateContext( |
| 21 const scoped_refptr<Configurator>& config, | 22 const scoped_refptr<Configurator>& config, |
| 22 bool is_foreground, | 23 bool is_foreground, |
| 23 const std::vector<std::string>& ids, | 24 const std::vector<std::string>& ids, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 47 UpdateEngine::UpdateEngine( | 48 UpdateEngine::UpdateEngine( |
| 48 const scoped_refptr<Configurator>& config, | 49 const scoped_refptr<Configurator>& config, |
| 49 UpdateChecker::Factory update_checker_factory, | 50 UpdateChecker::Factory update_checker_factory, |
| 50 CrxDownloader::Factory crx_downloader_factory, | 51 CrxDownloader::Factory crx_downloader_factory, |
| 51 PingManager* ping_manager, | 52 PingManager* ping_manager, |
| 52 const NotifyObserversCallback& notify_observers_callback) | 53 const NotifyObserversCallback& notify_observers_callback) |
| 53 : config_(config), | 54 : config_(config), |
| 54 update_checker_factory_(update_checker_factory), | 55 update_checker_factory_(update_checker_factory), |
| 55 crx_downloader_factory_(crx_downloader_factory), | 56 crx_downloader_factory_(crx_downloader_factory), |
| 56 ping_manager_(ping_manager), | 57 ping_manager_(ping_manager), |
| 58 metadata_( |
| 59 new ComponentMetadata(config->GetMetadataPath(), |
| 60 config->GetSequencedTaskRunner())), |
| 57 notify_observers_callback_(notify_observers_callback) { | 61 notify_observers_callback_(notify_observers_callback) { |
| 58 } | 62 } |
| 59 | 63 |
| 60 UpdateEngine::~UpdateEngine() { | 64 UpdateEngine::~UpdateEngine() { |
| 61 DCHECK(thread_checker_.CalledOnValidThread()); | 65 DCHECK(thread_checker_.CalledOnValidThread()); |
| 62 } | 66 } |
| 63 | 67 |
| 64 bool UpdateEngine::GetUpdateState(const std::string& id, | 68 bool UpdateEngine::GetUpdateState(const std::string& id, |
| 65 CrxUpdateItem* update_item) { | 69 CrxUpdateItem* update_item) { |
| 66 DCHECK(thread_checker_.CalledOnValidThread()); | 70 DCHECK(thread_checker_.CalledOnValidThread()); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 91 return; | 95 return; |
| 92 } | 96 } |
| 93 | 97 |
| 94 scoped_ptr<UpdateContext> update_context(new UpdateContext( | 98 scoped_ptr<UpdateContext> update_context(new UpdateContext( |
| 95 config_, is_foreground, ids, crx_data_callback, | 99 config_, is_foreground, ids, crx_data_callback, |
| 96 notify_observers_callback_, callback, update_checker_factory_, | 100 notify_observers_callback_, callback, update_checker_factory_, |
| 97 crx_downloader_factory_, ping_manager_)); | 101 crx_downloader_factory_, ping_manager_)); |
| 98 | 102 |
| 99 CrxUpdateItem update_item; | 103 CrxUpdateItem update_item; |
| 100 scoped_ptr<ActionUpdateCheck> update_check_action(new ActionUpdateCheck( | 104 scoped_ptr<ActionUpdateCheck> update_check_action(new ActionUpdateCheck( |
| 101 (*update_context->update_checker_factory)(config_), | 105 (*update_context->update_checker_factory)(config_, metadata_), |
| 102 config_->GetBrowserVersion(), config_->ExtraRequestParams())); | 106 config_->GetBrowserVersion(), config_->ExtraRequestParams())); |
| 103 | 107 |
| 104 update_context->current_action.reset(update_check_action.release()); | 108 update_context->current_action.reset(update_check_action.release()); |
| 105 update_contexts_.insert(update_context.get()); | 109 update_contexts_.insert(update_context.get()); |
| 106 | 110 |
| 107 update_context->current_action->Run( | 111 update_context->current_action->Run( |
| 108 update_context.get(), | 112 update_context.get(), |
| 109 base::Bind(&UpdateEngine::UpdateComplete, base::Unretained(this), | 113 base::Bind(&UpdateEngine::UpdateComplete, base::Unretained(this), |
| 110 update_context.get())); | 114 update_context.get())); |
| 111 | 115 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 142 | 146 |
| 143 const auto now(base::Time::Now()); | 147 const auto now(base::Time::Now()); |
| 144 | 148 |
| 145 // Throttle the calls in the interval (t - 1 day, t) to limit the effect of | 149 // Throttle the calls in the interval (t - 1 day, t) to limit the effect of |
| 146 // unset clocks or clock drift. | 150 // unset clocks or clock drift. |
| 147 return throttle_updates_until_ - base::TimeDelta::FromDays(1) < now && | 151 return throttle_updates_until_ - base::TimeDelta::FromDays(1) < now && |
| 148 now < throttle_updates_until_; | 152 now < throttle_updates_until_; |
| 149 } | 153 } |
| 150 | 154 |
| 151 } // namespace update_client | 155 } // namespace update_client |
| OLD | NEW |