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

Side by Side Diff: chrome/browser/budget_service/budget_database.cc

Issue 2522553003: Mojo C++ bindings: switch WebKit mojom targets to use STL/WTF types. (Closed)
Patch Set: . Created 4 years 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 | « no previous file | chrome/browser/budget_service/budget_database_unittest.cc » ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "chrome/browser/budget_service/budget_database.h" 5 #include "chrome/browser/budget_service/budget_database.h"
6 6
7 #include "base/metrics/histogram_macros.h" 7 #include "base/metrics/histogram_macros.h"
8 #include "base/time/clock.h" 8 #include "base/time/clock.h"
9 #include "base/time/default_clock.h" 9 #include "base/time/default_clock.h"
10 #include "chrome/browser/budget_service/budget.pb.h" 10 #include "chrome/browser/budget_service/budget.pb.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 123
124 info.last_engagement_award = 124 info.last_engagement_award =
125 base::Time::FromInternalValue(budget_proto->engagement_last_updated()); 125 base::Time::FromInternalValue(budget_proto->engagement_last_updated());
126 126
127 callback.Run(success); 127 callback.Run(success);
128 } 128 }
129 129
130 void BudgetDatabase::GetBudgetAfterSync(const url::Origin& origin, 130 void BudgetDatabase::GetBudgetAfterSync(const url::Origin& origin,
131 const GetBudgetCallback& callback, 131 const GetBudgetCallback& callback,
132 bool success) { 132 bool success) {
133 mojo::Array<blink::mojom::BudgetStatePtr> predictions; 133 std::vector<blink::mojom::BudgetStatePtr> predictions;
134 134
135 // If the database wasn't able to read the information, return the 135 // If the database wasn't able to read the information, return the
136 // failure and an empty predictions array. 136 // failure and an empty predictions array.
137 if (!success) { 137 if (!success) {
138 callback.Run(blink::mojom::BudgetServiceErrorType::DATABASE_ERROR, 138 callback.Run(blink::mojom::BudgetServiceErrorType::DATABASE_ERROR,
139 std::move(predictions)); 139 std::move(predictions));
140 return; 140 return;
141 } 141 }
142 142
143 // Now, build up the BudgetExpection. This is different from the format 143 // Now, build up the BudgetExpection. This is different from the format
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 clock_->Now() - base::TimeDelta::FromHours(kBudgetDurationInHours)) { 360 clock_->Now() - base::TimeDelta::FromHours(kBudgetDurationInHours)) {
361 budget_map_.erase(origin); 361 budget_map_.erase(origin);
362 return true; 362 return true;
363 } 363 }
364 364
365 // Although some things may have expired, there are some chunks still valid. 365 // Although some things may have expired, there are some chunks still valid.
366 // Don't write to the DB now, write either when all chunks expire or when the 366 // Don't write to the DB now, write either when all chunks expire or when the
367 // origin spends some budget. 367 // origin spends some budget.
368 return false; 368 return false;
369 } 369 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/budget_service/budget_database_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698