Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULESESSION_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULESESSION_IMPL_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULESESSION_IMPL_H_ | 6 #define CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULESESSION_IMPL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/weak_ptr.h" | |
| 14 #include "media/base/media_keys.h" | 15 #include "media/base/media_keys.h" |
| 15 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleSession.h " | 16 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleSession.h " |
| 16 #include "third_party/WebKit/public/platform/WebString.h" | 17 #include "third_party/WebKit/public/platform/WebString.h" |
| 17 | 18 |
| 18 namespace media { | 19 namespace media { |
| 19 class MediaKeys; | 20 class MediaKeys; |
| 20 } | 21 } |
| 21 | 22 |
| 22 namespace content { | 23 namespace content { |
| 23 class CdmSessionAdapter; | 24 class CdmSessionAdapter; |
| 24 | 25 |
| 25 class WebContentDecryptionModuleSessionImpl | 26 class WebContentDecryptionModuleSessionImpl |
| 26 : public blink::WebContentDecryptionModuleSession { | 27 : public blink::WebContentDecryptionModuleSession { |
| 27 public: | 28 public: |
| 28 WebContentDecryptionModuleSessionImpl( | 29 WebContentDecryptionModuleSessionImpl( |
| 29 uint32 session_id, | |
| 30 Client* client, | 30 Client* client, |
| 31 const scoped_refptr<CdmSessionAdapter>& adapter); | 31 const scoped_refptr<CdmSessionAdapter>& adapter); |
| 32 virtual ~WebContentDecryptionModuleSessionImpl(); | 32 virtual ~WebContentDecryptionModuleSessionImpl(); |
| 33 | 33 |
| 34 // blink::WebContentDecryptionModuleSession implementation. | 34 // blink::WebContentDecryptionModuleSession implementation. |
| 35 virtual blink::WebString sessionId() const; | 35 virtual blink::WebString sessionId() const; |
| 36 virtual void initializeNewSession(const blink::WebString& mime_type, | 36 virtual void initializeNewSession(const blink::WebString& mime_type, |
| 37 const uint8* init_data, | 37 const uint8* init_data, |
| 38 size_t init_data_length); | 38 size_t init_data_length); |
| 39 virtual void update(const uint8* response, size_t response_length); | 39 virtual void update(const uint8* response, size_t response_length); |
| 40 virtual void release(); | 40 virtual void release(); |
| 41 | 41 |
| 42 // Callbacks. | 42 // Callbacks. |
| 43 void OnSessionCreated(const std::string& web_session_id); | |
| 44 void OnSessionMessage(const std::vector<uint8>& message, | 43 void OnSessionMessage(const std::vector<uint8>& message, |
| 45 const std::string& destination_url); | 44 const std::string& destination_url); |
| 46 void OnSessionReady(); | 45 void OnSessionReady(); |
| 47 void OnSessionClosed(); | 46 void OnSessionClosed(); |
| 48 void OnSessionError(media::MediaKeys::KeyError error_code, | 47 void OnSessionError(const std::string& error_name, |
| 49 uint32 system_code); | 48 uint32 system_code, |
| 49 const std::string& error_message); | |
| 50 | 50 |
| 51 private: | 51 private: |
| 52 // Helpers | |
|
ddorwin
2014/05/05 18:35:42
nit: Unnecessary.
jrummell
2014/05/08 23:37:45
Done.
| |
| 53 void setSessionId(const std::string& web_session_id); | |
| 54 | |
| 52 scoped_refptr<CdmSessionAdapter> adapter_; | 55 scoped_refptr<CdmSessionAdapter> adapter_; |
| 53 | 56 |
| 54 // Non-owned pointer. | 57 // Non-owned pointer. |
| 55 Client* client_; | 58 Client* client_; |
| 56 | 59 |
| 57 // Web session ID is the app visible ID for this session generated by the CDM. | 60 // Web session ID is the app visible ID for this session generated by the CDM. |
| 58 // This value is not set until the CDM calls OnSessionCreated(). | 61 // This value is not set until the CDM resolves the initializeNewSession() |
| 59 blink::WebString web_session_id_; | 62 // promise. |
| 63 std::string web_session_id_; | |
| 60 | 64 |
| 61 // Session ID is used to uniquely track this object so that CDM callbacks | 65 // NOTE: Since promises will last until they are fired, keep a weak reference |
|
ddorwin
2014/05/05 18:35:42
nits:
Remove "NOTE: "
s/last/live/
_they_ keep? <-
jrummell
2014/05/08 23:37:45
Comment changed.
| |
| 62 // can get routed to the correct object. | 66 // in case this class disappears before the promise actually fires. |
| 63 const uint32 session_id_; | 67 base::WeakPtrFactory<WebContentDecryptionModuleSessionImpl> weak_ptr_factory_; |
| 64 | 68 |
| 65 DISALLOW_COPY_AND_ASSIGN(WebContentDecryptionModuleSessionImpl); | 69 DISALLOW_COPY_AND_ASSIGN(WebContentDecryptionModuleSessionImpl); |
| 66 }; | 70 }; |
| 67 | 71 |
| 68 } // namespace content | 72 } // namespace content |
| 69 | 73 |
| 70 #endif // CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULESESSION_IMPL_H_ | 74 #endif // CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULESESSION_IMPL_H_ |
| OLD | NEW |