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

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

Issue 8316008: Add a new globals object for PPAPI tracking information. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 2 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"
11 #include "ppapi/c/dev/pp_video_capture_dev.h" 11 #include "ppapi/c/dev/pp_video_capture_dev.h"
12 #include "ppapi/c/dev/ppb_video_capture_dev.h" 12 #include "ppapi/c/dev/ppb_video_capture_dev.h"
13 #include "ppapi/c/pp_completion_callback.h" 13 #include "ppapi/c/pp_completion_callback.h"
14 #include "ppapi/c/pp_errors.h" 14 #include "ppapi/c/pp_errors.h"
15 #include "ppapi/shared_impl/ppapi_globals.h"
15 #include "ppapi/thunk/enter.h" 16 #include "ppapi/thunk/enter.h"
16 #include "webkit/plugins/ppapi/common.h" 17 #include "webkit/plugins/ppapi/common.h"
17 #include "webkit/plugins/ppapi/plugin_module.h" 18 #include "webkit/plugins/ppapi/plugin_module.h"
18 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 19 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
19 #include "webkit/plugins/ppapi/ppb_buffer_impl.h" 20 #include "webkit/plugins/ppapi/ppb_buffer_impl.h"
20 #include "webkit/plugins/ppapi/resource_helper.h" 21 #include "webkit/plugins/ppapi/resource_helper.h"
21 #include "webkit/plugins/ppapi/resource_tracker.h" 22 #include "webkit/plugins/ppapi/resource_tracker.h"
22 23
24 using ppapi::PpapiGlobals;
23 using ppapi::thunk::EnterResourceNoLock; 25 using ppapi::thunk::EnterResourceNoLock;
24 using ppapi::thunk::PPB_Buffer_API; 26 using ppapi::thunk::PPB_Buffer_API;
25 using ppapi::thunk::PPB_VideoCapture_API; 27 using ppapi::thunk::PPB_VideoCapture_API;
26 28
27 namespace { 29 namespace {
28 30
29 // Maximum number of buffers to actually allocate. 31 // Maximum number of buffers to actually allocate.
30 const uint32_t kMaxBuffers = 20; 32 const uint32_t kMaxBuffers = 20;
31 33
32 } // namespace 34 } // namespace
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 if (!resources[i]) 260 if (!resources[i])
259 break; 261 break;
260 262
261 EnterResourceNoLock<PPB_Buffer_API> enter(resources[i], true); 263 EnterResourceNoLock<PPB_Buffer_API> enter(resources[i], true);
262 DCHECK(enter.succeeded()); 264 DCHECK(enter.succeeded());
263 265
264 BufferInfo info; 266 BufferInfo info;
265 info.buffer = static_cast<PPB_Buffer_Impl*>(enter.object()); 267 info.buffer = static_cast<PPB_Buffer_Impl*>(enter.object());
266 info.data = info.buffer->Map(); 268 info.data = info.buffer->Map();
267 if (!info.data) { 269 if (!info.data) {
268 ResourceTracker::Get()->ReleaseResource(resources[i]); 270 PpapiGlobals::Get()->GetResourceTracker()->ReleaseResource(resources[i]);
269 break; 271 break;
270 } 272 }
271 buffers_.push_back(info); 273 buffers_.push_back(info);
272 } 274 }
273 275
274 if (buffers_.empty()) { 276 if (buffers_.empty()) {
275 // We couldn't allocate/map buffers at all. Send an error and stop the 277 // We couldn't allocate/map buffers at all. Send an error and stop the
276 // capture. 278 // capture.
277 ppp_videocapture_->OnError(pp_instance(), pp_resource(), PP_ERROR_NOMEMORY); 279 ppp_videocapture_->OnError(pp_instance(), pp_resource(), PP_ERROR_NOMEMORY);
278 status_ = PP_VIDEO_CAPTURE_STATUS_STOPPING; 280 status_ = PP_VIDEO_CAPTURE_STATUS_STOPPING;
279 platform_video_capture_->StopCapture(this); 281 platform_video_capture_->StopCapture(this);
280 return; 282 return;
281 } 283 }
282 284
283 ppp_videocapture_->OnDeviceInfo(pp_instance(), pp_resource(), &info, 285 ppp_videocapture_->OnDeviceInfo(pp_instance(), pp_resource(), &info,
284 buffers_.size(), resources.get()); 286 buffers_.size(), resources.get());
285 } 287 }
286 288
287 void PPB_VideoCapture_Impl::ReleaseBuffers() { 289 void PPB_VideoCapture_Impl::ReleaseBuffers() {
288 DCHECK(!is_dead_); 290 DCHECK(!is_dead_);
289 ResourceTracker *tracker = ResourceTracker::Get(); 291 ::ppapi::ResourceTracker* tracker = PpapiGlobals::Get()->GetResourceTracker();
290 for (size_t i = 0; i < buffers_.size(); ++i) { 292 for (size_t i = 0; i < buffers_.size(); ++i) {
291 buffers_[i].buffer->Unmap(); 293 buffers_[i].buffer->Unmap();
292 tracker->ReleaseResource(buffers_[i].buffer->pp_resource()); 294 tracker->ReleaseResource(buffers_[i].buffer->pp_resource());
293 } 295 }
294 buffers_.clear(); 296 buffers_.clear();
295 } 297 }
296 298
297 void PPB_VideoCapture_Impl::SendStatus() { 299 void PPB_VideoCapture_Impl::SendStatus() {
298 DCHECK(!is_dead_); 300 DCHECK(!is_dead_);
299 ppp_videocapture_->OnStatus(pp_instance(), pp_resource(), status_); 301 ppp_videocapture_->OnStatus(pp_instance(), pp_resource(), status_);
300 } 302 }
301 303
302 PPB_VideoCapture_Impl::BufferInfo::BufferInfo() 304 PPB_VideoCapture_Impl::BufferInfo::BufferInfo()
303 : in_use(false), 305 : in_use(false),
304 data(NULL), 306 data(NULL),
305 buffer() { 307 buffer() {
306 } 308 }
307 309
308 PPB_VideoCapture_Impl::BufferInfo::~BufferInfo() { 310 PPB_VideoCapture_Impl::BufferInfo::~BufferInfo() {
309 } 311 }
310 312
311 } // namespace ppapi 313 } // namespace ppapi
312 } // namespace webkit 314 } // namespace webkit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698