| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 { | 58 { |
| 59 if (ExecutionContext* context = executionContext()) { | 59 if (ExecutionContext* context = executionContext()) { |
| 60 return toDocument(context); | 60 return toDocument(context); |
| 61 } | 61 } |
| 62 | 62 |
| 63 return 0; | 63 return 0; |
| 64 } | 64 } |
| 65 | 65 |
| 66 ScriptPromise MediaDevicesRequest::start() | 66 ScriptPromise MediaDevicesRequest::start() |
| 67 { | 67 { |
| 68 if (m_controller) { | 68 ASSERT(m_controller); |
| 69 m_resolver->keepAliveWhilePending(); | 69 m_resolver->keepAliveWhilePending(); |
| 70 m_controller->requestMediaDevices(this); | 70 m_controller->requestMediaDevices(this); |
| 71 return m_resolver->promise(); | 71 return m_resolver->promise(); |
| 72 } | |
| 73 | |
| 74 return ScriptPromise::rejectWithDOMException(m_resolver->scriptState(), DOME
xception::create(NotSupportedError, "No media device controller available")); | |
| 75 } | 72 } |
| 76 | 73 |
| 77 void MediaDevicesRequest::succeed(const MediaDeviceInfoVector& mediaDevices) | 74 void MediaDevicesRequest::succeed(const MediaDeviceInfoVector& mediaDevices) |
| 78 { | 75 { |
| 79 if (!executionContext() || !m_resolver) | 76 if (!executionContext() || !m_resolver) |
| 80 return; | 77 return; |
| 81 | 78 |
| 82 m_resolver->resolve(mediaDevices); | 79 m_resolver->resolve(mediaDevices); |
| 83 } | 80 } |
| 84 | 81 |
| 85 void MediaDevicesRequest::stop() | 82 void MediaDevicesRequest::stop() |
| 86 { | 83 { |
| 87 m_controller.clear(); | 84 m_controller.clear(); |
| 88 m_resolver.clear(); | 85 m_resolver.clear(); |
| 89 } | 86 } |
| 90 | 87 |
| 91 DEFINE_TRACE(MediaDevicesRequest) | 88 DEFINE_TRACE(MediaDevicesRequest) |
| 92 { | 89 { |
| 93 visitor->trace(m_controller); | 90 visitor->trace(m_controller); |
| 94 visitor->trace(m_resolver); | 91 visitor->trace(m_resolver); |
| 95 ActiveDOMObject::trace(visitor); | 92 ActiveDOMObject::trace(visitor); |
| 96 } | 93 } |
| 97 | 94 |
| 98 } // namespace blink | 95 } // namespace blink |
| OLD | NEW |