| OLD | NEW |
| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 #include "public/platform/WebServiceWorkerRegistration.h" | 54 #include "public/platform/WebServiceWorkerRegistration.h" |
| 55 #include "public/platform/WebString.h" | 55 #include "public/platform/WebString.h" |
| 56 #include "public/platform/WebURL.h" | 56 #include "public/platform/WebURL.h" |
| 57 | 57 |
| 58 namespace blink { | 58 namespace blink { |
| 59 | 59 |
| 60 class RegistrationCallback : public WebServiceWorkerProvider::WebServiceWorkerRe
gistrationCallbacks { | 60 class RegistrationCallback : public WebServiceWorkerProvider::WebServiceWorkerRe
gistrationCallbacks { |
| 61 public: | 61 public: |
| 62 explicit RegistrationCallback(PassRefPtrWillBeRawPtr<ScriptPromiseResolver>
resolver) | 62 explicit RegistrationCallback(PassRefPtrWillBeRawPtr<ScriptPromiseResolver>
resolver) |
| 63 : m_resolver(resolver) { } | 63 : m_resolver(resolver) { } |
| 64 virtual ~RegistrationCallback() { } | 64 ~RegistrationCallback() override { } |
| 65 | 65 |
| 66 virtual void onSuccess(WebServiceWorkerRegistration* registration) override | 66 void onSuccess(WebServiceWorkerRegistration* registration) override |
| 67 { | 67 { |
| 68 if (!m_resolver->executionContext() || m_resolver->executionContext()->a
ctiveDOMObjectsAreStopped()) | 68 if (!m_resolver->executionContext() || m_resolver->executionContext()->a
ctiveDOMObjectsAreStopped()) |
| 69 return; | 69 return; |
| 70 m_resolver->resolve(ServiceWorkerRegistration::take(m_resolver.get(), re
gistration)); | 70 m_resolver->resolve(ServiceWorkerRegistration::take(m_resolver.get(), re
gistration)); |
| 71 } | 71 } |
| 72 | 72 |
| 73 // Takes ownership of |errorRaw|. | 73 // Takes ownership of |errorRaw|. |
| 74 virtual void onError(WebServiceWorkerError* errorRaw) override | 74 void onError(WebServiceWorkerError* errorRaw) override |
| 75 { | 75 { |
| 76 OwnPtr<WebServiceWorkerError> error = adoptPtr(errorRaw); | 76 OwnPtr<WebServiceWorkerError> error = adoptPtr(errorRaw); |
| 77 if (!m_resolver->executionContext() || m_resolver->executionContext()->a
ctiveDOMObjectsAreStopped()) | 77 if (!m_resolver->executionContext() || m_resolver->executionContext()->a
ctiveDOMObjectsAreStopped()) |
| 78 return; | 78 return; |
| 79 m_resolver->reject(ServiceWorkerError::take(m_resolver.get(), error.rele
ase())); | 79 m_resolver->reject(ServiceWorkerError::take(m_resolver.get(), error.rele
ase())); |
| 80 } | 80 } |
| 81 | 81 |
| 82 private: | 82 private: |
| 83 RefPtrWillBePersistent<ScriptPromiseResolver> m_resolver; | 83 RefPtrWillBePersistent<ScriptPromiseResolver> m_resolver; |
| 84 WTF_MAKE_NONCOPYABLE(RegistrationCallback); | 84 WTF_MAKE_NONCOPYABLE(RegistrationCallback); |
| 85 }; | 85 }; |
| 86 | 86 |
| 87 class GetRegistrationCallback : public WebServiceWorkerProvider::WebServiceWorke
rGetRegistrationCallbacks { | 87 class GetRegistrationCallback : public WebServiceWorkerProvider::WebServiceWorke
rGetRegistrationCallbacks { |
| 88 public: | 88 public: |
| 89 explicit GetRegistrationCallback(PassRefPtrWillBeRawPtr<ScriptPromiseResolve
r> resolver) | 89 explicit GetRegistrationCallback(PassRefPtrWillBeRawPtr<ScriptPromiseResolve
r> resolver) |
| 90 : m_resolver(resolver) { } | 90 : m_resolver(resolver) { } |
| 91 virtual ~GetRegistrationCallback() { } | 91 ~GetRegistrationCallback() override { } |
| 92 | 92 |
| 93 virtual void onSuccess(WebServiceWorkerRegistration* registration) override | 93 void onSuccess(WebServiceWorkerRegistration* registration) override |
| 94 { | 94 { |
| 95 if (!m_resolver->executionContext() || m_resolver->executionContext()->a
ctiveDOMObjectsAreStopped()) | 95 if (!m_resolver->executionContext() || m_resolver->executionContext()->a
ctiveDOMObjectsAreStopped()) |
| 96 return; | 96 return; |
| 97 if (!registration) { | 97 if (!registration) { |
| 98 // Resolve the promise with undefined. | 98 // Resolve the promise with undefined. |
| 99 m_resolver->resolve(); | 99 m_resolver->resolve(); |
| 100 return; | 100 return; |
| 101 } | 101 } |
| 102 m_resolver->resolve(ServiceWorkerRegistration::take(m_resolver.get(), re
gistration)); | 102 m_resolver->resolve(ServiceWorkerRegistration::take(m_resolver.get(), re
gistration)); |
| 103 } | 103 } |
| 104 | 104 |
| 105 // Takes ownership of |errorRaw|. | 105 // Takes ownership of |errorRaw|. |
| 106 virtual void onError(WebServiceWorkerError* errorRaw) override | 106 void onError(WebServiceWorkerError* errorRaw) override |
| 107 { | 107 { |
| 108 OwnPtr<WebServiceWorkerError> error = adoptPtr(errorRaw); | 108 OwnPtr<WebServiceWorkerError> error = adoptPtr(errorRaw); |
| 109 if (!m_resolver->executionContext() || m_resolver->executionContext()->a
ctiveDOMObjectsAreStopped()) | 109 if (!m_resolver->executionContext() || m_resolver->executionContext()->a
ctiveDOMObjectsAreStopped()) |
| 110 return; | 110 return; |
| 111 m_resolver->reject(ServiceWorkerError::take(m_resolver.get(), error.rele
ase())); | 111 m_resolver->reject(ServiceWorkerError::take(m_resolver.get(), error.rele
ase())); |
| 112 } | 112 } |
| 113 | 113 |
| 114 private: | 114 private: |
| 115 RefPtrWillBePersistent<ScriptPromiseResolver> m_resolver; | 115 RefPtrWillBePersistent<ScriptPromiseResolver> m_resolver; |
| 116 WTF_MAKE_NONCOPYABLE(GetRegistrationCallback); | 116 WTF_MAKE_NONCOPYABLE(GetRegistrationCallback); |
| 117 }; | 117 }; |
| 118 | 118 |
| 119 class GetRegistrationsCallback : public WebServiceWorkerProvider::WebServiceWork
erGetRegistrationsCallbacks { | 119 class GetRegistrationsCallback : public WebServiceWorkerProvider::WebServiceWork
erGetRegistrationsCallbacks { |
| 120 public: | 120 public: |
| 121 explicit GetRegistrationsCallback(PassRefPtrWillBeRawPtr<ScriptPromiseResolv
er> resolver) | 121 explicit GetRegistrationsCallback(PassRefPtrWillBeRawPtr<ScriptPromiseResolv
er> resolver) |
| 122 : m_resolver(resolver) { } | 122 : m_resolver(resolver) { } |
| 123 virtual ~GetRegistrationsCallback() { } | 123 ~GetRegistrationsCallback() override { } |
| 124 | 124 |
| 125 // Takes ownership of |registrationsRaw|. | 125 // Takes ownership of |registrationsRaw|. |
| 126 virtual void onSuccess(WebVector<WebServiceWorkerRegistration*>* registratio
nsRaw) override | 126 void onSuccess(WebVector<WebServiceWorkerRegistration*>* registrationsRaw) o
verride |
| 127 { | 127 { |
| 128 OwnPtr<WebVector<WebServiceWorkerRegistration*>> registrations = adoptPt
r(registrationsRaw); | 128 OwnPtr<WebVector<WebServiceWorkerRegistration*>> registrations = adoptPt
r(registrationsRaw); |
| 129 if (!m_resolver->executionContext() || m_resolver->executionContext()->a
ctiveDOMObjectsAreStopped()) | 129 if (!m_resolver->executionContext() || m_resolver->executionContext()->a
ctiveDOMObjectsAreStopped()) |
| 130 return; | 130 return; |
| 131 m_resolver->resolve(ServiceWorkerRegistrationArray::take(m_resolver.get(
), registrations.release())); | 131 m_resolver->resolve(ServiceWorkerRegistrationArray::take(m_resolver.get(
), registrations.release())); |
| 132 } | 132 } |
| 133 | 133 |
| 134 // Takes ownership of |errorRaw|. | 134 // Takes ownership of |errorRaw|. |
| 135 virtual void onError(WebServiceWorkerError* errorRaw) override | 135 void onError(WebServiceWorkerError* errorRaw) override |
| 136 { | 136 { |
| 137 OwnPtr<WebServiceWorkerError> error = adoptPtr(errorRaw); | 137 OwnPtr<WebServiceWorkerError> error = adoptPtr(errorRaw); |
| 138 if (!m_resolver->executionContext() || m_resolver->executionContext()->a
ctiveDOMObjectsAreStopped()) | 138 if (!m_resolver->executionContext() || m_resolver->executionContext()->a
ctiveDOMObjectsAreStopped()) |
| 139 return; | 139 return; |
| 140 m_resolver->reject(ServiceWorkerError::take(m_resolver.get(), error.rele
ase())); | 140 m_resolver->reject(ServiceWorkerError::take(m_resolver.get(), error.rele
ase())); |
| 141 } | 141 } |
| 142 | 142 |
| 143 private: | 143 private: |
| 144 RefPtrWillBePersistent<ScriptPromiseResolver> m_resolver; | 144 RefPtrWillBePersistent<ScriptPromiseResolver> m_resolver; |
| 145 WTF_MAKE_NONCOPYABLE(GetRegistrationsCallback); | 145 WTF_MAKE_NONCOPYABLE(GetRegistrationsCallback); |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 return; | 390 return; |
| 391 | 391 |
| 392 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro
m(executionContext)) { | 392 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro
m(executionContext)) { |
| 393 m_provider = client->provider(); | 393 m_provider = client->provider(); |
| 394 if (m_provider) | 394 if (m_provider) |
| 395 m_provider->setClient(this); | 395 m_provider->setClient(this); |
| 396 } | 396 } |
| 397 } | 397 } |
| 398 | 398 |
| 399 } // namespace blink | 399 } // namespace blink |
| OLD | NEW |