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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 #include "public/platform/modules/serviceworker/WebServiceWorkerRegistration.h" | 57 #include "public/platform/modules/serviceworker/WebServiceWorkerRegistration.h" |
58 | 58 |
59 namespace blink { | 59 namespace blink { |
60 | 60 |
61 class RegistrationCallback : public WebServiceWorkerProvider::WebServiceWorkerRe
gistrationCallbacks { | 61 class RegistrationCallback : public WebServiceWorkerProvider::WebServiceWorkerRe
gistrationCallbacks { |
62 public: | 62 public: |
63 explicit RegistrationCallback(ScriptPromiseResolver* resolver) | 63 explicit RegistrationCallback(ScriptPromiseResolver* resolver) |
64 : m_resolver(resolver) { } | 64 : m_resolver(resolver) { } |
65 ~RegistrationCallback() override { } | 65 ~RegistrationCallback() override { } |
66 | 66 |
67 void onSuccess(WebServiceWorkerRegistration* registration) override | 67 void onSuccess(WebServiceWorkerRegistration* registrationRaw) override |
68 { | 68 { |
| 69 OwnPtr<WebServiceWorkerRegistration> registration = adoptPtr(registratio
nRaw); |
69 if (!m_resolver->executionContext() || m_resolver->executionContext()->a
ctiveDOMObjectsAreStopped()) | 70 if (!m_resolver->executionContext() || m_resolver->executionContext()->a
ctiveDOMObjectsAreStopped()) |
70 return; | 71 return; |
71 m_resolver->resolve(ServiceWorkerRegistration::take(m_resolver.get(), re
gistration)); | 72 m_resolver->resolve(ServiceWorkerRegistration::take(m_resolver.get(), re
gistration.release())); |
72 } | 73 } |
73 | 74 |
74 // Takes ownership of |errorRaw|. | 75 // Takes ownership of |errorRaw|. |
75 void onError(WebServiceWorkerError* errorRaw) override | 76 void onError(WebServiceWorkerError* errorRaw) override |
76 { | 77 { |
77 OwnPtr<WebServiceWorkerError> error = adoptPtr(errorRaw); | 78 OwnPtr<WebServiceWorkerError> error = adoptPtr(errorRaw); |
78 if (!m_resolver->executionContext() || m_resolver->executionContext()->a
ctiveDOMObjectsAreStopped()) | 79 if (!m_resolver->executionContext() || m_resolver->executionContext()->a
ctiveDOMObjectsAreStopped()) |
79 return; | 80 return; |
80 m_resolver->reject(ServiceWorkerError::take(m_resolver.get(), *error)); | 81 m_resolver->reject(ServiceWorkerError::take(m_resolver.get(), *error)); |
81 } | 82 } |
82 | 83 |
83 private: | 84 private: |
84 Persistent<ScriptPromiseResolver> m_resolver; | 85 Persistent<ScriptPromiseResolver> m_resolver; |
85 WTF_MAKE_NONCOPYABLE(RegistrationCallback); | 86 WTF_MAKE_NONCOPYABLE(RegistrationCallback); |
86 }; | 87 }; |
87 | 88 |
88 class GetRegistrationCallback : public WebServiceWorkerProvider::WebServiceWorke
rGetRegistrationCallbacks { | 89 class GetRegistrationCallback : public WebServiceWorkerProvider::WebServiceWorke
rGetRegistrationCallbacks { |
89 public: | 90 public: |
90 explicit GetRegistrationCallback(ScriptPromiseResolver* resolver) | 91 explicit GetRegistrationCallback(ScriptPromiseResolver* resolver) |
91 : m_resolver(resolver) { } | 92 : m_resolver(resolver) { } |
92 ~GetRegistrationCallback() override { } | 93 ~GetRegistrationCallback() override { } |
93 | 94 |
94 void onSuccess(WebServiceWorkerRegistration* registration) override | 95 void onSuccess(WebServiceWorkerRegistration* registrationRaw) override |
95 { | 96 { |
| 97 OwnPtr<WebServiceWorkerRegistration> registration = adoptPtr(registratio
nRaw); |
96 if (!m_resolver->executionContext() || m_resolver->executionContext()->a
ctiveDOMObjectsAreStopped()) | 98 if (!m_resolver->executionContext() || m_resolver->executionContext()->a
ctiveDOMObjectsAreStopped()) |
97 return; | 99 return; |
98 if (!registration) { | 100 if (!registration) { |
99 // Resolve the promise with undefined. | 101 // Resolve the promise with undefined. |
100 m_resolver->resolve(); | 102 m_resolver->resolve(); |
101 return; | 103 return; |
102 } | 104 } |
103 m_resolver->resolve(ServiceWorkerRegistration::take(m_resolver.get(), re
gistration)); | 105 m_resolver->resolve(ServiceWorkerRegistration::take(m_resolver.get(), re
gistration.release())); |
104 } | 106 } |
105 | 107 |
106 // Takes ownership of |errorRaw|. | 108 // Takes ownership of |errorRaw|. |
107 void onError(WebServiceWorkerError* errorRaw) override | 109 void onError(WebServiceWorkerError* errorRaw) override |
108 { | 110 { |
109 OwnPtr<WebServiceWorkerError> error = adoptPtr(errorRaw); | 111 OwnPtr<WebServiceWorkerError> error = adoptPtr(errorRaw); |
110 if (!m_resolver->executionContext() || m_resolver->executionContext()->a
ctiveDOMObjectsAreStopped()) | 112 if (!m_resolver->executionContext() || m_resolver->executionContext()->a
ctiveDOMObjectsAreStopped()) |
111 return; | 113 return; |
112 m_resolver->reject(ServiceWorkerError::take(m_resolver.get(), *error)); | 114 m_resolver->reject(ServiceWorkerError::take(m_resolver.get(), *error)); |
113 } | 115 } |
(...skipping 30 matching lines...) Expand all Loading... |
144 private: | 146 private: |
145 Persistent<ScriptPromiseResolver> m_resolver; | 147 Persistent<ScriptPromiseResolver> m_resolver; |
146 WTF_MAKE_NONCOPYABLE(GetRegistrationsCallback); | 148 WTF_MAKE_NONCOPYABLE(GetRegistrationsCallback); |
147 }; | 149 }; |
148 | 150 |
149 class ServiceWorkerContainer::GetRegistrationForReadyCallback : public WebServic
eWorkerProvider::WebServiceWorkerGetRegistrationForReadyCallbacks { | 151 class ServiceWorkerContainer::GetRegistrationForReadyCallback : public WebServic
eWorkerProvider::WebServiceWorkerGetRegistrationForReadyCallbacks { |
150 public: | 152 public: |
151 explicit GetRegistrationForReadyCallback(ReadyProperty* ready) | 153 explicit GetRegistrationForReadyCallback(ReadyProperty* ready) |
152 : m_ready(ready) { } | 154 : m_ready(ready) { } |
153 ~GetRegistrationForReadyCallback() { } | 155 ~GetRegistrationForReadyCallback() { } |
154 void onSuccess(WebServiceWorkerRegistration* registration) override | 156 void onSuccess(WebServiceWorkerRegistration* registrationRaw) override |
155 { | 157 { |
156 ASSERT(registration); | 158 ASSERT(registrationRaw); |
157 ASSERT(m_ready->state() == ReadyProperty::Pending); | 159 ASSERT(m_ready->state() == ReadyProperty::Pending); |
| 160 |
| 161 OwnPtr<WebServiceWorkerRegistration> registration = adoptPtr(registratio
nRaw); |
158 if (m_ready->executionContext() && !m_ready->executionContext()->activeD
OMObjectsAreStopped()) | 162 if (m_ready->executionContext() && !m_ready->executionContext()->activeD
OMObjectsAreStopped()) |
159 m_ready->resolve(ServiceWorkerRegistration::from(m_ready->executionC
ontext(), registration)); | 163 m_ready->resolve(ServiceWorkerRegistration::create(m_ready->executio
nContext(), registration.release())); |
160 } | 164 } |
161 private: | 165 private: |
162 Persistent<ReadyProperty> m_ready; | 166 Persistent<ReadyProperty> m_ready; |
163 WTF_MAKE_NONCOPYABLE(GetRegistrationForReadyCallback); | 167 WTF_MAKE_NONCOPYABLE(GetRegistrationForReadyCallback); |
164 }; | 168 }; |
165 | 169 |
166 ServiceWorkerContainer* ServiceWorkerContainer::create(ExecutionContext* executi
onContext) | 170 ServiceWorkerContainer* ServiceWorkerContainer::create(ExecutionContext* executi
onContext) |
167 { | 171 { |
168 return new ServiceWorkerContainer(executionContext); | 172 return new ServiceWorkerContainer(executionContext); |
169 } | 173 } |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 return; | 401 return; |
398 | 402 |
399 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro
m(executionContext)) { | 403 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro
m(executionContext)) { |
400 m_provider = client->provider(); | 404 m_provider = client->provider(); |
401 if (m_provider) | 405 if (m_provider) |
402 m_provider->setClient(this); | 406 m_provider->setClient(this); |
403 } | 407 } |
404 } | 408 } |
405 | 409 |
406 } // namespace blink | 410 } // namespace blink |
OLD | NEW |