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

Side by Side Diff: media/cdm/proxy_decryptor.cc

Issue 1407933010: media: Make MediaKeys ref-counted. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase only Created 5 years, 1 month 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
« no previous file with comments | « media/cdm/proxy_decryptor.h ('k') | media/media.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "media/cdm/proxy_decryptor.h" 5 #include "media/cdm/proxy_decryptor.h"
6 6
7 #include <cstring> 7 #include <cstring>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 is_clear_key_(false), 53 is_clear_key_(false),
54 weak_ptr_factory_(this) { 54 weak_ptr_factory_(this) {
55 DCHECK(media_permission); 55 DCHECK(media_permission);
56 DCHECK(!key_added_cb_.is_null()); 56 DCHECK(!key_added_cb_.is_null());
57 DCHECK(!key_error_cb_.is_null()); 57 DCHECK(!key_error_cb_.is_null());
58 DCHECK(!key_message_cb_.is_null()); 58 DCHECK(!key_message_cb_.is_null());
59 } 59 }
60 60
61 ProxyDecryptor::~ProxyDecryptor() { 61 ProxyDecryptor::~ProxyDecryptor() {
62 // Destroy the decryptor explicitly before destroying the plugin. 62 // Destroy the decryptor explicitly before destroying the plugin.
63 media_keys_.reset(); 63 media_keys_ = nullptr;
64 } 64 }
65 65
66 void ProxyDecryptor::CreateCdm(CdmFactory* cdm_factory, 66 void ProxyDecryptor::CreateCdm(CdmFactory* cdm_factory,
67 const std::string& key_system, 67 const std::string& key_system,
68 const GURL& security_origin, 68 const GURL& security_origin,
69 const CdmContextReadyCB& cdm_context_ready_cb) { 69 const CdmContextReadyCB& cdm_context_ready_cb) {
70 DVLOG(1) << __FUNCTION__ << ": key_system = " << key_system; 70 DVLOG(1) << __FUNCTION__ << ": key_system = " << key_system;
71 DCHECK(!is_creating_cdm_); 71 DCHECK(!is_creating_cdm_);
72 DCHECK(!media_keys_); 72 DCHECK(!media_keys_);
73 73
(...skipping 15 matching lines...) Expand all
89 base::Bind(&ProxyDecryptor::OnLegacySessionError, weak_this), 89 base::Bind(&ProxyDecryptor::OnLegacySessionError, weak_this),
90 base::Bind(&ProxyDecryptor::OnSessionKeysChange, weak_this), 90 base::Bind(&ProxyDecryptor::OnSessionKeysChange, weak_this),
91 base::Bind(&ProxyDecryptor::OnSessionExpirationUpdate, weak_this), 91 base::Bind(&ProxyDecryptor::OnSessionExpirationUpdate, weak_this),
92 base::Bind(&ProxyDecryptor::OnCdmCreated, weak_this, key_system, 92 base::Bind(&ProxyDecryptor::OnCdmCreated, weak_this, key_system,
93 security_origin, cdm_context_ready_cb)); 93 security_origin, cdm_context_ready_cb));
94 } 94 }
95 95
96 void ProxyDecryptor::OnCdmCreated(const std::string& key_system, 96 void ProxyDecryptor::OnCdmCreated(const std::string& key_system,
97 const GURL& security_origin, 97 const GURL& security_origin,
98 const CdmContextReadyCB& cdm_context_ready_cb, 98 const CdmContextReadyCB& cdm_context_ready_cb,
99 scoped_ptr<MediaKeys> cdm, 99 const scoped_refptr<MediaKeys>& cdm,
100 const std::string& /* error_message */) { 100 const std::string& /* error_message */) {
101 is_creating_cdm_ = false; 101 is_creating_cdm_ = false;
102 102
103 if (!cdm) { 103 if (!cdm) {
104 cdm_context_ready_cb.Run(nullptr); 104 cdm_context_ready_cb.Run(nullptr);
105 } else { 105 } else {
106 key_system_ = key_system; 106 key_system_ = key_system;
107 security_origin_ = security_origin; 107 security_origin_ = security_origin;
108 is_clear_key_ = IsClearKey(key_system) || IsExternalClearKey(key_system); 108 is_clear_key_ = IsClearKey(key_system) || IsExternalClearKey(key_system);
109 media_keys_ = cdm.Pass(); 109 media_keys_ = cdm;
110 110
111 cdm_context_ready_cb.Run(media_keys_->GetCdmContext()); 111 cdm_context_ready_cb.Run(media_keys_->GetCdmContext());
112 } 112 }
113 113
114 for (const auto& request : pending_requests_) 114 for (const auto& request : pending_requests_)
115 GenerateKeyRequestInternal(request->init_data_type, request->init_data); 115 GenerateKeyRequestInternal(request->init_data_type, request->init_data);
116 116
117 pending_requests_.clear(); 117 pending_requests_.clear();
118 } 118 }
119 119
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 bool is_persistent = 404 bool is_persistent =
405 session_type == PersistentSession || session_type == LoadSession; 405 session_type == PersistentSession || session_type == LoadSession;
406 active_sessions_.insert(std::make_pair(session_id, is_persistent)); 406 active_sessions_.insert(std::make_pair(session_id, is_persistent));
407 407
408 // For LoadSession(), generate the KeyAdded event. 408 // For LoadSession(), generate the KeyAdded event.
409 if (session_type == LoadSession) 409 if (session_type == LoadSession)
410 GenerateKeyAdded(session_id); 410 GenerateKeyAdded(session_id);
411 } 411 }
412 412
413 } // namespace media 413 } // namespace media
OLDNEW
« no previous file with comments | « media/cdm/proxy_decryptor.h ('k') | media/media.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698