| 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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 | 257 |
| 258 PermissionService* Permissions::getService(ExecutionContext* executionContext) { | 258 PermissionService* Permissions::getService(ExecutionContext* executionContext) { |
| 259 if (!m_service && | 259 if (!m_service && |
| 260 connectToPermissionService(executionContext, mojo::GetProxy(&m_service))) | 260 connectToPermissionService(executionContext, mojo::GetProxy(&m_service))) |
| 261 m_service.set_connection_error_handler(convertToBaseCallback(WTF::bind( | 261 m_service.set_connection_error_handler(convertToBaseCallback(WTF::bind( |
| 262 &Permissions::serviceConnectionError, wrapWeakPersistent(this)))); | 262 &Permissions::serviceConnectionError, wrapWeakPersistent(this)))); |
| 263 return m_service.get(); | 263 return m_service.get(); |
| 264 } | 264 } |
| 265 | 265 |
| 266 void Permissions::serviceConnectionError() { | 266 void Permissions::serviceConnectionError() { |
| 267 if (!Platform::current()) { |
| 268 // TODO(rockot): Remove this hack once renderer shutdown sequence is fixed. |
| 269 // Note that reaching this code indicates that the MessageLoop has already |
| 270 // been torn down, so it's impossible for any pending reply callbacks on |
| 271 // |m_service| to fire beyond this point anyway. |
| 272 return; |
| 273 } |
| 267 m_service.reset(); | 274 m_service.reset(); |
| 268 } | 275 } |
| 269 | 276 |
| 270 void Permissions::taskComplete(ScriptPromiseResolver* resolver, | 277 void Permissions::taskComplete(ScriptPromiseResolver* resolver, |
| 271 mojom::blink::PermissionDescriptorPtr descriptor, | 278 mojom::blink::PermissionDescriptorPtr descriptor, |
| 272 mojom::blink::PermissionStatus result) { | 279 mojom::blink::PermissionStatus result) { |
| 273 if (!resolver->getExecutionContext() || | 280 if (!resolver->getExecutionContext() || |
| 274 resolver->getExecutionContext()->activeDOMObjectsAreStopped()) | 281 resolver->getExecutionContext()->activeDOMObjectsAreStopped()) |
| 275 return; | 282 return; |
| 276 resolver->resolve( | 283 resolver->resolve( |
| (...skipping 16 matching lines...) Expand all Loading... |
| 293 result.reserveInitialCapacity(callerIndexToInternalIndex.size()); | 300 result.reserveInitialCapacity(callerIndexToInternalIndex.size()); |
| 294 for (int internalIndex : callerIndexToInternalIndex) { | 301 for (int internalIndex : callerIndexToInternalIndex) { |
| 295 result.append(PermissionStatus::createAndListen( | 302 result.append(PermissionStatus::createAndListen( |
| 296 resolver->getExecutionContext(), results[internalIndex], | 303 resolver->getExecutionContext(), results[internalIndex], |
| 297 descriptors[internalIndex]->Clone())); | 304 descriptors[internalIndex]->Clone())); |
| 298 } | 305 } |
| 299 resolver->resolve(result); | 306 resolver->resolve(result); |
| 300 } | 307 } |
| 301 | 308 |
| 302 } // namespace blink | 309 } // namespace blink |
| OLD | NEW |