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

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

Issue 257503003: Oilpan: Enable Oilpan by default in modules/encryptedmedia (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 8 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 static bool isKeySystemSupportedWithContentType(const String& keySystem, const S tring& contentType) 47 static bool isKeySystemSupportedWithContentType(const String& keySystem, const S tring& contentType)
48 { 48 {
49 ASSERT(!keySystem.isEmpty()); 49 ASSERT(!keySystem.isEmpty());
50 50
51 ContentType type(contentType); 51 ContentType type(contentType);
52 String codecs = type.parameter("codecs"); 52 String codecs = type.parameter("codecs");
53 return MIMETypeRegistry::isSupportedEncryptedMediaMIMEType(keySystem, type.t ype(), codecs); 53 return MIMETypeRegistry::isSupportedEncryptedMediaMIMEType(keySystem, type.t ype(), codecs);
54 } 54 }
55 55
56 PassRefPtrWillBeRawPtr<MediaKeys> MediaKeys::create(ExecutionContext* context, c onst String& keySystem, ExceptionState& exceptionState) 56 MediaKeys* MediaKeys::create(ExecutionContext* context, const String& keySystem, ExceptionState& exceptionState)
57 { 57 {
58 // From <http://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/e ncrypted-media.html#dom-media-keys-constructor>: 58 // From <http://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/e ncrypted-media.html#dom-media-keys-constructor>:
59 // The MediaKeys(keySystem) constructor must run the following steps: 59 // The MediaKeys(keySystem) constructor must run the following steps:
60 60
61 // 1. If keySystem is an empty string, throw an InvalidAccessError exception and abort these steps. 61 // 1. If keySystem is an empty string, throw an InvalidAccessError exception and abort these steps.
62 if (keySystem.isEmpty()) { 62 if (keySystem.isEmpty()) {
63 exceptionState.throwDOMException(InvalidAccessError, "The key system pro vided is invalid."); 63 exceptionState.throwDOMException(InvalidAccessError, "The key system pro vided is invalid.");
64 return nullptr; 64 return nullptr;
65 } 65 }
66 66
67 // 2. If keySystem is not one of the user agent's supported Key Systems, thr ow a NotSupportedError and abort these steps. 67 // 2. If keySystem is not one of the user agent's supported Key Systems, thr ow a NotSupportedError and abort these steps.
68 if (!isKeySystemSupportedWithContentType(keySystem, "")) { 68 if (!isKeySystemSupportedWithContentType(keySystem, "")) {
69 exceptionState.throwDOMException(NotSupportedError, "The '" + keySystem + "' key system is not supported."); 69 exceptionState.throwDOMException(NotSupportedError, "The '" + keySystem + "' key system is not supported.");
70 return nullptr; 70 return nullptr;
71 } 71 }
72 72
73 // 3. Let cdm be the content decryption module corresponding to keySystem. 73 // 3. Let cdm be the content decryption module corresponding to keySystem.
74 // 4. Load cdm if necessary. 74 // 4. Load cdm if necessary.
75 Document* document = toDocument(context); 75 Document* document = toDocument(context);
76 MediaKeysController* controller = MediaKeysController::from(document->page() ); 76 MediaKeysController* controller = MediaKeysController::from(document->page() );
77 OwnPtr<blink::WebContentDecryptionModule> cdm = controller->createContentDec ryptionModule(context, keySystem); 77 OwnPtr<blink::WebContentDecryptionModule> cdm = controller->createContentDec ryptionModule(context, keySystem);
78 if (!cdm) { 78 if (!cdm) {
79 exceptionState.throwDOMException(NotSupportedError, "A content decryptio n module could not be loaded for the '" + keySystem + "' key system."); 79 exceptionState.throwDOMException(NotSupportedError, "A content decryptio n module could not be loaded for the '" + keySystem + "' key system.");
80 return nullptr; 80 return nullptr;
81 } 81 }
82 82
83 // 5. Create a new MediaKeys object. 83 // 5. Create a new MediaKeys object.
84 // 5.1 Let the keySystem attribute be keySystem. 84 // 5.1 Let the keySystem attribute be keySystem.
85 // 6. Return the new object to the caller. 85 // 6. Return the new object to the caller.
86 return adoptRefWillBeNoop(new MediaKeys(context, keySystem, cdm.release())); 86 return new MediaKeys(context, keySystem, cdm.release());
87 } 87 }
88 88
89 MediaKeys::MediaKeys(ExecutionContext* context, const String& keySystem, PassOwn Ptr<blink::WebContentDecryptionModule> cdm) 89 MediaKeys::MediaKeys(ExecutionContext* context, const String& keySystem, PassOwn Ptr<blink::WebContentDecryptionModule> cdm)
90 : ContextLifecycleObserver(context) 90 : ContextLifecycleObserver(context)
91 , m_mediaElement(0) 91 , m_mediaElement(0)
92 , m_keySystem(keySystem) 92 , m_keySystem(keySystem)
93 , m_cdm(cdm) 93 , m_cdm(cdm)
94 , m_initializeNewSessionTimer(this, &MediaKeys::initializeNewSessionTimerFir ed) 94 , m_initializeNewSessionTimer(this, &MediaKeys::initializeNewSessionTimerFir ed)
95 #if !ENABLE(OILPAN) 95 #if !ENABLE(OILPAN)
96 , m_weakFactory(this) 96 , m_weakFactory(this)
97 #endif 97 #endif
98 { 98 {
99 WTF_LOG(Media, "MediaKeys::MediaKeys"); 99 WTF_LOG(Media, "MediaKeys::MediaKeys");
100 ScriptWrappable::init(this); 100 ScriptWrappable::init(this);
101 } 101 }
102 102
103 MediaKeys::~MediaKeys() 103 MediaKeys::~MediaKeys()
104 { 104 {
105 } 105 }
106 106
107 PassRefPtrWillBeRawPtr<MediaKeySession> MediaKeys::createSession(ExecutionContex t* context, const String& contentType, Uint8Array* initData, ExceptionState& exc eptionState) 107 MediaKeySession* MediaKeys::createSession(ExecutionContext* context, const Strin g& contentType, Uint8Array* initData, ExceptionState& exceptionState)
108 { 108 {
109 WTF_LOG(Media, "MediaKeys::createSession"); 109 WTF_LOG(Media, "MediaKeys::createSession");
110 110
111 // From <http://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/e ncrypted-media.html#dom-createsession>: 111 // From <http://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/e ncrypted-media.html#dom-createsession>:
112 // The createSession(type, initData) method must run the following steps: 112 // The createSession(type, initData) method must run the following steps:
113 // Note: The contents of initData are container-specific Initialization Data . 113 // Note: The contents of initData are container-specific Initialization Data .
114 114
115 if (contentType.isEmpty()) { 115 if (contentType.isEmpty()) {
116 exceptionState.throwDOMException(InvalidAccessError, "The contentType pr ovided ('" + contentType + "') is empty."); 116 exceptionState.throwDOMException(InvalidAccessError, "The contentType pr ovided ('" + contentType + "') is empty.");
117 return nullptr; 117 return nullptr;
118 } 118 }
119 119
120 if (!initData->length()) { 120 if (!initData->length()) {
121 exceptionState.throwDOMException(InvalidAccessError, "The initData provi ded is empty."); 121 exceptionState.throwDOMException(InvalidAccessError, "The initData provi ded is empty.");
122 return nullptr; 122 return nullptr;
123 } 123 }
124 124
125 // 1. If type contains a MIME type that is not supported or is not supported by the keySystem, 125 // 1. If type contains a MIME type that is not supported or is not supported by the keySystem,
126 // throw a NOT_SUPPORTED_ERR exception and abort these steps. 126 // throw a NOT_SUPPORTED_ERR exception and abort these steps.
127 if (!isKeySystemSupportedWithContentType(m_keySystem, contentType)) { 127 if (!isKeySystemSupportedWithContentType(m_keySystem, contentType)) {
128 exceptionState.throwDOMException(NotSupportedError, "The type provided ( '" + contentType + "') is unsupported."); 128 exceptionState.throwDOMException(NotSupportedError, "The type provided ( '" + contentType + "') is unsupported.");
129 return nullptr; 129 return nullptr;
130 } 130 }
131 131
132 // 2. Create a new MediaKeySession object. 132 // 2. Create a new MediaKeySession object.
133 #if ENABLE(OILPAN)
134 MediaKeySession* session = MediaKeySession::create(context, m_cdm.get(), thi s); 133 MediaKeySession* session = MediaKeySession::create(context, m_cdm.get(), thi s);
135 #else
136 RefPtr<MediaKeySession> session = MediaKeySession::create(context, m_cdm.get (), m_weakFactory.createWeakPtr());
137 #endif
138 // 2.1 Let the keySystem attribute be keySystem. 134 // 2.1 Let the keySystem attribute be keySystem.
139 ASSERT(!session->keySystem().isEmpty()); 135 ASSERT(!session->keySystem().isEmpty());
140 // FIXME: 2.2 Let the state of the session be CREATED. 136 // FIXME: 2.2 Let the state of the session be CREATED.
141 137
142 // 3. Add the new object to an internal list of session objects (not needed) . 138 // 3. Add the new object to an internal list of session objects (not needed) .
143 139
144 // 4. Schedule a task to initialize the session, providing type, initData, a nd the new object. 140 // 4. Schedule a task to initialize the session, providing type, initData, a nd the new object.
145 m_pendingInitializeNewSessionData.append(InitializeNewSessionData(session, c ontentType, initData)); 141 m_pendingInitializeNewSessionData.append(InitializeNewSessionData(session, c ontentType, initData));
146 142
147 if (!m_initializeNewSessionTimer.isActive()) 143 if (!m_initializeNewSessionTimer.isActive())
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 205
210 void MediaKeys::contextDestroyed() 206 void MediaKeys::contextDestroyed()
211 { 207 {
212 ContextLifecycleObserver::contextDestroyed(); 208 ContextLifecycleObserver::contextDestroyed();
213 209
214 // We don't need the CDM anymore. 210 // We don't need the CDM anymore.
215 m_cdm.clear(); 211 m_cdm.clear();
216 } 212 }
217 213
218 } 214 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698