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

Side by Side Diff: third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerContainer.cpp

Issue 2547053003: s/ passed(...) / WTF::passed(...) / to avoid future ambiguity w/ base::Passed. (Closed)
Patch Set: Rebasing... 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 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 explicit RegistrationCallback(ScriptPromiseResolver* resolver) 68 explicit RegistrationCallback(ScriptPromiseResolver* resolver)
69 : m_resolver(resolver) {} 69 : m_resolver(resolver) {}
70 ~RegistrationCallback() override {} 70 ~RegistrationCallback() override {}
71 71
72 void onSuccess( 72 void onSuccess(
73 std::unique_ptr<WebServiceWorkerRegistration::Handle> handle) override { 73 std::unique_ptr<WebServiceWorkerRegistration::Handle> handle) override {
74 if (!m_resolver->getExecutionContext() || 74 if (!m_resolver->getExecutionContext() ||
75 m_resolver->getExecutionContext()->isContextDestroyed()) 75 m_resolver->getExecutionContext()->isContextDestroyed())
76 return; 76 return;
77 m_resolver->resolve(ServiceWorkerRegistration::getOrCreate( 77 m_resolver->resolve(ServiceWorkerRegistration::getOrCreate(
78 m_resolver->getExecutionContext(), wrapUnique(handle.release()))); 78 m_resolver->getExecutionContext(), WTF::wrapUnique(handle.release())));
79 } 79 }
80 80
81 void onError(const WebServiceWorkerError& error) override { 81 void onError(const WebServiceWorkerError& error) override {
82 if (!m_resolver->getExecutionContext() || 82 if (!m_resolver->getExecutionContext() ||
83 m_resolver->getExecutionContext()->isContextDestroyed()) 83 m_resolver->getExecutionContext()->isContextDestroyed())
84 return; 84 return;
85 ScriptState::Scope scope(m_resolver->getScriptState()); 85 ScriptState::Scope scope(m_resolver->getScriptState());
86 if (error.errorType == WebServiceWorkerError::ErrorTypeType) { 86 if (error.errorType == WebServiceWorkerError::ErrorTypeType) {
87 m_resolver->reject(V8ThrowException::createTypeError( 87 m_resolver->reject(V8ThrowException::createTypeError(
88 m_resolver->getScriptState()->isolate(), error.message)); 88 m_resolver->getScriptState()->isolate(), error.message));
(...skipping 11 matching lines...) Expand all
100 class GetRegistrationCallback : public WebServiceWorkerProvider:: 100 class GetRegistrationCallback : public WebServiceWorkerProvider::
101 WebServiceWorkerGetRegistrationCallbacks { 101 WebServiceWorkerGetRegistrationCallbacks {
102 public: 102 public:
103 explicit GetRegistrationCallback(ScriptPromiseResolver* resolver) 103 explicit GetRegistrationCallback(ScriptPromiseResolver* resolver)
104 : m_resolver(resolver) {} 104 : m_resolver(resolver) {}
105 ~GetRegistrationCallback() override {} 105 ~GetRegistrationCallback() override {}
106 106
107 void onSuccess(std::unique_ptr<WebServiceWorkerRegistration::Handle> 107 void onSuccess(std::unique_ptr<WebServiceWorkerRegistration::Handle>
108 webPassHandle) override { 108 webPassHandle) override {
109 std::unique_ptr<WebServiceWorkerRegistration::Handle> handle = 109 std::unique_ptr<WebServiceWorkerRegistration::Handle> handle =
110 wrapUnique(webPassHandle.release()); 110 WTF::wrapUnique(webPassHandle.release());
111 if (!m_resolver->getExecutionContext() || 111 if (!m_resolver->getExecutionContext() ||
112 m_resolver->getExecutionContext()->isContextDestroyed()) 112 m_resolver->getExecutionContext()->isContextDestroyed())
113 return; 113 return;
114 if (!handle) { 114 if (!handle) {
115 // Resolve the promise with undefined. 115 // Resolve the promise with undefined.
116 m_resolver->resolve(); 116 m_resolver->resolve();
117 return; 117 return;
118 } 118 }
119 m_resolver->resolve(ServiceWorkerRegistration::getOrCreate( 119 m_resolver->resolve(ServiceWorkerRegistration::getOrCreate(
120 m_resolver->getExecutionContext(), std::move(handle))); 120 m_resolver->getExecutionContext(), std::move(handle)));
(...skipping 16 matching lines...) Expand all
137 public: 137 public:
138 explicit GetRegistrationsCallback(ScriptPromiseResolver* resolver) 138 explicit GetRegistrationsCallback(ScriptPromiseResolver* resolver)
139 : m_resolver(resolver) {} 139 : m_resolver(resolver) {}
140 ~GetRegistrationsCallback() override {} 140 ~GetRegistrationsCallback() override {}
141 141
142 void onSuccess( 142 void onSuccess(
143 std::unique_ptr<WebVector<WebServiceWorkerRegistration::Handle*>> 143 std::unique_ptr<WebVector<WebServiceWorkerRegistration::Handle*>>
144 webPassRegistrations) override { 144 webPassRegistrations) override {
145 Vector<std::unique_ptr<WebServiceWorkerRegistration::Handle>> handles; 145 Vector<std::unique_ptr<WebServiceWorkerRegistration::Handle>> handles;
146 std::unique_ptr<WebVector<WebServiceWorkerRegistration::Handle*>> 146 std::unique_ptr<WebVector<WebServiceWorkerRegistration::Handle*>>
147 webRegistrations = wrapUnique(webPassRegistrations.release()); 147 webRegistrations = WTF::wrapUnique(webPassRegistrations.release());
148 for (auto& handle : *webRegistrations) { 148 for (auto& handle : *webRegistrations) {
149 handles.append(wrapUnique(handle)); 149 handles.append(WTF::wrapUnique(handle));
150 } 150 }
151 151
152 if (!m_resolver->getExecutionContext() || 152 if (!m_resolver->getExecutionContext() ||
153 m_resolver->getExecutionContext()->isContextDestroyed()) 153 m_resolver->getExecutionContext()->isContextDestroyed())
154 return; 154 return;
155 m_resolver->resolve( 155 m_resolver->resolve(
156 ServiceWorkerRegistrationArray::take(m_resolver.get(), &handles)); 156 ServiceWorkerRegistrationArray::take(m_resolver.get(), &handles));
157 } 157 }
158 158
159 void onError(const WebServiceWorkerError& error) override { 159 void onError(const WebServiceWorkerError& error) override {
(...skipping 14 matching lines...) Expand all
174 public: 174 public:
175 explicit GetRegistrationForReadyCallback(ReadyProperty* ready) 175 explicit GetRegistrationForReadyCallback(ReadyProperty* ready)
176 : m_ready(ready) {} 176 : m_ready(ready) {}
177 ~GetRegistrationForReadyCallback() override {} 177 ~GetRegistrationForReadyCallback() override {}
178 178
179 void onSuccess( 179 void onSuccess(
180 std::unique_ptr<WebServiceWorkerRegistration::Handle> handle) override { 180 std::unique_ptr<WebServiceWorkerRegistration::Handle> handle) override {
181 ASSERT(m_ready->getState() == ReadyProperty::Pending); 181 ASSERT(m_ready->getState() == ReadyProperty::Pending);
182 182
183 if (m_ready->getExecutionContext() && 183 if (m_ready->getExecutionContext() &&
184 !m_ready->getExecutionContext()->isContextDestroyed()) 184 !m_ready->getExecutionContext()->isContextDestroyed()) {
185 m_ready->resolve(ServiceWorkerRegistration::getOrCreate( 185 m_ready->resolve(ServiceWorkerRegistration::getOrCreate(
186 m_ready->getExecutionContext(), wrapUnique(handle.release()))); 186 m_ready->getExecutionContext(), WTF::wrapUnique(handle.release())));
187 }
187 } 188 }
188 189
189 private: 190 private:
190 Persistent<ReadyProperty> m_ready; 191 Persistent<ReadyProperty> m_ready;
191 WTF_MAKE_NONCOPYABLE(GetRegistrationForReadyCallback); 192 WTF_MAKE_NONCOPYABLE(GetRegistrationForReadyCallback);
192 }; 193 };
193 194
194 ServiceWorkerContainer* ServiceWorkerContainer::create( 195 ServiceWorkerContainer* ServiceWorkerContainer::create(
195 ExecutionContext* executionContext) { 196 ExecutionContext* executionContext) {
196 return new ServiceWorkerContainer(executionContext); 197 return new ServiceWorkerContainer(executionContext);
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 scriptURL.removeFragmentIdentifier(); 352 scriptURL.removeFragmentIdentifier();
352 353
353 KURL patternURL; 354 KURL patternURL;
354 if (options.scope().isNull()) 355 if (options.scope().isNull())
355 patternURL = KURL(scriptURL, "./"); 356 patternURL = KURL(scriptURL, "./");
356 else 357 else
357 patternURL = enteredExecutionContext(scriptState->isolate()) 358 patternURL = enteredExecutionContext(scriptState->isolate())
358 ->completeURL(options.scope()); 359 ->completeURL(options.scope());
359 360
360 registerServiceWorkerImpl(executionContext, scriptURL, patternURL, 361 registerServiceWorkerImpl(executionContext, scriptURL, patternURL,
361 makeUnique<RegistrationCallback>(resolver)); 362 WTF::makeUnique<RegistrationCallback>(resolver));
362 363
363 return promise; 364 return promise;
364 } 365 }
365 366
366 ScriptPromise ServiceWorkerContainer::getRegistration( 367 ScriptPromise ServiceWorkerContainer::getRegistration(
367 ScriptState* scriptState, 368 ScriptState* scriptState,
368 const String& documentURL) { 369 const String& documentURL) {
369 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); 370 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
370 ScriptPromise promise = resolver->promise(); 371 ScriptPromise promise = resolver->promise();
371 372
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 } 487 }
487 488
488 return m_ready->promise(callerState->world()); 489 return m_ready->promise(callerState->world());
489 } 490 }
490 491
491 void ServiceWorkerContainer::setController( 492 void ServiceWorkerContainer::setController(
492 std::unique_ptr<WebServiceWorker::Handle> handle, 493 std::unique_ptr<WebServiceWorker::Handle> handle,
493 bool shouldNotifyControllerChange) { 494 bool shouldNotifyControllerChange) {
494 if (!getExecutionContext()) 495 if (!getExecutionContext())
495 return; 496 return;
496 m_controller = 497 m_controller = ServiceWorker::from(getExecutionContext(),
497 ServiceWorker::from(getExecutionContext(), wrapUnique(handle.release())); 498 WTF::wrapUnique(handle.release()));
498 if (m_controller) 499 if (m_controller)
499 UseCounter::count(getExecutionContext(), 500 UseCounter::count(getExecutionContext(),
500 UseCounter::ServiceWorkerControlledPage); 501 UseCounter::ServiceWorkerControlledPage);
501 if (shouldNotifyControllerChange) 502 if (shouldNotifyControllerChange)
502 dispatchEvent(Event::create(EventTypeNames::controllerchange)); 503 dispatchEvent(Event::create(EventTypeNames::controllerchange));
503 } 504 }
504 505
505 void ServiceWorkerContainer::dispatchMessageEvent( 506 void ServiceWorkerContainer::dispatchMessageEvent(
506 std::unique_ptr<WebServiceWorker::Handle> handle, 507 std::unique_ptr<WebServiceWorker::Handle> handle,
507 const WebString& message, 508 const WebString& message,
508 const WebMessagePortChannelArray& webChannels) { 509 const WebMessagePortChannelArray& webChannels) {
509 if (!getExecutionContext() || !getExecutionContext()->executingWindow()) 510 if (!getExecutionContext() || !getExecutionContext()->executingWindow())
510 return; 511 return;
511 512
512 MessagePortArray* ports = 513 MessagePortArray* ports =
513 MessagePort::toMessagePortArray(getExecutionContext(), webChannels); 514 MessagePort::toMessagePortArray(getExecutionContext(), webChannels);
514 RefPtr<SerializedScriptValue> value = SerializedScriptValue::create(message); 515 RefPtr<SerializedScriptValue> value = SerializedScriptValue::create(message);
515 ServiceWorker* source = 516 ServiceWorker* source = ServiceWorker::from(
516 ServiceWorker::from(getExecutionContext(), wrapUnique(handle.release())); 517 getExecutionContext(), WTF::wrapUnique(handle.release()));
517 dispatchEvent(ServiceWorkerMessageEvent::create( 518 dispatchEvent(ServiceWorkerMessageEvent::create(
518 ports, value, source, 519 ports, value, source,
519 getExecutionContext()->getSecurityOrigin()->toString())); 520 getExecutionContext()->getSecurityOrigin()->toString()));
520 } 521 }
521 522
522 const AtomicString& ServiceWorkerContainer::interfaceName() const { 523 const AtomicString& ServiceWorkerContainer::interfaceName() const {
523 return EventTargetNames::ServiceWorkerContainer; 524 return EventTargetNames::ServiceWorkerContainer;
524 } 525 }
525 526
526 ServiceWorkerContainer::ServiceWorkerContainer( 527 ServiceWorkerContainer::ServiceWorkerContainer(
527 ExecutionContext* executionContext) 528 ExecutionContext* executionContext)
528 : ContextLifecycleObserver(executionContext), m_provider(0) { 529 : ContextLifecycleObserver(executionContext), m_provider(0) {
529 if (!executionContext) 530 if (!executionContext)
530 return; 531 return;
531 532
532 if (ServiceWorkerContainerClient* client = 533 if (ServiceWorkerContainerClient* client =
533 ServiceWorkerContainerClient::from(executionContext)) { 534 ServiceWorkerContainerClient::from(executionContext)) {
534 m_provider = client->provider(); 535 m_provider = client->provider();
535 if (m_provider) 536 if (m_provider)
536 m_provider->setClient(this); 537 m_provider->setClient(this);
537 } 538 }
538 } 539 }
539 540
540 } // namespace blink 541 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698