| 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 24 matching lines...) Expand all Loading... |
| 35 namespace blink { | 35 namespace blink { |
| 36 | 36 |
| 37 MediaDevicesRequest* MediaDevicesRequest::create(ScriptState* state, UserMediaCo
ntroller* controller) | 37 MediaDevicesRequest* MediaDevicesRequest::create(ScriptState* state, UserMediaCo
ntroller* controller) |
| 38 { | 38 { |
| 39 MediaDevicesRequest* request = new MediaDevicesRequest(state, controller); | 39 MediaDevicesRequest* request = new MediaDevicesRequest(state, controller); |
| 40 request->suspendIfNeeded(); | 40 request->suspendIfNeeded(); |
| 41 return request; | 41 return request; |
| 42 } | 42 } |
| 43 | 43 |
| 44 MediaDevicesRequest::MediaDevicesRequest(ScriptState* state, UserMediaController
* controller) | 44 MediaDevicesRequest::MediaDevicesRequest(ScriptState* state, UserMediaController
* controller) |
| 45 : ActiveDOMObject(state->executionContext()) | 45 : ActiveDOMObject(state->getExecutionContext()) |
| 46 , m_controller(controller) | 46 , m_controller(controller) |
| 47 , m_resolver(ScriptPromiseResolver::create(state)) | 47 , m_resolver(ScriptPromiseResolver::create(state)) |
| 48 { | 48 { |
| 49 } | 49 } |
| 50 | 50 |
| 51 MediaDevicesRequest::~MediaDevicesRequest() | 51 MediaDevicesRequest::~MediaDevicesRequest() |
| 52 { | 52 { |
| 53 } | 53 } |
| 54 | 54 |
| 55 Document* MediaDevicesRequest::ownerDocument() | 55 Document* MediaDevicesRequest::ownerDocument() |
| 56 { | 56 { |
| 57 if (ExecutionContext* context = executionContext()) { | 57 if (ExecutionContext* context = getExecutionContext()) { |
| 58 return toDocument(context); | 58 return toDocument(context); |
| 59 } | 59 } |
| 60 | 60 |
| 61 return 0; | 61 return 0; |
| 62 } | 62 } |
| 63 | 63 |
| 64 ScriptPromise MediaDevicesRequest::start() | 64 ScriptPromise MediaDevicesRequest::start() |
| 65 { | 65 { |
| 66 ASSERT(m_controller); | 66 ASSERT(m_controller); |
| 67 m_resolver->keepAliveWhilePending(); | 67 m_resolver->keepAliveWhilePending(); |
| 68 m_controller->requestMediaDevices(this); | 68 m_controller->requestMediaDevices(this); |
| 69 return m_resolver->promise(); | 69 return m_resolver->promise(); |
| 70 } | 70 } |
| 71 | 71 |
| 72 void MediaDevicesRequest::succeed(const MediaDeviceInfoVector& mediaDevices) | 72 void MediaDevicesRequest::succeed(const MediaDeviceInfoVector& mediaDevices) |
| 73 { | 73 { |
| 74 if (!executionContext() || !m_resolver) | 74 if (!getExecutionContext() || !m_resolver) |
| 75 return; | 75 return; |
| 76 | 76 |
| 77 m_resolver->resolve(mediaDevices); | 77 m_resolver->resolve(mediaDevices); |
| 78 } | 78 } |
| 79 | 79 |
| 80 void MediaDevicesRequest::stop() | 80 void MediaDevicesRequest::stop() |
| 81 { | 81 { |
| 82 m_controller.clear(); | 82 m_controller.clear(); |
| 83 m_resolver.clear(); | 83 m_resolver.clear(); |
| 84 } | 84 } |
| 85 | 85 |
| 86 DEFINE_TRACE(MediaDevicesRequest) | 86 DEFINE_TRACE(MediaDevicesRequest) |
| 87 { | 87 { |
| 88 visitor->trace(m_controller); | 88 visitor->trace(m_controller); |
| 89 visitor->trace(m_resolver); | 89 visitor->trace(m_resolver); |
| 90 ActiveDOMObject::trace(visitor); | 90 ActiveDOMObject::trace(visitor); |
| 91 } | 91 } |
| 92 | 92 |
| 93 } // namespace blink | 93 } // namespace blink |
| OLD | NEW |