| 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 #include "content/renderer/media/crypto/ppapi_decryptor.h" | 5 #include "content/renderer/media/crypto/ppapi_decryptor.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "media/base/data_buffer.h" | 21 #include "media/base/data_buffer.h" |
| 22 #include "media/base/decoder_buffer.h" | 22 #include "media/base/decoder_buffer.h" |
| 23 #include "media/base/video_decoder_config.h" | 23 #include "media/base/video_decoder_config.h" |
| 24 #include "media/base/video_frame.h" | 24 #include "media/base/video_frame.h" |
| 25 | 25 |
| 26 namespace content { | 26 namespace content { |
| 27 | 27 |
| 28 // This class is needed so that resolving an Update() promise triggers playback | 28 // This class is needed so that resolving an Update() promise triggers playback |
| 29 // of the stream. It intercepts the resolve() call to invoke an additional | 29 // of the stream. It intercepts the resolve() call to invoke an additional |
| 30 // callback. | 30 // callback. |
| 31 class SessionUpdatedPromise : public media::SimpleCdmPromise { | 31 class SessionUpdatedPromise : public media::CdmPromiseTemplate<> { |
| 32 public: | 32 public: |
| 33 SessionUpdatedPromise(scoped_ptr<media::SimpleCdmPromise> caller_promise, | 33 SessionUpdatedPromise(scoped_ptr<media::SimpleCdmPromise> caller_promise, |
| 34 base::Closure additional_resolve_cb) | 34 const base::Closure& additional_resolve_cb) |
| 35 : caller_promise_(caller_promise.Pass()), | 35 : caller_promise_(caller_promise.Pass()), |
| 36 additional_resolve_cb_(additional_resolve_cb) {} | 36 additional_resolve_cb_(additional_resolve_cb) {} |
| 37 | 37 |
| 38 virtual void resolve() OVERRIDE { | 38 virtual void resolve() override { |
| 39 DCHECK(is_pending_); | 39 MarkPromiseSettled(); |
| 40 is_pending_ = false; | |
| 41 additional_resolve_cb_.Run(); | 40 additional_resolve_cb_.Run(); |
| 42 caller_promise_->resolve(); | 41 caller_promise_->resolve(); |
| 43 } | 42 } |
| 44 | 43 |
| 45 virtual void reject(media::MediaKeys::Exception exception_code, | 44 virtual void reject(media::MediaKeys::Exception exception_code, |
| 46 uint32 system_code, | 45 uint32 system_code, |
| 47 const std::string& error_message) OVERRIDE { | 46 const std::string& error_message) override { |
| 48 DCHECK(is_pending_); | 47 MarkPromiseSettled(); |
| 49 is_pending_ = false; | |
| 50 caller_promise_->reject(exception_code, system_code, error_message); | 48 caller_promise_->reject(exception_code, system_code, error_message); |
| 51 } | 49 } |
| 52 | 50 |
| 53 protected: | 51 protected: |
| 54 scoped_ptr<media::SimpleCdmPromise> caller_promise_; | 52 scoped_ptr<media::SimpleCdmPromise> caller_promise_; |
| 55 base::Closure additional_resolve_cb_; | 53 base::Closure additional_resolve_cb_; |
| 56 }; | 54 }; |
| 57 | 55 |
| 58 // This class is needed so that resolving a SessionLoaded() promise triggers | 56 // This class is needed so that resolving a SessionLoaded() promise triggers |
| 59 // playback of the stream. It intercepts the resolve() call to invoke an | 57 // playback of the stream. It intercepts the resolve() call to invoke an |
| 60 // additional callback. This is only needed until KeysChange event gets passed | 58 // additional callback. This is only needed until KeysChange event gets passed |
| 61 // through Pepper. | 59 // through Pepper. |
| 62 class SessionLoadedPromise : public media::NewSessionCdmPromise { | 60 class SessionLoadedPromise : public media::CdmPromiseTemplate<std::string> { |
| 63 public: | 61 public: |
| 64 SessionLoadedPromise(scoped_ptr<media::NewSessionCdmPromise> caller_promise, | 62 SessionLoadedPromise(scoped_ptr<media::NewSessionCdmPromise> caller_promise, |
| 65 base::Closure additional_resolve_cb) | 63 const base::Closure& additional_resolve_cb) |
| 66 : caller_promise_(caller_promise.Pass()), | 64 : caller_promise_(caller_promise.Pass()), |
| 67 additional_resolve_cb_(additional_resolve_cb) {} | 65 additional_resolve_cb_(additional_resolve_cb) {} |
| 68 | 66 |
| 69 virtual void resolve(const std::string& web_session_id) OVERRIDE { | 67 virtual void resolve(const std::string& web_session_id) override { |
| 70 DCHECK(is_pending_); | 68 MarkPromiseSettled(); |
| 71 is_pending_ = false; | |
| 72 additional_resolve_cb_.Run(); | 69 additional_resolve_cb_.Run(); |
| 73 caller_promise_->resolve(web_session_id); | 70 caller_promise_->resolve(web_session_id); |
| 74 } | 71 } |
| 75 | 72 |
| 76 virtual void reject(media::MediaKeys::Exception exception_code, | 73 virtual void reject(media::MediaKeys::Exception exception_code, |
| 77 uint32 system_code, | 74 uint32 system_code, |
| 78 const std::string& error_message) OVERRIDE { | 75 const std::string& error_message) override { |
| 79 DCHECK(is_pending_); | 76 MarkPromiseSettled(); |
| 80 is_pending_ = false; | |
| 81 caller_promise_->reject(exception_code, system_code, error_message); | 77 caller_promise_->reject(exception_code, system_code, error_message); |
| 82 } | 78 } |
| 83 | 79 |
| 84 protected: | 80 protected: |
| 85 scoped_ptr<media::NewSessionCdmPromise> caller_promise_; | 81 scoped_ptr<media::NewSessionCdmPromise> caller_promise_; |
| 86 base::Closure additional_resolve_cb_; | 82 base::Closure additional_resolve_cb_; |
| 87 }; | 83 }; |
| 88 | 84 |
| 89 scoped_ptr<PpapiDecryptor> PpapiDecryptor::Create( | 85 scoped_ptr<PpapiDecryptor> PpapiDecryptor::Create( |
| 90 const std::string& key_system, | 86 const std::string& key_system, |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); | 545 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); |
| 550 pepper_cdm_wrapper_.reset(); | 546 pepper_cdm_wrapper_.reset(); |
| 551 } | 547 } |
| 552 | 548 |
| 553 ContentDecryptorDelegate* PpapiDecryptor::CdmDelegate() { | 549 ContentDecryptorDelegate* PpapiDecryptor::CdmDelegate() { |
| 554 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); | 550 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); |
| 555 return (pepper_cdm_wrapper_) ? pepper_cdm_wrapper_->GetCdmDelegate() : NULL; | 551 return (pepper_cdm_wrapper_) ? pepper_cdm_wrapper_->GetCdmDelegate() : NULL; |
| 556 } | 552 } |
| 557 | 553 |
| 558 } // namespace content | 554 } // namespace content |
| OLD | NEW |