OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2013 Apple Inc. All rights reserved. | 2 * Copyright (C) 2013 Apple 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 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
806 // 1. If this object is closed, return a promise rejected with an | 806 // 1. If this object is closed, return a promise rejected with an |
807 // InvalidStateError. | 807 // InvalidStateError. |
808 if (is_closed_) | 808 if (is_closed_) |
809 return CreateRejectedPromiseAlreadyClosed(script_state); | 809 return CreateRejectedPromiseAlreadyClosed(script_state); |
810 | 810 |
811 // 2. If this object's callable value is false, return a promise rejected | 811 // 2. If this object's callable value is false, return a promise rejected |
812 // with an InvalidStateError. | 812 // with an InvalidStateError. |
813 if (!is_callable_) | 813 if (!is_callable_) |
814 return CreateRejectedPromiseNotCallable(script_state); | 814 return CreateRejectedPromiseNotCallable(script_state); |
815 | 815 |
816 // 3. If the result of running the "Is persistent session type?" algorithm | 816 // 3. Let promise be a new promise. |
xhwang
2017/04/21 18:00:28
This change will also affect all key systems (e.g.
jrummell
2017/04/22 00:23:17
Limited this to ClearKey only. Unfortunately there
| |
817 // on this object's session type is false, return a promise rejected | |
818 // with a newly created TypeError. | |
819 if (!IsPersistentSessionType(session_type_)) { | |
820 return ScriptPromise::Reject( | |
821 script_state, | |
822 V8ThrowException::CreateTypeError( | |
823 script_state->GetIsolate(), "The session type is not persistent.")); | |
824 } | |
825 | |
826 // 4. Let promise be a new promise. | |
827 SimpleResultPromise* result = new SimpleResultPromise(script_state, this); | 817 SimpleResultPromise* result = new SimpleResultPromise(script_state, this); |
828 ScriptPromise promise = result->Promise(); | 818 ScriptPromise promise = result->Promise(); |
829 | 819 |
830 // 5. Run the following steps asynchronously (done in removeTask()). | 820 // 4. Run the following steps asynchronously (done in removeTask()). |
831 pending_actions_.push_back(PendingAction::CreatePendingRemove(result)); | 821 pending_actions_.push_back(PendingAction::CreatePendingRemove(result)); |
832 if (!action_timer_.IsActive()) | 822 if (!action_timer_.IsActive()) |
833 action_timer_.StartOneShot(0, BLINK_FROM_HERE); | 823 action_timer_.StartOneShot(0, BLINK_FROM_HERE); |
834 | 824 |
835 // 6. Return promise. | 825 // 5. Return promise. |
836 return promise; | 826 return promise; |
837 } | 827 } |
838 | 828 |
839 void MediaKeySession::RemoveTask(ContentDecryptionModuleResult* result) { | 829 void MediaKeySession::RemoveTask(ContentDecryptionModuleResult* result) { |
840 // NOTE: Continue step 5 of MediaKeySession::remove(). | 830 // NOTE: Continue step 4 of MediaKeySession::remove(). |
841 DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << __func__ << "(" << this << ")"; | 831 DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << __func__ << "(" << this << ")"; |
842 | 832 |
843 // remove() in Chromium will execute steps 5.1 through 5.3. | 833 // remove() in Chromium will execute steps 4.1 through 4.5. |
844 session_->Remove(result->Result()); | 834 session_->Remove(result->Result()); |
845 | 835 |
846 // Last step (5.3.6 Resolve promise) will be done when |result| is resolved. | 836 // Last step (4.5.6 Resolve promise) will be done when |result| is resolved. |
847 } | 837 } |
848 | 838 |
849 void MediaKeySession::ActionTimerFired(TimerBase*) { | 839 void MediaKeySession::ActionTimerFired(TimerBase*) { |
850 DCHECK(pending_actions_.size()); | 840 DCHECK(pending_actions_.size()); |
851 | 841 |
852 // Resolving promises now run synchronously and may result in additional | 842 // Resolving promises now run synchronously and may result in additional |
853 // actions getting added to the queue. As a result, swap the queue to | 843 // actions getting added to the queue. As a result, swap the queue to |
854 // a local copy to avoid problems if this happens. | 844 // a local copy to avoid problems if this happens. |
855 HeapDeque<Member<PendingAction>> pending_actions; | 845 HeapDeque<Member<PendingAction>> pending_actions; |
856 pending_actions.Swap(pending_actions_); | 846 pending_actions.Swap(pending_actions_); |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1052 visitor->Trace(async_event_queue_); | 1042 visitor->Trace(async_event_queue_); |
1053 visitor->Trace(pending_actions_); | 1043 visitor->Trace(pending_actions_); |
1054 visitor->Trace(media_keys_); | 1044 visitor->Trace(media_keys_); |
1055 visitor->Trace(key_statuses_map_); | 1045 visitor->Trace(key_statuses_map_); |
1056 visitor->Trace(closed_promise_); | 1046 visitor->Trace(closed_promise_); |
1057 EventTargetWithInlineData::Trace(visitor); | 1047 EventTargetWithInlineData::Trace(visitor); |
1058 ContextLifecycleObserver::Trace(visitor); | 1048 ContextLifecycleObserver::Trace(visitor); |
1059 } | 1049 } |
1060 | 1050 |
1061 } // namespace blink | 1051 } // namespace blink |
OLD | NEW |