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

Side by Side Diff: webkit/media/crypto/proxy_decryptor.h

Issue 10822026: Implement "Key Presence" step in "Encrypted Block Encounted" algorithm in EME. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use message_loop_proxy. Created 8 years, 4 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 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 WEBKIT_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_ 5 #ifndef WEBKIT_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_
6 #define WEBKIT_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_ 6 #define WEBKIT_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector>
9 10
10 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
11 #include "base/synchronization/lock.h" 12 #include "base/synchronization/lock.h"
12 #include "media/base/decryptor.h" 13 #include "media/base/decryptor.h"
13 14
15 namespace base {
16 class MessageLoopProxy;
17 }
18
14 namespace media { 19 namespace media {
15 class DecryptorClient; 20 class DecryptorClient;
16 } 21 }
17 22
18 namespace WebKit { 23 namespace WebKit {
19 class WebFrame; 24 class WebFrame;
20 class WebMediaPlayerClient; 25 class WebMediaPlayerClient;
21 } 26 }
22 27
23 namespace webkit_media { 28 namespace webkit_media {
(...skipping 22 matching lines...) Expand all
46 virtual void CancelKeyRequest(const std::string& key_system, 51 virtual void CancelKeyRequest(const std::string& key_system,
47 const std::string& session_id) OVERRIDE; 52 const std::string& session_id) OVERRIDE;
48 virtual void Decrypt(const scoped_refptr<media::DecoderBuffer>& encrypted, 53 virtual void Decrypt(const scoped_refptr<media::DecoderBuffer>& encrypted,
49 const DecryptCB& decrypt_cb) OVERRIDE; 54 const DecryptCB& decrypt_cb) OVERRIDE;
50 55
51 private: 56 private:
52 scoped_ptr<media::Decryptor> CreatePpapiDecryptor( 57 scoped_ptr<media::Decryptor> CreatePpapiDecryptor(
53 const std::string& key_system); 58 const std::string& key_system);
54 scoped_ptr<media::Decryptor> CreateDecryptor(const std::string& key_system); 59 scoped_ptr<media::Decryptor> CreateDecryptor(const std::string& key_system);
55 60
61 // Helper function that makes sure decryptor_->Decrypt() runs on the
62 // |message_loop|.
63 void DecryptOnMessageLoop(
64 const scoped_refptr<base::MessageLoopProxy>& message_loop_proxy,
65 const scoped_refptr<media::DecoderBuffer>& encrypted,
66 const media::Decryptor::DecryptCB& decrypt_cb);
67
68 // Callback used to pass into decryptor_->Decrypt().
69 void OnBufferDecrypted(
70 const scoped_refptr<base::MessageLoopProxy>& message_loop_proxy,
71 const scoped_refptr<media::DecoderBuffer>& encrypted,
72 const media::Decryptor::DecryptCB& decrypt_cb,
73 media::Decryptor::DecryptStatus status,
74 const scoped_refptr<media::DecoderBuffer>& decrypted);
75
56 media::DecryptorClient* client_; 76 media::DecryptorClient* client_;
57 77
58 // Needed to create the PpapiDecryptor. 78 // Needed to create the PpapiDecryptor.
59 WebKit::WebMediaPlayerClient* web_media_player_client_; 79 WebKit::WebMediaPlayerClient* web_media_player_client_;
60 WebKit::WebFrame* web_frame_; 80 WebKit::WebFrame* web_frame_;
61 81
62 // Protects the |decryptor_|. The Decryptor interface specifies that the 82 // Protects the |decryptor_|. The Decryptor interface specifies that the
63 // Decrypt() function will be called on the decoder thread and all other 83 // Decrypt() function will be called on the decoder thread and all other
64 // methods on the renderer thread. The |decryptor_| itself is thread safe 84 // methods on the renderer thread. The |decryptor_| itself is thread safe
65 // when this rule is obeyed. This lock is solely to prevent the race condition 85 // when this rule is obeyed. This lock is solely to prevent the race condition
66 // between setting the |decryptor_| in GenerateKeyRequest() and using it in 86 // between setting the |decryptor_| in GenerateKeyRequest() and using it in
67 // Decrypt(). 87 // Decrypt().
68 base::Lock lock_; 88 base::Lock decryptor_lock_;
69 scoped_ptr<media::Decryptor> decryptor_; // Protected by the |lock_|. 89 scoped_ptr<media::Decryptor> decryptor_; // Protected by the |lock_|.
70 90
91 // Protects the |pending_decrypt_closures_|.
92 base::Lock pending_decrypt_closures_lock_;
scherkus (not reviewing) 2012/07/26 02:06:38 do you need separate locks?
xhwang 2012/07/26 22:16:04 I was trying to minimize the time of lock blocking
scherkus (not reviewing) 2012/07/28 23:07:19 Yes. There are three situations where a lock is r
93 std::vector<base::Closure> pending_decrypt_closures_;
94
71 DISALLOW_COPY_AND_ASSIGN(ProxyDecryptor); 95 DISALLOW_COPY_AND_ASSIGN(ProxyDecryptor);
72 }; 96 };
73 97
74 } // namespace webkit_media 98 } // namespace webkit_media
75 99
76 #endif // WEBKIT_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_ 100 #endif // WEBKIT_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698