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

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

Issue 7629017: Add a unified resource tracker shared between the proxy and the impl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments Created 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/ppb_video_capture_impl.h" 5 #include "webkit/plugins/ppapi/ppb_video_capture_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 if (!resources[i]) 212 if (!resources[i])
213 break; 213 break;
214 214
215 EnterResourceNoLock<PPB_Buffer_API> enter(resources[i], true); 215 EnterResourceNoLock<PPB_Buffer_API> enter(resources[i], true);
216 DCHECK(enter.succeeded()); 216 DCHECK(enter.succeeded());
217 217
218 BufferInfo info; 218 BufferInfo info;
219 info.buffer = static_cast<PPB_Buffer_Impl*>(enter.object()); 219 info.buffer = static_cast<PPB_Buffer_Impl*>(enter.object());
220 info.data = info.buffer->Map(); 220 info.data = info.buffer->Map();
221 if (!info.data) { 221 if (!info.data) {
222 ResourceTracker::Get()->UnrefResource(resources[i]); 222 ResourceTracker::Get()->ReleaseResource(resources[i]);
223 break; 223 break;
224 } 224 }
225 buffers_.push_back(info); 225 buffers_.push_back(info);
226 } 226 }
227 227
228 if (buffers_.empty()) { 228 if (buffers_.empty()) {
229 // We couldn't allocate/map buffers at all. Send an error and stop the 229 // We couldn't allocate/map buffers at all. Send an error and stop the
230 // capture. 230 // capture.
231 ppp_videocapture_->OnError(instance()->pp_instance(), 231 ppp_videocapture_->OnError(instance()->pp_instance(),
232 ScopedResourceId(this).id, 232 ScopedResourceId(this).id,
233 PP_ERROR_NOMEMORY); 233 PP_ERROR_NOMEMORY);
234 status_ = PP_VIDEO_CAPTURE_STATUS_STOPPING; 234 status_ = PP_VIDEO_CAPTURE_STATUS_STOPPING;
235 platform_video_capture_->StopCapture(this); 235 platform_video_capture_->StopCapture(this);
236 return; 236 return;
237 } 237 }
238 238
239 ppp_videocapture_->OnDeviceInfo(instance()->pp_instance(), 239 ppp_videocapture_->OnDeviceInfo(instance()->pp_instance(),
240 ScopedResourceId(this).id, 240 ScopedResourceId(this).id,
241 &info, 241 &info,
242 buffers_.size(), 242 buffers_.size(),
243 resources.get()); 243 resources.get());
244 } 244 }
245 245
246 void PPB_VideoCapture_Impl::ReleaseBuffers() { 246 void PPB_VideoCapture_Impl::ReleaseBuffers() {
247 ResourceTracker *tracker = ResourceTracker::Get(); 247 ResourceTracker *tracker = ResourceTracker::Get();
248 for (size_t i = 0; i < buffers_.size(); ++i) { 248 for (size_t i = 0; i < buffers_.size(); ++i) {
249 buffers_[i].buffer->Unmap(); 249 buffers_[i].buffer->Unmap();
250 tracker->UnrefResource(buffers_[i].buffer->GetReferenceNoAddRef()); 250 tracker->ReleaseResource(buffers_[i].buffer->pp_resource());
251 } 251 }
252 buffers_.clear(); 252 buffers_.clear();
253 } 253 }
254 254
255 void PPB_VideoCapture_Impl::SendStatus() { 255 void PPB_VideoCapture_Impl::SendStatus() {
256 ppp_videocapture_->OnStatus(instance()->pp_instance(), 256 ppp_videocapture_->OnStatus(instance()->pp_instance(),
257 ScopedResourceId(this).id, 257 ScopedResourceId(this).id,
258 status_); 258 status_);
259 } 259 }
260 260
261 PPB_VideoCapture_Impl::BufferInfo::BufferInfo() 261 PPB_VideoCapture_Impl::BufferInfo::BufferInfo()
262 : in_use(false), 262 : in_use(false),
263 data(NULL), 263 data(NULL),
264 buffer() { 264 buffer() {
265 } 265 }
266 266
267 PPB_VideoCapture_Impl::BufferInfo::~BufferInfo() { 267 PPB_VideoCapture_Impl::BufferInfo::~BufferInfo() {
268 } 268 }
269 269
270 } // namespace ppapi 270 } // namespace ppapi
271 } // namespace webkit 271 } // namespace webkit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698