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

Side by Side Diff: third_party/WebKit/Source/modules/payments/PaymentAppServiceWorkerRegistration.cpp

Issue 2686613004: Revert of Use a new Supplement constructor for ServiceWorkerRegistration supplements (Closed)
Patch Set: Created 3 years, 10 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
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 "modules/payments/PaymentAppServiceWorkerRegistration.h" 5 #include "modules/payments/PaymentAppServiceWorkerRegistration.h"
6 6
7 #include "bindings/core/v8/ScriptState.h" 7 #include "bindings/core/v8/ScriptState.h"
8 #include "core/dom/Document.h" 8 #include "core/dom/Document.h"
9 #include "modules/payments/PaymentAppManager.h" 9 #include "modules/payments/PaymentAppManager.h"
10 #include "modules/serviceworkers/ServiceWorkerRegistration.h" 10 #include "modules/serviceworkers/ServiceWorkerRegistration.h"
11 11
12 namespace blink { 12 namespace blink {
13 13
14 PaymentAppServiceWorkerRegistration::~PaymentAppServiceWorkerRegistration() {} 14 PaymentAppServiceWorkerRegistration::~PaymentAppServiceWorkerRegistration() {}
15 15
16 // static 16 // static
17 PaymentAppServiceWorkerRegistration& PaymentAppServiceWorkerRegistration::from( 17 PaymentAppServiceWorkerRegistration& PaymentAppServiceWorkerRegistration::from(
18 ServiceWorkerRegistration& registration) { 18 ServiceWorkerRegistration& registration) {
19 PaymentAppServiceWorkerRegistration* supplement = 19 PaymentAppServiceWorkerRegistration* supplement =
20 static_cast<PaymentAppServiceWorkerRegistration*>( 20 static_cast<PaymentAppServiceWorkerRegistration*>(
21 Supplement<ServiceWorkerRegistration>::from(registration, 21 Supplement<ServiceWorkerRegistration>::from(registration,
22 supplementName())); 22 supplementName()));
23 23
24 if (!supplement) { 24 if (!supplement) {
25 supplement = new PaymentAppServiceWorkerRegistration(registration); 25 supplement = new PaymentAppServiceWorkerRegistration(&registration);
26 provideTo(registration, supplementName(), supplement); 26 provideTo(registration, supplementName(), supplement);
27 } 27 }
28 28
29 return *supplement; 29 return *supplement;
30 } 30 }
31 31
32 // static 32 // static
33 PaymentAppManager* PaymentAppServiceWorkerRegistration::paymentAppManager( 33 PaymentAppManager* PaymentAppServiceWorkerRegistration::paymentAppManager(
34 ScriptState* scriptState, 34 ScriptState* scriptState,
35 ServiceWorkerRegistration& registration) { 35 ServiceWorkerRegistration& registration) {
36 return PaymentAppServiceWorkerRegistration::from(registration) 36 return PaymentAppServiceWorkerRegistration::from(registration)
37 .paymentAppManager(scriptState); 37 .paymentAppManager(scriptState);
38 } 38 }
39 39
40 PaymentAppManager* PaymentAppServiceWorkerRegistration::paymentAppManager( 40 PaymentAppManager* PaymentAppServiceWorkerRegistration::paymentAppManager(
41 ScriptState* scriptState) { 41 ScriptState* scriptState) {
42 if (!m_paymentAppManager) { 42 if (!m_paymentAppManager) {
43 m_paymentAppManager = PaymentAppManager::create(supplementable()); 43 m_paymentAppManager = PaymentAppManager::create(m_registration);
44 } 44 }
45 return m_paymentAppManager.get(); 45 return m_paymentAppManager.get();
46 } 46 }
47 47
48 DEFINE_TRACE(PaymentAppServiceWorkerRegistration) { 48 DEFINE_TRACE(PaymentAppServiceWorkerRegistration) {
49 visitor->trace(m_registration);
49 visitor->trace(m_paymentAppManager); 50 visitor->trace(m_paymentAppManager);
50 Supplement<ServiceWorkerRegistration>::trace(visitor); 51 Supplement<ServiceWorkerRegistration>::trace(visitor);
51 } 52 }
52 53
53 PaymentAppServiceWorkerRegistration::PaymentAppServiceWorkerRegistration( 54 PaymentAppServiceWorkerRegistration::PaymentAppServiceWorkerRegistration(
54 ServiceWorkerRegistration& registration) 55 ServiceWorkerRegistration* registration)
55 : Supplement<ServiceWorkerRegistration>(registration) {} 56 : m_registration(registration) {}
56 57
57 // static 58 // static
58 const char* PaymentAppServiceWorkerRegistration::supplementName() { 59 const char* PaymentAppServiceWorkerRegistration::supplementName() {
59 return "PaymentAppServiceWorkerRegistration"; 60 return "PaymentAppServiceWorkerRegistration";
60 } 61 }
61 62
62 } // namespace blink 63 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698