| 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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 return m_service.get(); | 263 return m_service.get(); |
| 264 } | 264 } |
| 265 | 265 |
| 266 void Permissions::serviceConnectionError() { | 266 void Permissions::serviceConnectionError() { |
| 267 m_service.reset(); | 267 m_service.reset(); |
| 268 } | 268 } |
| 269 | 269 |
| 270 void Permissions::taskComplete(ScriptPromiseResolver* resolver, | 270 void Permissions::taskComplete(ScriptPromiseResolver* resolver, |
| 271 mojom::blink::PermissionDescriptorPtr descriptor, | 271 mojom::blink::PermissionDescriptorPtr descriptor, |
| 272 mojom::blink::PermissionStatus result) { | 272 mojom::blink::PermissionStatus result) { |
| 273 if (!resolver->getExecutionContext() || | 273 if (!resolver->getExecutionContext()) |
| 274 resolver->getExecutionContext()->activeDOMObjectsAreStopped()) | |
| 275 return; | 274 return; |
| 276 resolver->resolve( | 275 resolver->resolve( |
| 277 PermissionStatus::take(resolver, result, std::move(descriptor))); | 276 PermissionStatus::take(resolver, result, std::move(descriptor))); |
| 278 } | 277 } |
| 279 | 278 |
| 280 void Permissions::batchTaskComplete( | 279 void Permissions::batchTaskComplete( |
| 281 ScriptPromiseResolver* resolver, | 280 ScriptPromiseResolver* resolver, |
| 282 Vector<mojom::blink::PermissionDescriptorPtr> descriptors, | 281 Vector<mojom::blink::PermissionDescriptorPtr> descriptors, |
| 283 Vector<int> callerIndexToInternalIndex, | 282 Vector<int> callerIndexToInternalIndex, |
| 284 const Vector<mojom::blink::PermissionStatus>& results) { | 283 const Vector<mojom::blink::PermissionStatus>& results) { |
| 285 if (!resolver->getExecutionContext() || | 284 if (!resolver->getExecutionContext()) |
| 286 resolver->getExecutionContext()->activeDOMObjectsAreStopped()) | |
| 287 return; | 285 return; |
| 288 | 286 |
| 289 // Create the response vector by finding the status for each index by | 287 // Create the response vector by finding the status for each index by |
| 290 // using the caller to internal index mapping and looking up the status | 288 // using the caller to internal index mapping and looking up the status |
| 291 // using the internal index obtained. | 289 // using the internal index obtained. |
| 292 HeapVector<Member<PermissionStatus>> result; | 290 HeapVector<Member<PermissionStatus>> result; |
| 293 result.reserveInitialCapacity(callerIndexToInternalIndex.size()); | 291 result.reserveInitialCapacity(callerIndexToInternalIndex.size()); |
| 294 for (int internalIndex : callerIndexToInternalIndex) { | 292 for (int internalIndex : callerIndexToInternalIndex) { |
| 295 result.append(PermissionStatus::createAndListen( | 293 result.append(PermissionStatus::createAndListen( |
| 296 resolver->getExecutionContext(), results[internalIndex], | 294 resolver->getExecutionContext(), results[internalIndex], |
| 297 descriptors[internalIndex]->Clone())); | 295 descriptors[internalIndex]->Clone())); |
| 298 } | 296 } |
| 299 resolver->resolve(result); | 297 resolver->resolve(result); |
| 300 } | 298 } |
| 301 | 299 |
| 302 } // namespace blink | 300 } // namespace blink |
| OLD | NEW |