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

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

Issue 2866623003: PaymentRequest.canMakePayment() query quota on desktop. (Closed)
Patch Set: 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
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& iframe_origin,
23 const std::map<std::string, std::set<std::string>>& query) {
24 const auto& it = queries_.find(iframe_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::ExpireQuotaForIframeOrigin,
30 base::Unretained(this), iframe_origin));
31 timers_.insert(std::make_pair(iframe_origin, std::move(timer)));
32 queries_.insert(std::make_pair(iframe_origin, query));
33 return true;
34 }
35
36 return it->second == query;
37 }
38
39 void CanMakePaymentQuery::ExpireQuotaForIframeOrigin(
40 const GURL& iframe_origin) {
41 timers_.erase(iframe_origin);
42 queries_.erase(iframe_origin);
43 }
44
45 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698