Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: components/update_client/update_engine.cc

Issue 1861383004: Add module for counting date-last-roll-call and persisting those counts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Another test fix. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/update_client/update_engine.h ('k') | components/update_client/update_response.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/prefs/pref_service.h"
13 #include "components/update_client/action_update_check.h" 14 #include "components/update_client/action_update_check.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"
17 #include "components/update_client/persisted_data.h"
16 #include "components/update_client/update_checker.h" 18 #include "components/update_client/update_checker.h"
17 19
18 namespace update_client { 20 namespace update_client {
19 21
20 UpdateContext::UpdateContext( 22 UpdateContext::UpdateContext(
21 const scoped_refptr<Configurator>& config, 23 const scoped_refptr<Configurator>& config,
22 bool is_foreground, 24 bool is_foreground,
23 const std::vector<std::string>& ids, 25 const std::vector<std::string>& ids,
24 const UpdateClient::CrxDataCallback& crx_data_callback, 26 const UpdateClient::CrxDataCallback& crx_data_callback,
25 const UpdateEngine::NotifyObserversCallback& notify_observers_callback, 27 const UpdateEngine::NotifyObserversCallback& notify_observers_callback,
(...skipping 21 matching lines...) Expand all
47 UpdateEngine::UpdateEngine( 49 UpdateEngine::UpdateEngine(
48 const scoped_refptr<Configurator>& config, 50 const scoped_refptr<Configurator>& config,
49 UpdateChecker::Factory update_checker_factory, 51 UpdateChecker::Factory update_checker_factory,
50 CrxDownloader::Factory crx_downloader_factory, 52 CrxDownloader::Factory crx_downloader_factory,
51 PingManager* ping_manager, 53 PingManager* ping_manager,
52 const NotifyObserversCallback& notify_observers_callback) 54 const NotifyObserversCallback& notify_observers_callback)
53 : config_(config), 55 : config_(config),
54 update_checker_factory_(update_checker_factory), 56 update_checker_factory_(update_checker_factory),
55 crx_downloader_factory_(crx_downloader_factory), 57 crx_downloader_factory_(crx_downloader_factory),
56 ping_manager_(ping_manager), 58 ping_manager_(ping_manager),
57 notify_observers_callback_(notify_observers_callback) { 59 metadata_(new PersistedData(config->GetPrefService())),
58 } 60 notify_observers_callback_(notify_observers_callback) {}
59 61
60 UpdateEngine::~UpdateEngine() { 62 UpdateEngine::~UpdateEngine() {
61 DCHECK(thread_checker_.CalledOnValidThread()); 63 DCHECK(thread_checker_.CalledOnValidThread());
62 } 64 }
63 65
64 bool UpdateEngine::GetUpdateState(const std::string& id, 66 bool UpdateEngine::GetUpdateState(const std::string& id,
65 CrxUpdateItem* update_item) { 67 CrxUpdateItem* update_item) {
66 DCHECK(thread_checker_.CalledOnValidThread()); 68 DCHECK(thread_checker_.CalledOnValidThread());
67 for (const auto& context : update_contexts_) { 69 for (const auto& context : update_contexts_) {
68 const auto& update_items = context->update_items; 70 const auto& update_items = context->update_items;
(...skipping 22 matching lines...) Expand all
91 return; 93 return;
92 } 94 }
93 95
94 scoped_ptr<UpdateContext> update_context(new UpdateContext( 96 scoped_ptr<UpdateContext> update_context(new UpdateContext(
95 config_, is_foreground, ids, crx_data_callback, 97 config_, is_foreground, ids, crx_data_callback,
96 notify_observers_callback_, callback, update_checker_factory_, 98 notify_observers_callback_, callback, update_checker_factory_,
97 crx_downloader_factory_, ping_manager_)); 99 crx_downloader_factory_, ping_manager_));
98 100
99 CrxUpdateItem update_item; 101 CrxUpdateItem update_item;
100 scoped_ptr<ActionUpdateCheck> update_check_action(new ActionUpdateCheck( 102 scoped_ptr<ActionUpdateCheck> update_check_action(new ActionUpdateCheck(
101 (*update_context->update_checker_factory)(config_), 103 (*update_context->update_checker_factory)(config_, *metadata_),
102 config_->GetBrowserVersion(), config_->ExtraRequestParams())); 104 config_->GetBrowserVersion(), config_->ExtraRequestParams()));
103 105
104 update_context->current_action.reset(update_check_action.release()); 106 update_context->current_action.reset(update_check_action.release());
105 update_contexts_.insert(update_context.get()); 107 update_contexts_.insert(update_context.get());
106 108
107 update_context->current_action->Run( 109 update_context->current_action->Run(
108 update_context.get(), 110 update_context.get(),
109 base::Bind(&UpdateEngine::UpdateComplete, base::Unretained(this), 111 base::Bind(&UpdateEngine::UpdateComplete, base::Unretained(this),
110 update_context.get())); 112 update_context.get()));
111 113
(...skipping 30 matching lines...) Expand all
142 144
143 const auto now(base::Time::Now()); 145 const auto now(base::Time::Now());
144 146
145 // Throttle the calls in the interval (t - 1 day, t) to limit the effect of 147 // Throttle the calls in the interval (t - 1 day, t) to limit the effect of
146 // unset clocks or clock drift. 148 // unset clocks or clock drift.
147 return throttle_updates_until_ - base::TimeDelta::FromDays(1) < now && 149 return throttle_updates_until_ - base::TimeDelta::FromDays(1) < now &&
148 now < throttle_updates_until_; 150 now < throttle_updates_until_;
149 } 151 }
150 152
151 } // namespace update_client 153 } // namespace update_client
OLDNEW
« no previous file with comments | « components/update_client/update_engine.h ('k') | components/update_client/update_response.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698