blob: 98bd8e5a7714ac674c0fd0d37f88fe9f6dfbb1e7 [file] [log] [blame]
harkness883658b2016-07-18 11:37:531// Copyright 2016 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "chrome/browser/budget_service/budget_database.h"
6
fdorayba121422016-12-23 19:51:487#include "base/memory/ptr_util.h"
harkness6f6b41432016-09-08 09:17:288#include "base/metrics/histogram_macros.h"
fdorayad78154a2017-04-03 17:11:099#include "base/task_scheduler/post_task.h"
harknessf8c93432016-08-08 15:41:5910#include "base/time/clock.h"
11#include "base/time/default_clock.h"
harkness883658b2016-07-18 11:37:5312#include "chrome/browser/budget_service/budget.pb.h"
harknessc3fb0452016-09-02 14:08:3713#include "chrome/browser/engagement/site_engagement_score.h"
14#include "chrome/browser/engagement/site_engagement_service.h"
15#include "chrome/browser/profiles/profile.h"
harkness883658b2016-07-18 11:37:5316#include "components/leveldb_proto/proto_database_impl.h"
17#include "content/public/browser/browser_thread.h"
18#include "url/gurl.h"
harkness03be8a1d2016-09-09 16:01:1219#include "url/origin.h"
harkness883658b2016-07-18 11:37:5320
harkness804b612a62016-07-27 12:53:3121using content::BrowserThread;
22
harkness883658b2016-07-18 11:37:5323namespace {
24
25// UMA are logged for the database with this string as part of the name.
harknessbea56c22016-08-16 07:23:0026// They will be LevelDB.*.BudgetManager. Changes here should be synchronized
27// with histograms.xml.
28const char kDatabaseUMAName[] = "BudgetManager";
harkness883658b2016-07-18 11:37:5329
harknessf8c93432016-08-08 15:41:5930// The default amount of time during which a budget will be valid.
harknessccdc3f3a2017-01-16 12:42:1731constexpr int kBudgetDurationInDays = 4;
32
33// The amount of budget that a maximally engaged site should receive per hour.
34// For context, silent push messages cost 2 each, so this allows 6 silent push
35// messages a day for a fully engaged site. See budget_manager.cc for costs of
36// various actions.
37constexpr double kMaximumHourlyBudget = 12.0 / 24.0;
harknessf8c93432016-08-08 15:41:5938
harkness883658b2016-07-18 11:37:5339} // namespace
40
harknesse0e26092016-08-24 06:29:3241BudgetDatabase::BudgetInfo::BudgetInfo() {}
42
43BudgetDatabase::BudgetInfo::BudgetInfo(const BudgetInfo&& other)
44 : last_engagement_award(other.last_engagement_award) {
45 chunks = std::move(other.chunks);
46}
47
48BudgetDatabase::BudgetInfo::~BudgetInfo() {}
49
fdorayad78154a2017-04-03 17:11:0950BudgetDatabase::BudgetDatabase(Profile* profile,
51 const base::FilePath& database_dir)
harknessc3fb0452016-09-02 14:08:3752 : profile_(profile),
53 db_(new leveldb_proto::ProtoDatabaseImpl<budget_service::Budget>(
fdorayad78154a2017-04-03 17:11:0954 base::CreateSequencedTaskRunnerWithTraits(
fdoray4ad14932017-05-03 21:21:1155 {base::MayBlock(), base::TaskPriority::BACKGROUND,
56 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN}))),
harknessf8c93432016-08-08 15:41:5957 clock_(base::WrapUnique(new base::DefaultClock)),
harkness883658b2016-07-18 11:37:5358 weak_ptr_factory_(this) {
59 db_->Init(kDatabaseUMAName, database_dir,
tzika8668f8c2017-06-26 08:58:0560 base::BindOnce(&BudgetDatabase::OnDatabaseInit,
61 weak_ptr_factory_.GetWeakPtr()));
harkness883658b2016-07-18 11:37:5362}
63
64BudgetDatabase::~BudgetDatabase() {}
65
harkness03be8a1d2016-09-09 16:01:1266void BudgetDatabase::GetBudgetDetails(const url::Origin& origin,
tzikcf7bcd652017-06-15 04:19:3067 GetBudgetCallback callback) {
tzika8668f8c2017-06-26 08:58:0568 SyncCache(origin, base::BindOnce(&BudgetDatabase::GetBudgetAfterSync,
69 weak_ptr_factory_.GetWeakPtr(), origin,
70 base::Passed(&callback)));
harknesse0e26092016-08-24 06:29:3271}
72
harkness03be8a1d2016-09-09 16:01:1273void BudgetDatabase::SpendBudget(const url::Origin& origin,
harknesse0e26092016-08-24 06:29:3274 double amount,
tzikcf7bcd652017-06-15 04:19:3075 SpendBudgetCallback callback) {
tzika8668f8c2017-06-26 08:58:0576 SyncCache(origin, base::BindOnce(&BudgetDatabase::SpendBudgetAfterSync,
77 weak_ptr_factory_.GetWeakPtr(), origin,
78 amount, base::Passed(&callback)));
harknessc3fb0452016-09-02 14:08:3779}
harknesse0e26092016-08-24 06:29:3280
harknessc3fb0452016-09-02 14:08:3781void BudgetDatabase::SetClockForTesting(std::unique_ptr<base::Clock> clock) {
82 clock_ = std::move(clock);
harknesse0e26092016-08-24 06:29:3283}
84
harkness804b612a62016-07-27 12:53:3185void BudgetDatabase::OnDatabaseInit(bool success) {
86 // TODO(harkness): Consider caching the budget database now?
87}
88
harkness03be8a1d2016-09-09 16:01:1289bool BudgetDatabase::IsCached(const url::Origin& origin) const {
90 return budget_map_.find(origin) != budget_map_.end();
harkness5186e6d822016-08-09 16:54:1491}
92
harkness03be8a1d2016-09-09 16:01:1293double BudgetDatabase::GetBudget(const url::Origin& origin) const {
harkness6f6b41432016-09-08 09:17:2894 double total = 0;
harkness03be8a1d2016-09-09 16:01:1295 auto iter = budget_map_.find(origin);
harkness6f6b41432016-09-08 09:17:2896 if (iter == budget_map_.end())
97 return total;
98
99 const BudgetInfo& info = iter->second;
100 for (const BudgetChunk& chunk : info.chunks)
101 total += chunk.amount;
102 return total;
103}
104
harkness804b612a62016-07-27 12:53:31105void BudgetDatabase::AddToCache(
harkness03be8a1d2016-09-09 16:01:12106 const url::Origin& origin,
tzikcf7bcd652017-06-15 04:19:30107 CacheCallback callback,
harkness804b612a62016-07-27 12:53:31108 bool success,
109 std::unique_ptr<budget_service::Budget> budget_proto) {
harkness0f9724a2016-09-13 14:43:12110 // If the database read failed or there's nothing to add, just return.
harknessf8c93432016-08-08 15:41:59111 if (!success || !budget_proto) {
tzikcf7bcd652017-06-15 04:19:30112 std::move(callback).Run(success);
harkness804b612a62016-07-27 12:53:31113 return;
114 }
115
harknessc3fb0452016-09-02 14:08:37116 // If there were two simultaneous loads, don't overwrite the cache value,
117 // which might have been updated after the previous load.
118 if (IsCached(origin)) {
tzikcf7bcd652017-06-15 04:19:30119 std::move(callback).Run(success);
harknessc3fb0452016-09-02 14:08:37120 return;
121 }
122
harkness804b612a62016-07-27 12:53:31123 // Add the data to the cache, converting from the proto format to an STL
124 // format which is better for removing things from the list.
harkness03be8a1d2016-09-09 16:01:12125 BudgetInfo& info = budget_map_[origin];
harknessbf8b3852016-08-10 18:42:02126 for (const auto& chunk : budget_proto->budget()) {
harknesse0e26092016-08-24 06:29:32127 info.chunks.emplace_back(chunk.amount(),
128 base::Time::FromInternalValue(chunk.expiration()));
harknessbf8b3852016-08-10 18:42:02129 }
harkness804b612a62016-07-27 12:53:31130
harknesse0e26092016-08-24 06:29:32131 info.last_engagement_award =
132 base::Time::FromInternalValue(budget_proto->engagement_last_updated());
harkness804b612a62016-07-27 12:53:31133
tzikcf7bcd652017-06-15 04:19:30134 std::move(callback).Run(success);
harkness804b612a62016-07-27 12:53:31135}
136
harkness03be8a1d2016-09-09 16:01:12137void BudgetDatabase::GetBudgetAfterSync(const url::Origin& origin,
tzikcf7bcd652017-06-15 04:19:30138 GetBudgetCallback callback,
harkness6f6b41432016-09-08 09:17:28139 bool success) {
yzshen6b5ad7f22016-11-22 21:38:21140 std::vector<blink::mojom::BudgetStatePtr> predictions;
harkness6f6b41432016-09-08 09:17:28141
harkness804b612a62016-07-27 12:53:31142 // If the database wasn't able to read the information, return the
harkness6f6b41432016-09-08 09:17:28143 // failure and an empty predictions array.
harkness804b612a62016-07-27 12:53:31144 if (!success) {
tzikcf7bcd652017-06-15 04:19:30145 std::move(callback).Run(
146 blink::mojom::BudgetServiceErrorType::DATABASE_ERROR,
147 std::move(predictions));
harkness804b612a62016-07-27 12:53:31148 return;
149 }
150
harkness5186e6d822016-08-09 16:54:14151 // Now, build up the BudgetExpection. This is different from the format
harkness804b612a62016-07-27 12:53:31152 // in which the cache stores the data. The cache stores chunks of budget and
harkness6f6b41432016-09-08 09:17:28153 // when that budget expires. The mojo array describes a set of times
harkness804b612a62016-07-27 12:53:31154 // and the budget at those times.
harkness6f6b41432016-09-08 09:17:28155 double total = GetBudget(origin);
harkness804b612a62016-07-27 12:53:31156
harkness5186e6d822016-08-09 16:54:14157 // Always add one entry at the front of the list for the total budget now.
harkness6f6b41432016-09-08 09:17:28158 blink::mojom::BudgetStatePtr prediction(blink::mojom::BudgetState::New());
159 prediction->budget_at = total;
petera1644922017-06-06 01:33:56160 prediction->time = clock_->Now().ToJsTime();
harkness6f6b41432016-09-08 09:17:28161 predictions.push_back(std::move(prediction));
harkness804b612a62016-07-27 12:53:31162
harkness6f6b41432016-09-08 09:17:28163 // Starting with the soonest expiring chunks, add entries for the
164 // expiration times going forward.
harkness03be8a1d2016-09-09 16:01:12165 const BudgetChunks& chunks = budget_map_[origin].chunks;
harkness6f6b41432016-09-08 09:17:28166 for (const auto& chunk : chunks) {
167 blink::mojom::BudgetStatePtr prediction(blink::mojom::BudgetState::New());
168 total -= chunk.amount;
169 prediction->budget_at = total;
petera1644922017-06-06 01:33:56170 prediction->time = chunk.expiration.ToJsTime();
harkness6f6b41432016-09-08 09:17:28171 predictions.push_back(std::move(prediction));
172 }
173
tzikcf7bcd652017-06-15 04:19:30174 std::move(callback).Run(blink::mojom::BudgetServiceErrorType::NONE,
175 std::move(predictions));
harkness804b612a62016-07-27 12:53:31176}
harknessf8c93432016-08-08 15:41:59177
harkness03be8a1d2016-09-09 16:01:12178void BudgetDatabase::SpendBudgetAfterSync(const url::Origin& origin,
harknessc3fb0452016-09-02 14:08:37179 double amount,
tzikcf7bcd652017-06-15 04:19:30180 SpendBudgetCallback callback,
harknessc3fb0452016-09-02 14:08:37181 bool success) {
182 if (!success) {
tzikcf7bcd652017-06-15 04:19:30183 std::move(callback).Run(
184 blink::mojom::BudgetServiceErrorType::DATABASE_ERROR,
185 false /* success */);
harknessc3fb0452016-09-02 14:08:37186 return;
187 }
188
harkness6f6b41432016-09-08 09:17:28189 // Get the current SES score, to generate UMA.
peter91882282017-05-25 17:57:33190 double score = GetSiteEngagementScoreForOrigin(origin);
harkness6f6b41432016-09-08 09:17:28191
harknessc3fb0452016-09-02 14:08:37192 // Walk the list of budget chunks to see if the origin has enough budget.
193 double total = 0;
harkness03be8a1d2016-09-09 16:01:12194 BudgetInfo& info = budget_map_[origin];
harknessc3fb0452016-09-02 14:08:37195 for (const BudgetChunk& chunk : info.chunks)
196 total += chunk.amount;
197
198 if (total < amount) {
harkness6f6b41432016-09-08 09:17:28199 UMA_HISTOGRAM_COUNTS_100("PushMessaging.SESForNoBudgetOrigin", score);
tzikcf7bcd652017-06-15 04:19:30200 std::move(callback).Run(blink::mojom::BudgetServiceErrorType::NONE,
201 false /* success */);
harknessc3fb0452016-09-02 14:08:37202 return;
harkness6f6b41432016-09-08 09:17:28203 } else if (total < amount * 2) {
204 UMA_HISTOGRAM_COUNTS_100("PushMessaging.SESForLowBudgetOrigin", score);
harknessc3fb0452016-09-02 14:08:37205 }
206
207 // Walk the chunks and remove enough budget to cover the needed amount.
208 double bill = amount;
209 for (auto iter = info.chunks.begin(); iter != info.chunks.end();) {
210 if (iter->amount > bill) {
211 iter->amount -= bill;
212 bill = 0;
213 break;
214 }
215 bill -= iter->amount;
216 iter = info.chunks.erase(iter);
217 }
218
219 // There should have been enough budget to cover the entire bill.
220 DCHECK_EQ(0, bill);
221
222 // Now that the cache is updated, write the data to the database.
harkness0f9724a2016-09-13 14:43:12223 WriteCachedValuesToDatabase(
tzikcf7bcd652017-06-15 04:19:30224 origin,
225 base::BindOnce(&BudgetDatabase::SpendBudgetAfterWrite,
226 weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
harkness0f9724a2016-09-13 14:43:12227}
228
229// This converts the bool value which is returned from the database to a Mojo
230// error type.
tzikcf7bcd652017-06-15 04:19:30231void BudgetDatabase::SpendBudgetAfterWrite(SpendBudgetCallback callback,
harkness0f9724a2016-09-13 14:43:12232 bool write_successful) {
harknessc3fb0452016-09-02 14:08:37233 // TODO(harkness): If the database write fails, the cache will be out of sync
234 // with the database. Consider ways to mitigate this.
harkness0f9724a2016-09-13 14:43:12235 if (!write_successful) {
tzikcf7bcd652017-06-15 04:19:30236 std::move(callback).Run(
237 blink::mojom::BudgetServiceErrorType::DATABASE_ERROR,
238 false /* success */);
harkness0f9724a2016-09-13 14:43:12239 return;
240 }
tzikcf7bcd652017-06-15 04:19:30241 std::move(callback).Run(blink::mojom::BudgetServiceErrorType::NONE,
242 true /* success */);
harknessf8c93432016-08-08 15:41:59243}
harkness5186e6d822016-08-09 16:54:14244
tzikcf7bcd652017-06-15 04:19:30245void BudgetDatabase::WriteCachedValuesToDatabase(const url::Origin& origin,
246 StoreBudgetCallback callback) {
harkness5186e6d822016-08-09 16:54:14247 // Create the data structures that are passed to the ProtoDatabase.
248 std::unique_ptr<
249 leveldb_proto::ProtoDatabase<budget_service::Budget>::KeyEntryVector>
250 entries(new leveldb_proto::ProtoDatabase<
251 budget_service::Budget>::KeyEntryVector());
252 std::unique_ptr<std::vector<std::string>> keys_to_remove(
253 new std::vector<std::string>());
254
255 // Each operation can either update the existing budget or remove the origin's
256 // budget information.
257 if (IsCached(origin)) {
258 // Build the Budget proto object.
259 budget_service::Budget budget;
harkness03be8a1d2016-09-09 16:01:12260 const BudgetInfo& info = budget_map_[origin];
harknesse0e26092016-08-24 06:29:32261 for (const auto& chunk : info.chunks) {
harkness5186e6d822016-08-09 16:54:14262 budget_service::BudgetChunk* budget_chunk = budget.add_budget();
harknessbf8b3852016-08-10 18:42:02263 budget_chunk->set_amount(chunk.amount);
264 budget_chunk->set_expiration(chunk.expiration.ToInternalValue());
harkness5186e6d822016-08-09 16:54:14265 }
harknesse0e26092016-08-24 06:29:32266 budget.set_engagement_last_updated(
267 info.last_engagement_award.ToInternalValue());
harkness03be8a1d2016-09-09 16:01:12268 entries->push_back(std::make_pair(origin.Serialize(), budget));
harkness5186e6d822016-08-09 16:54:14269 } else {
270 // If the origin doesn't exist in the cache, this is a remove operation.
harkness03be8a1d2016-09-09 16:01:12271 keys_to_remove->push_back(origin.Serialize());
harkness5186e6d822016-08-09 16:54:14272 }
273
274 // Send the updates to the database.
tzikcf7bcd652017-06-15 04:19:30275 db_->UpdateEntries(std::move(entries), std::move(keys_to_remove),
276 std::move(callback));
harkness5186e6d822016-08-09 16:54:14277}
278
harkness03be8a1d2016-09-09 16:01:12279void BudgetDatabase::SyncCache(const url::Origin& origin,
tzikcf7bcd652017-06-15 04:19:30280 CacheCallback callback) {
harknessc3fb0452016-09-02 14:08:37281 // If the origin isn't already cached, add it to the cache.
282 if (!IsCached(origin)) {
tzikcf7bcd652017-06-15 04:19:30283 CacheCallback add_callback = base::BindOnce(
284 &BudgetDatabase::SyncLoadedCache, weak_ptr_factory_.GetWeakPtr(),
285 origin, std::move(callback));
tzika8668f8c2017-06-26 08:58:05286 db_->GetEntry(origin.Serialize(),
287 base::BindOnce(&BudgetDatabase::AddToCache,
288 weak_ptr_factory_.GetWeakPtr(), origin,
289 base::Passed(&add_callback)));
harkness5186e6d822016-08-09 16:54:14290 return;
harknessc3fb0452016-09-02 14:08:37291 }
tzikcf7bcd652017-06-15 04:19:30292 SyncLoadedCache(origin, std::move(callback), true /* success */);
harknessc3fb0452016-09-02 14:08:37293}
294
harkness03be8a1d2016-09-09 16:01:12295void BudgetDatabase::SyncLoadedCache(const url::Origin& origin,
tzikcf7bcd652017-06-15 04:19:30296 CacheCallback callback,
harknessc3fb0452016-09-02 14:08:37297 bool success) {
298 if (!success) {
tzikcf7bcd652017-06-15 04:19:30299 std::move(callback).Run(false /* success */);
harknessc3fb0452016-09-02 14:08:37300 return;
301 }
302
harknessc3fb0452016-09-02 14:08:37303 // Now, cleanup any expired budget chunks for the origin.
304 bool needs_write = CleanupExpiredBudget(origin);
305
harkness6f6b41432016-09-08 09:17:28306 // Get the SES score and add engagement budget for the site.
307 AddEngagementBudget(origin);
308
harknessc3fb0452016-09-02 14:08:37309 if (needs_write)
tzikcf7bcd652017-06-15 04:19:30310 WriteCachedValuesToDatabase(origin, std::move(callback));
harknessc3fb0452016-09-02 14:08:37311 else
tzikcf7bcd652017-06-15 04:19:30312 std::move(callback).Run(success);
harknessc3fb0452016-09-02 14:08:37313}
314
harkness03be8a1d2016-09-09 16:01:12315void BudgetDatabase::AddEngagementBudget(const url::Origin& origin) {
harknessccdc3f3a2017-01-16 12:42:17316 // Calculate how much budget should be awarded. The award depends on the
317 // time elapsed since the last award and the SES score.
318 // By default, give the origin kBudgetDurationInDays worth of budget, but
319 // reduce that if budget has already been given during that period.
320 base::TimeDelta elapsed = base::TimeDelta::FromDays(kBudgetDurationInDays);
harknessc3fb0452016-09-02 14:08:37321 if (IsCached(origin)) {
harknessccdc3f3a2017-01-16 12:42:17322 elapsed = clock_->Now() - budget_map_[origin].last_engagement_award;
harknessc3fb0452016-09-02 14:08:37323 // Don't give engagement awards for periods less than an hour.
harknessccdc3f3a2017-01-16 12:42:17324 if (elapsed.InHours() < 1)
harknessc3fb0452016-09-02 14:08:37325 return;
harknessccdc3f3a2017-01-16 12:42:17326 // Cap elapsed time to the budget duration.
327 if (elapsed.InDays() > kBudgetDurationInDays)
328 elapsed = base::TimeDelta::FromDays(kBudgetDurationInDays);
harknessc3fb0452016-09-02 14:08:37329 }
330
harknessccdc3f3a2017-01-16 12:42:17331 // Get the current SES score, and calculate the hourly budget for that score.
harknessccdc3f3a2017-01-16 12:42:17332 double hourly_budget = kMaximumHourlyBudget *
peter91882282017-05-25 17:57:33333 GetSiteEngagementScoreForOrigin(origin) /
334 SiteEngagementService::GetMaxPoints();
harknessccdc3f3a2017-01-16 12:42:17335
harknessc3fb0452016-09-02 14:08:37336 // Update the last_engagement_award to the current time. If the origin wasn't
337 // already in the map, this adds a new entry for it.
harkness03be8a1d2016-09-09 16:01:12338 budget_map_[origin].last_engagement_award = clock_->Now();
harknessc3fb0452016-09-02 14:08:37339
340 // Add a new chunk of budget for the origin at the default expiration time.
341 base::Time expiration =
harknessccdc3f3a2017-01-16 12:42:17342 clock_->Now() + base::TimeDelta::FromDays(kBudgetDurationInDays);
343 budget_map_[origin].chunks.emplace_back(elapsed.InHours() * hourly_budget,
344 expiration);
harkness6f6b41432016-09-08 09:17:28345
346 // Any time we award engagement budget, which is done at most once an hour
347 // whenever any budget action is taken, record the budget.
348 double budget = GetBudget(origin);
349 UMA_HISTOGRAM_COUNTS_100("PushMessaging.BackgroundBudget", budget);
harknessc3fb0452016-09-02 14:08:37350}
351
352// Cleans up budget in the cache. Relies on the caller eventually writing the
353// cache back to the database.
harkness03be8a1d2016-09-09 16:01:12354bool BudgetDatabase::CleanupExpiredBudget(const url::Origin& origin) {
harknessc3fb0452016-09-02 14:08:37355 if (!IsCached(origin))
356 return false;
harkness5186e6d822016-08-09 16:54:14357
358 base::Time now = clock_->Now();
harkness03be8a1d2016-09-09 16:01:12359 BudgetChunks& chunks = budget_map_[origin].chunks;
harkness5186e6d822016-08-09 16:54:14360 auto cleanup_iter = chunks.begin();
361
362 // This relies on the list of chunks being in timestamp order.
harknessbf8b3852016-08-10 18:42:02363 while (cleanup_iter != chunks.end() && cleanup_iter->expiration <= now)
harkness5186e6d822016-08-09 16:54:14364 cleanup_iter = chunks.erase(cleanup_iter);
365
harknesse0e26092016-08-24 06:29:32366 // If the entire budget is empty now AND there have been no engagements
harknessccdc3f3a2017-01-16 12:42:17367 // in the last kBudgetDurationInDays days, remove this from the cache.
harknesse0e26092016-08-24 06:29:32368 if (chunks.empty() &&
harkness03be8a1d2016-09-09 16:01:12369 budget_map_[origin].last_engagement_award <
harknessccdc3f3a2017-01-16 12:42:17370 clock_->Now() - base::TimeDelta::FromDays(kBudgetDurationInDays)) {
harkness03be8a1d2016-09-09 16:01:12371 budget_map_.erase(origin);
harknessc3fb0452016-09-02 14:08:37372 return true;
373 }
374
375 // Although some things may have expired, there are some chunks still valid.
376 // Don't write to the DB now, write either when all chunks expire or when the
377 // origin spends some budget.
378 return false;
harkness5186e6d822016-08-09 16:54:14379}
peter91882282017-05-25 17:57:33380
381double BudgetDatabase::GetSiteEngagementScoreForOrigin(
382 const url::Origin& origin) const {
383 if (profile_->IsOffTheRecord())
384 return 0;
385
386 return SiteEngagementService::Get(profile_)->GetScore(origin.GetURL());
387}