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

Side by Side Diff: webkit/plugins/ppapi/ppapi_plugin_instance.cc

Issue 10909068: Fix resource leaks in CDM implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use ScopedPPResource in PluginInstance::DeliverBlock Created 8 years, 3 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 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 5 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/linked_ptr.h" 10 #include "base/memory/linked_ptr.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "base/stl_util.h" 12 #include "base/stl_util.h"
13 #include "base/stringprintf.h" 13 #include "base/stringprintf.h"
14 #include "base/time.h" 14 #include "base/time.h"
15 #include "base/utf_offset_string_conversions.h" 15 #include "base/utf_offset_string_conversions.h"
16 #include "base/utf_string_conversions.h" 16 #include "base/utf_string_conversions.h"
17 #include "media/base/decoder_buffer.h" 17 #include "media/base/decoder_buffer.h"
18 #include "media/base/decryptor_client.h" 18 #include "media/base/decryptor_client.h"
19 #include "ppapi/c/dev/ppb_find_dev.h" 19 #include "ppapi/c/dev/ppb_find_dev.h"
20 #include "ppapi/c/dev/ppb_zoom_dev.h" 20 #include "ppapi/c/dev/ppb_zoom_dev.h"
21 #include "ppapi/c/dev/ppp_find_dev.h" 21 #include "ppapi/c/dev/ppp_find_dev.h"
22 #include "ppapi/c/dev/ppp_selection_dev.h" 22 #include "ppapi/c/dev/ppp_selection_dev.h"
23 #include "ppapi/c/dev/ppb_testing_dev.h"
ddorwin 2012/09/05 16:17:51 This doesn't seem right.
Tom Finegan 2012/09/05 16:41:56 Done.
23 #include "ppapi/c/dev/ppp_text_input_dev.h" 24 #include "ppapi/c/dev/ppp_text_input_dev.h"
24 #include "ppapi/c/dev/ppp_zoom_dev.h" 25 #include "ppapi/c/dev/ppp_zoom_dev.h"
25 #include "ppapi/c/pp_rect.h" 26 #include "ppapi/c/pp_rect.h"
26 #include "ppapi/c/ppb_audio_config.h" 27 #include "ppapi/c/ppb_audio_config.h"
27 #include "ppapi/c/ppb_core.h" 28 #include "ppapi/c/ppb_core.h"
28 #include "ppapi/c/ppb_gamepad.h" 29 #include "ppapi/c/ppb_gamepad.h"
29 #include "ppapi/c/ppp_input_event.h" 30 #include "ppapi/c/ppp_input_event.h"
30 #include "ppapi/c/ppp_instance.h" 31 #include "ppapi/c/ppp_instance.h"
31 #include "ppapi/c/ppp_messaging.h" 32 #include "ppapi/c/ppp_messaging.h"
32 #include "ppapi/c/ppp_mouse_lock.h" 33 #include "ppapi/c/ppp_mouse_lock.h"
(...skipping 2135 matching lines...) Expand 10 before | Expand all | Expand 10 after
2168 2169
2169 DCHECK(decryptor_client_); 2170 DCHECK(decryptor_client_);
2170 decryptor_client_->KeyError( 2171 decryptor_client_->KeyError(
2171 key_system_string->value(), 2172 key_system_string->value(),
2172 session_id_string->value(), 2173 session_id_string->value(),
2173 static_cast<media::Decryptor::KeyError>(media_error), 2174 static_cast<media::Decryptor::KeyError>(media_error),
2174 system_code); 2175 system_code);
2175 } 2176 }
2176 2177
2177 void PluginInstance::DeliverBlock(PP_Instance instance, 2178 void PluginInstance::DeliverBlock(PP_Instance instance,
2178 PP_Resource decrypted_block, 2179 PP_Resource decrypted_block_arg,
ddorwin 2012/09/05 16:17:51 Prefer to keep parameter names nice (and consisten
Tom Finegan 2012/09/05 16:41:56 Done.
2179 const PP_DecryptedBlockInfo* block_info) { 2180 const PP_DecryptedBlockInfo* block_info) {
2180 DCHECK(block_info); 2181 DCHECK(block_info);
2181 2182
2182 DecryptionCBMap::iterator found = pending_decryption_cbs_.find( 2183 DecryptionCBMap::iterator found = pending_decryption_cbs_.find(
2183 block_info->tracking_info.request_id); 2184 block_info->tracking_info.request_id);
2184 2185
2185 if (found == pending_decryption_cbs_.end()) 2186 if (found == pending_decryption_cbs_.end())
2186 return; 2187 return;
2187 media::Decryptor::DecryptCB decrypt_cb = found->second; 2188 media::Decryptor::DecryptCB decrypt_cb = found->second;
2188 pending_decryption_cbs_.erase(found); 2189 pending_decryption_cbs_.erase(found);
2189 2190
2190 if (block_info->result == PP_DECRYPTRESULT_DECRYPT_NOKEY) { 2191 if (block_info->result == PP_DECRYPTRESULT_DECRYPT_NOKEY) {
2191 decrypt_cb.Run(media::Decryptor::kNoKey, NULL); 2192 decrypt_cb.Run(media::Decryptor::kNoKey, NULL);
ddorwin 2012/09/05 16:17:51 PP_DCHECK that the decrypted_block is not valid si
Tom Finegan 2012/09/05 16:41:56 Done.
2192 return; 2193 return;
2193 } 2194 }
2195
2194 if (block_info->result != PP_DECRYPTRESULT_SUCCESS) { 2196 if (block_info->result != PP_DECRYPTRESULT_SUCCESS) {
2195 decrypt_cb.Run(media::Decryptor::kError, NULL); 2197 decrypt_cb.Run(media::Decryptor::kError, NULL);
2196 return; 2198 return;
2197 } 2199 }
2200
2201 ScopedPPResource decrypted_block(ScopedPPResource::PassRef(),
2202 decrypted_block_arg);
2198 EnterResourceNoLock<PPB_Buffer_API> enter(decrypted_block, true); 2203 EnterResourceNoLock<PPB_Buffer_API> enter(decrypted_block, true);
2199
2200 if (!enter.succeeded()) { 2204 if (!enter.succeeded()) {
2201 decrypt_cb.Run(media::Decryptor::kError, NULL); 2205 decrypt_cb.Run(media::Decryptor::kError, NULL);
2202 return; 2206 return;
2203 } 2207 }
2208
2204 BufferAutoMapper mapper(enter.object()); 2209 BufferAutoMapper mapper(enter.object());
2205 if (!mapper.data() || !mapper.size()) { 2210 if (!mapper.data() || !mapper.size()) {
2206 decrypt_cb.Run(media::Decryptor::kError, NULL); 2211 decrypt_cb.Run(media::Decryptor::kError, NULL);
2207 return; 2212 return;
2208 } 2213 }
2209 2214
2210 scoped_refptr<media::DecoderBuffer> decrypted_buffer( 2215 scoped_refptr<media::DecoderBuffer> decrypted_buffer(
2211 media::DecoderBuffer::CopyFrom( 2216 media::DecoderBuffer::CopyFrom(
ddorwin 2012/09/05 16:17:51 We should try to avoid copies. With this and the C
Tom Finegan 2012/09/05 16:41:56 Added TODO.
2212 reinterpret_cast<const uint8*>(mapper.data()), mapper.size())); 2217 reinterpret_cast<const uint8*>(mapper.data()), mapper.size()));
2213 decrypted_buffer->SetTimestamp(base::TimeDelta::FromMicroseconds( 2218 decrypted_buffer->SetTimestamp(base::TimeDelta::FromMicroseconds(
2214 block_info->tracking_info.timestamp)); 2219 block_info->tracking_info.timestamp));
2215 decrypt_cb.Run(media::Decryptor::kSuccess, decrypted_buffer); 2220 decrypt_cb.Run(media::Decryptor::kSuccess, decrypted_buffer);
2216 } 2221 }
2217 2222
2218 void PluginInstance::DeliverFrame(PP_Instance instance, 2223 void PluginInstance::DeliverFrame(PP_Instance instance,
2219 PP_Resource decrypted_frame, 2224 PP_Resource decrypted_frame,
2220 const PP_DecryptedBlockInfo* block_info) { 2225 const PP_DecryptedBlockInfo* block_info) {
2221 // TODO(tomfinegan): To be implemented after completion of v0.1 of the 2226 // TODO(tomfinegan): To be implemented after completion of v0.1 of the
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
2602 screen_size_for_fullscreen_ = gfx::Size(); 2607 screen_size_for_fullscreen_ = gfx::Size();
2603 WebElement element = container_->element(); 2608 WebElement element = container_->element();
2604 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); 2609 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_);
2605 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); 2610 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_);
2606 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); 2611 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_);
2607 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); 2612 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_);
2608 } 2613 }
2609 2614
2610 } // namespace ppapi 2615 } // namespace ppapi
2611 } // namespace webkit 2616 } // namespace webkit
OLDNEW
« webkit/media/crypto/ppapi/cdm_wrapper.cc ('K') | « webkit/media/crypto/ppapi/cdm_wrapper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698