| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/permissions/Permissions.h" | 5 #include "modules/permissions/Permissions.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/Dictionary.h" | 7 #include "bindings/core/v8/Dictionary.h" |
| 8 #include "bindings/core/v8/Nullable.h" | 8 #include "bindings/core/v8/Nullable.h" |
| 9 #include "bindings/core/v8/ScriptPromise.h" | 9 #include "bindings/core/v8/ScriptPromise.h" |
| 10 #include "bindings/core/v8/ScriptPromiseResolver.h" | 10 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 // |m_service| to fire beyond this point anyway. | 271 // |m_service| to fire beyond this point anyway. |
| 272 return; | 272 return; |
| 273 } | 273 } |
| 274 m_service.reset(); | 274 m_service.reset(); |
| 275 } | 275 } |
| 276 | 276 |
| 277 void Permissions::taskComplete(ScriptPromiseResolver* resolver, | 277 void Permissions::taskComplete(ScriptPromiseResolver* resolver, |
| 278 mojom::blink::PermissionDescriptorPtr descriptor, | 278 mojom::blink::PermissionDescriptorPtr descriptor, |
| 279 mojom::blink::PermissionStatus result) { | 279 mojom::blink::PermissionStatus result) { |
| 280 if (!resolver->getExecutionContext() || | 280 if (!resolver->getExecutionContext() || |
| 281 resolver->getExecutionContext()->activeDOMObjectsAreStopped()) | 281 resolver->getExecutionContext()->isContextDestroyed()) |
| 282 return; | 282 return; |
| 283 resolver->resolve( | 283 resolver->resolve( |
| 284 PermissionStatus::take(resolver, result, std::move(descriptor))); | 284 PermissionStatus::take(resolver, result, std::move(descriptor))); |
| 285 } | 285 } |
| 286 | 286 |
| 287 void Permissions::batchTaskComplete( | 287 void Permissions::batchTaskComplete( |
| 288 ScriptPromiseResolver* resolver, | 288 ScriptPromiseResolver* resolver, |
| 289 Vector<mojom::blink::PermissionDescriptorPtr> descriptors, | 289 Vector<mojom::blink::PermissionDescriptorPtr> descriptors, |
| 290 Vector<int> callerIndexToInternalIndex, | 290 Vector<int> callerIndexToInternalIndex, |
| 291 const Vector<mojom::blink::PermissionStatus>& results) { | 291 const Vector<mojom::blink::PermissionStatus>& results) { |
| 292 if (!resolver->getExecutionContext() || | 292 if (!resolver->getExecutionContext() || |
| 293 resolver->getExecutionContext()->activeDOMObjectsAreStopped()) | 293 resolver->getExecutionContext()->isContextDestroyed()) |
| 294 return; | 294 return; |
| 295 | 295 |
| 296 // Create the response vector by finding the status for each index by | 296 // Create the response vector by finding the status for each index by |
| 297 // using the caller to internal index mapping and looking up the status | 297 // using the caller to internal index mapping and looking up the status |
| 298 // using the internal index obtained. | 298 // using the internal index obtained. |
| 299 HeapVector<Member<PermissionStatus>> result; | 299 HeapVector<Member<PermissionStatus>> result; |
| 300 result.reserveInitialCapacity(callerIndexToInternalIndex.size()); | 300 result.reserveInitialCapacity(callerIndexToInternalIndex.size()); |
| 301 for (int internalIndex : callerIndexToInternalIndex) { | 301 for (int internalIndex : callerIndexToInternalIndex) { |
| 302 result.append(PermissionStatus::createAndListen( | 302 result.append(PermissionStatus::createAndListen( |
| 303 resolver->getExecutionContext(), results[internalIndex], | 303 resolver->getExecutionContext(), results[internalIndex], |
| 304 descriptors[internalIndex]->Clone())); | 304 descriptors[internalIndex]->Clone())); |
| 305 } | 305 } |
| 306 resolver->resolve(result); | 306 resolver->resolve(result); |
| 307 } | 307 } |
| 308 | 308 |
| 309 } // namespace blink | 309 } // namespace blink |
| OLD | NEW |