Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(343)

Side by Side Diff: Source/modules/encryptedmedia/MediaKeys.cpp

Issue 139173012: Move encryptedmedia module to oilpan (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 19 matching lines...) Expand all
30 #include "core/events/ThreadLocalEventNames.h" 30 #include "core/events/ThreadLocalEventNames.h"
31 #include "core/html/HTMLMediaElement.h" 31 #include "core/html/HTMLMediaElement.h"
32 #include "modules/encryptedmedia/MediaKeyMessageEvent.h" 32 #include "modules/encryptedmedia/MediaKeyMessageEvent.h"
33 #include "platform/Logging.h" 33 #include "platform/Logging.h"
34 #include "platform/UUID.h" 34 #include "platform/UUID.h"
35 #include "platform/drm/ContentDecryptionModule.h" 35 #include "platform/drm/ContentDecryptionModule.h"
36 #include "wtf/HashSet.h" 36 #include "wtf/HashSet.h"
37 37
38 namespace WebCore { 38 namespace WebCore {
39 39
40 PassRefPtr<MediaKeys> MediaKeys::create(const String& keySystem, ExceptionState& exceptionState) 40 DEFINE_GC_INFO(MediaKeys);
41
42 PassRefPtrWillBeRawPtr<MediaKeys> MediaKeys::create(const String& keySystem, Exc eptionState& exceptionState)
41 { 43 {
42 // From <http://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/e ncrypted-media.html#dom-media-keys-constructor>: 44 // From <http://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/e ncrypted-media.html#dom-media-keys-constructor>:
43 // The MediaKeys(keySystem) constructor must run the following steps: 45 // The MediaKeys(keySystem) constructor must run the following steps:
44 46
45 // 1. If keySystem is null or an empty string, throw an InvalidAccessError e xception and abort these steps. 47 // 1. If keySystem is null or an empty string, throw an InvalidAccessError e xception and abort these steps.
46 if (keySystem.isEmpty()) { 48 if (keySystem.isEmpty()) {
47 exceptionState.throwDOMException(InvalidAccessError, "The key system pro vided is invalid."); 49 exceptionState.throwDOMException(InvalidAccessError, "The key system pro vided is invalid.");
48 return 0; 50 return 0;
49 } 51 }
50 52
51 // 2. If keySystem is not one of the user agent's supported Key Systems, thr ow a NotSupportedError and abort these steps. 53 // 2. If keySystem is not one of the user agent's supported Key Systems, thr ow a NotSupportedError and abort these steps.
52 if (!ContentDecryptionModule::supportsKeySystem(keySystem)) { 54 if (!ContentDecryptionModule::supportsKeySystem(keySystem)) {
53 exceptionState.throwDOMException(NotSupportedError, "The '" + keySystem + "' key system is not supported."); 55 exceptionState.throwDOMException(NotSupportedError, "The '" + keySystem + "' key system is not supported.");
54 return 0; 56 return 0;
55 } 57 }
56 58
57 // 3. Let cdm be the content decryption module corresponding to keySystem. 59 // 3. Let cdm be the content decryption module corresponding to keySystem.
58 // 4. Load cdm if necessary. 60 // 4. Load cdm if necessary.
59 OwnPtr<ContentDecryptionModule> cdm = ContentDecryptionModule::create(keySys tem); 61 OwnPtr<ContentDecryptionModule> cdm = ContentDecryptionModule::create(keySys tem);
60 if (!cdm) { 62 if (!cdm) {
61 exceptionState.throwDOMException(NotSupportedError, "A content decryptio n module could not be loaded for the '" + keySystem + "' key system."); 63 exceptionState.throwDOMException(NotSupportedError, "A content decryptio n module could not be loaded for the '" + keySystem + "' key system.");
62 return 0; 64 return 0;
63 } 65 }
64 66
65 // 5. Create a new MediaKeys object. 67 // 5. Create a new MediaKeys object.
66 // 5.1 Let the keySystem attribute be keySystem. 68 // 5.1 Let the keySystem attribute be keySystem.
67 // 6. Return the new object to the caller. 69 // 6. Return the new object to the caller.
68 return adoptRef(new MediaKeys(keySystem, cdm.release())); 70 return adoptRefWillBeNoop(new MediaKeys(keySystem, cdm.release()));
69 } 71 }
70 72
71 MediaKeys::MediaKeys(const String& keySystem, PassOwnPtr<ContentDecryptionModule > cdm) 73 MediaKeys::MediaKeys(const String& keySystem, PassOwnPtr<ContentDecryptionModule > cdm)
72 : m_mediaElement(0) 74 : m_mediaElement(0)
73 , m_keySystem(keySystem) 75 , m_keySystem(keySystem)
74 , m_cdm(cdm) 76 , m_cdm(cdm)
75 , m_initializeNewSessionTimer(this, &MediaKeys::initializeNewSessionTimerFir ed) 77 , m_initializeNewSessionTimer(this, &MediaKeys::initializeNewSessionTimerFir ed)
76 { 78 {
77 WTF_LOG(Media, "MediaKeys::MediaKeys"); 79 WTF_LOG(Media, "MediaKeys::MediaKeys");
78 ScriptWrappable::init(this); 80 ScriptWrappable::init(this);
79 } 81 }
80 82
81 MediaKeys::~MediaKeys() 83 MediaKeys::~MediaKeys()
82 { 84 {
83 // FIXME: Make sure MediaKeySessions are torn down correctly. 85 // FIXME: Make sure MediaKeySessions are torn down correctly.
84 } 86 }
85 87
86 PassRefPtr<MediaKeySession> MediaKeys::createSession(ExecutionContext* context, const String& contentType, Uint8Array* initData, ExceptionState& exceptionState) 88 PassRefPtrWillBeRawPtr<MediaKeySession> MediaKeys::createSession(ExecutionContex t* context, const String& contentType, Uint8Array* initData, ExceptionState& exc eptionState)
87 { 89 {
88 WTF_LOG(Media, "MediaKeys::createSession"); 90 WTF_LOG(Media, "MediaKeys::createSession");
89 91
90 // From <http://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/e ncrypted-media.html#dom-createsession>: 92 // From <http://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/e ncrypted-media.html#dom-createsession>:
91 // The createSession(type, initData) method must run the following steps: 93 // The createSession(type, initData) method must run the following steps:
92 // Note: The contents of initData are container-specific Initialization Data . 94 // Note: The contents of initData are container-specific Initialization Data .
93 95
94 if (contentType.isEmpty()) { 96 if (contentType.isEmpty()) {
95 exceptionState.throwDOMException(InvalidAccessError, "The contentType pr ovided ('" + contentType + "') is empty."); 97 exceptionState.throwDOMException(InvalidAccessError, "The contentType pr ovided ('" + contentType + "') is empty.");
96 return 0; 98 return 0;
97 } 99 }
98 100
99 if (!initData || !initData->length()) { 101 if (!initData || !initData->length()) {
100 exceptionState.throwDOMException(InvalidAccessError, "The initData provi ded is null or empty."); 102 exceptionState.throwDOMException(InvalidAccessError, "The initData provi ded is null or empty.");
101 return 0; 103 return 0;
102 } 104 }
103 105
104 // 1. If type contains a MIME type that is not supported or is not supported by the keySystem, 106 // 1. If type contains a MIME type that is not supported or is not supported by the keySystem,
105 // throw a NOT_SUPPORTED_ERR exception and abort these steps. 107 // throw a NOT_SUPPORTED_ERR exception and abort these steps.
106 if (!m_cdm->supportsMIMEType(contentType)) { 108 if (!m_cdm->supportsMIMEType(contentType)) {
107 exceptionState.throwDOMException(NotSupportedError, "The type provided ( '" + contentType + "') is unsupported."); 109 exceptionState.throwDOMException(NotSupportedError, "The type provided ( '" + contentType + "') is unsupported.");
108 return 0; 110 return 0;
109 } 111 }
110 112
111 // 2. Create a new MediaKeySession object. 113 // 2. Create a new MediaKeySession object.
112 RefPtr<MediaKeySession> session = MediaKeySession::create(context, m_cdm.get (), this); 114 RefPtrWillBeRawPtr<MediaKeySession> session = MediaKeySession::create(contex t, m_cdm.get(), this);
113 // 2.1 Let the keySystem attribute be keySystem. 115 // 2.1 Let the keySystem attribute be keySystem.
114 ASSERT(!session->keySystem().isEmpty()); 116 ASSERT(!session->keySystem().isEmpty());
115 // FIXME: 2.2 Let the state of the session be CREATED. 117 // FIXME: 2.2 Let the state of the session be CREATED.
116 118
117 // 3. Add the new object to an internal list of session objects. 119 // 3. Add the new object to an internal list of session objects.
118 m_sessions.append(session); 120 m_sessions.append(session);
119 121
120 // 4. Schedule a task to initialize the session, providing type, initData, a nd the new object. 122 // 4. Schedule a task to initialize the session, providing type, initData, a nd the new object.
121 m_pendingInitializeNewSessionData.append(InitializeNewSessionData(session, c ontentType, initData)); 123 m_pendingInitializeNewSessionData.append(InitializeNewSessionData(session, c ontentType, initData));
122 124
(...skipping 22 matching lines...) Expand all
145 ASSERT(m_pendingInitializeNewSessionData.size()); 147 ASSERT(m_pendingInitializeNewSessionData.size());
146 148
147 while (!m_pendingInitializeNewSessionData.isEmpty()) { 149 while (!m_pendingInitializeNewSessionData.isEmpty()) {
148 InitializeNewSessionData data = m_pendingInitializeNewSessionData.takeFi rst(); 150 InitializeNewSessionData data = m_pendingInitializeNewSessionData.takeFi rst();
149 // FIXME: Refer to the spec to see what needs to be done in blink. 151 // FIXME: Refer to the spec to see what needs to be done in blink.
150 data.session->initializeNewSession(data.contentType, *data.initData); 152 data.session->initializeNewSession(data.contentType, *data.initData);
151 } 153 }
152 } 154 }
153 155
154 } 156 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698