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

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

Issue 2553163003: Remove ContextLifecycleObserver from PaymentAppManager (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
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/PaymentAppManager.h" 5 #include "modules/payments/PaymentAppManager.h"
6 6
7 #include "bindings/core/v8/ScriptPromise.h" 7 #include "bindings/core/v8/ScriptPromise.h"
8 #include "bindings/core/v8/ScriptState.h" 8 #include "bindings/core/v8/ScriptState.h"
9 #include "core/dom/DOMException.h" 9 #include "core/dom/DOMException.h"
10 #include "modules/payments/PaymentAppManifest.h" 10 #include "modules/payments/PaymentAppManifest.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 output.setEnabledMethods(enabledMethods); 77 output.setEnabledMethods(enabledMethods);
78 return output; 78 return output;
79 } 79 }
80 }; 80 };
81 81
82 } // namespace mojo 82 } // namespace mojo
83 83
84 namespace blink { 84 namespace blink {
85 85
86 PaymentAppManager* PaymentAppManager::create( 86 PaymentAppManager* PaymentAppManager::create(
87 ExecutionContext* executionContext,
88 ServiceWorkerRegistration* registration) { 87 ServiceWorkerRegistration* registration) {
89 return new PaymentAppManager(executionContext, registration); 88 return new PaymentAppManager(registration);
90 }
91
92 void PaymentAppManager::contextDestroyed() {
93 m_manager.reset();
94 } 89 }
95 90
96 ScriptPromise PaymentAppManager::setManifest( 91 ScriptPromise PaymentAppManager::setManifest(
97 ScriptState* scriptState, 92 ScriptState* scriptState,
98 const PaymentAppManifest& manifest) { 93 const PaymentAppManifest& manifest) {
99 if (!m_manager) { 94 if (!m_manager) {
100 return ScriptPromise::rejectWithDOMException( 95 return ScriptPromise::rejectWithDOMException(
101 scriptState, DOMException::create(InvalidStateError, 96 scriptState, DOMException::create(InvalidStateError,
102 "Payment app manager unavailable.")); 97 "Payment app manager unavailable."));
103 } 98 }
(...skipping 24 matching lines...) Expand all
128 m_manager->GetManifest(m_registration->scope(), 123 m_manager->GetManifest(m_registration->scope(),
129 convertToBaseCallback(WTF::bind( 124 convertToBaseCallback(WTF::bind(
130 &PaymentAppManager::onGetManifest, 125 &PaymentAppManager::onGetManifest,
131 wrapPersistent(this), wrapPersistent(resolver)))); 126 wrapPersistent(this), wrapPersistent(resolver))));
132 127
133 return promise; 128 return promise;
134 } 129 }
135 130
136 DEFINE_TRACE(PaymentAppManager) { 131 DEFINE_TRACE(PaymentAppManager) {
137 visitor->trace(m_registration); 132 visitor->trace(m_registration);
138 ContextLifecycleObserver::trace(visitor);
139 } 133 }
140 134
141 PaymentAppManager::PaymentAppManager(ExecutionContext* executionContext, 135 PaymentAppManager::PaymentAppManager(ServiceWorkerRegistration* registration)
142 ServiceWorkerRegistration* registration) 136 : m_registration(registration) {
143 : ContextLifecycleObserver(executionContext), m_registration(registration) {
144 DCHECK(registration); 137 DCHECK(registration);
145 Platform::current()->interfaceProvider()->getInterface( 138 Platform::current()->interfaceProvider()->getInterface(
146 mojo::GetProxy(&m_manager)); 139 mojo::GetProxy(&m_manager));
147 140
148 m_manager.set_connection_error_handler(convertToBaseCallback(WTF::bind( 141 m_manager.set_connection_error_handler(convertToBaseCallback(WTF::bind(
149 &PaymentAppManager::onServiceConnectionError, wrapWeakPersistent(this)))); 142 &PaymentAppManager::onServiceConnectionError, wrapWeakPersistent(this))));
150 } 143 }
151 144
152 void PaymentAppManager::onSetManifest( 145 void PaymentAppManager::onSetManifest(
153 ScriptPromiseResolver* resolver, 146 ScriptPromiseResolver* resolver,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 192
200 void PaymentAppManager::onServiceConnectionError() { 193 void PaymentAppManager::onServiceConnectionError() {
201 if (!Platform::current()) { 194 if (!Platform::current()) {
202 return; 195 return;
203 } 196 }
204 197
205 m_manager.reset(); 198 m_manager.reset();
206 } 199 }
207 200
208 } // namespace blink 201 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698