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

Side by Side Diff: components/payments/core/can_make_payment_query.cc

Issue 2866623003: PaymentRequest.canMakePayment() query quota on desktop. (Closed)
Patch Set: frame Created 3 years, 7 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/payments/core/can_make_payment_query.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 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 "components/payments/core/can_make_payment_query.h"
6
7 #include <utility>
8
9 #include "base/bind.h"
10 #include "base/bind_helpers.h"
11 #include "base/location.h"
12 #include "base/memory/ptr_util.h"
13 #include "base/time/time.h"
14
15 namespace payments {
16
17 CanMakePaymentQuery::CanMakePaymentQuery() {}
18
19 CanMakePaymentQuery::~CanMakePaymentQuery() {}
20
21 bool CanMakePaymentQuery::CanQuery(
22 const GURL& frame_origin,
23 const std::map<std::string, std::set<std::string>>& query) {
24 const auto& it = queries_.find(frame_origin);
25 if (it == queries_.end()) {
26 std::unique_ptr<base::OneShotTimer> timer =
27 base::MakeUnique<base::OneShotTimer>();
28 timer->Start(FROM_HERE, base::TimeDelta::FromMinutes(30),
29 base::Bind(&CanMakePaymentQuery::ExpireQuotaForFrameOrigin,
30 base::Unretained(this), frame_origin));
31 timers_.insert(std::make_pair(frame_origin, std::move(timer)));
32 queries_.insert(std::make_pair(frame_origin, query));
33 return true;
34 }
35
36 return it->second == query;
37 }
38
39 void CanMakePaymentQuery::ExpireQuotaForFrameOrigin(const GURL& frame_origin) {
40 timers_.erase(frame_origin);
41 queries_.erase(frame_origin);
42 }
43
44 } // namespace payments
OLDNEW
« no previous file with comments | « components/payments/core/can_make_payment_query.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698