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

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

Issue 8342016: Revert 106142 - 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
« no previous file with comments | « webkit/plugins/ppapi/ppb_var_impl.cc ('k') | webkit/plugins/ppapi/quota_file_io.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:mergeinfo
Merged /branches/chrome_webkit_merge_branch/src/webkit/plugins/ppapi/ppb_video_capture_impl.cc:r3734-4217,4606-5108,5177-5263
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"
16 #include "ppapi/thunk/enter.h" 15 #include "ppapi/thunk/enter.h"
17 #include "webkit/plugins/ppapi/common.h" 16 #include "webkit/plugins/ppapi/common.h"
18 #include "webkit/plugins/ppapi/plugin_module.h" 17 #include "webkit/plugins/ppapi/plugin_module.h"
19 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 18 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
20 #include "webkit/plugins/ppapi/ppb_buffer_impl.h" 19 #include "webkit/plugins/ppapi/ppb_buffer_impl.h"
21 #include "webkit/plugins/ppapi/resource_helper.h" 20 #include "webkit/plugins/ppapi/resource_helper.h"
22 #include "webkit/plugins/ppapi/resource_tracker.h" 21 #include "webkit/plugins/ppapi/resource_tracker.h"
23 22
24 using ppapi::PpapiGlobals;
25 using ppapi::thunk::EnterResourceNoLock; 23 using ppapi::thunk::EnterResourceNoLock;
26 using ppapi::thunk::PPB_Buffer_API; 24 using ppapi::thunk::PPB_Buffer_API;
27 using ppapi::thunk::PPB_VideoCapture_API; 25 using ppapi::thunk::PPB_VideoCapture_API;
28 26
29 namespace { 27 namespace {
30 28
31 // Maximum number of buffers to actually allocate. 29 // Maximum number of buffers to actually allocate.
32 const uint32_t kMaxBuffers = 20; 30 const uint32_t kMaxBuffers = 20;
33 31
34 } // namespace 32 } // namespace
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 if (!resources[i]) 258 if (!resources[i])
261 break; 259 break;
262 260
263 EnterResourceNoLock<PPB_Buffer_API> enter(resources[i], true); 261 EnterResourceNoLock<PPB_Buffer_API> enter(resources[i], true);
264 DCHECK(enter.succeeded()); 262 DCHECK(enter.succeeded());
265 263
266 BufferInfo info; 264 BufferInfo info;
267 info.buffer = static_cast<PPB_Buffer_Impl*>(enter.object()); 265 info.buffer = static_cast<PPB_Buffer_Impl*>(enter.object());
268 info.data = info.buffer->Map(); 266 info.data = info.buffer->Map();
269 if (!info.data) { 267 if (!info.data) {
270 PpapiGlobals::Get()->GetResourceTracker()->ReleaseResource(resources[i]); 268 ResourceTracker::Get()->ReleaseResource(resources[i]);
271 break; 269 break;
272 } 270 }
273 buffers_.push_back(info); 271 buffers_.push_back(info);
274 } 272 }
275 273
276 if (buffers_.empty()) { 274 if (buffers_.empty()) {
277 // We couldn't allocate/map buffers at all. Send an error and stop the 275 // We couldn't allocate/map buffers at all. Send an error and stop the
278 // capture. 276 // capture.
279 ppp_videocapture_->OnError(pp_instance(), pp_resource(), PP_ERROR_NOMEMORY); 277 ppp_videocapture_->OnError(pp_instance(), pp_resource(), PP_ERROR_NOMEMORY);
280 status_ = PP_VIDEO_CAPTURE_STATUS_STOPPING; 278 status_ = PP_VIDEO_CAPTURE_STATUS_STOPPING;
281 platform_video_capture_->StopCapture(this); 279 platform_video_capture_->StopCapture(this);
282 return; 280 return;
283 } 281 }
284 282
285 ppp_videocapture_->OnDeviceInfo(pp_instance(), pp_resource(), &info, 283 ppp_videocapture_->OnDeviceInfo(pp_instance(), pp_resource(), &info,
286 buffers_.size(), resources.get()); 284 buffers_.size(), resources.get());
287 } 285 }
288 286
289 void PPB_VideoCapture_Impl::ReleaseBuffers() { 287 void PPB_VideoCapture_Impl::ReleaseBuffers() {
290 DCHECK(!is_dead_); 288 DCHECK(!is_dead_);
291 ::ppapi::ResourceTracker* tracker = PpapiGlobals::Get()->GetResourceTracker(); 289 ResourceTracker *tracker = ResourceTracker::Get();
292 for (size_t i = 0; i < buffers_.size(); ++i) { 290 for (size_t i = 0; i < buffers_.size(); ++i) {
293 buffers_[i].buffer->Unmap(); 291 buffers_[i].buffer->Unmap();
294 tracker->ReleaseResource(buffers_[i].buffer->pp_resource()); 292 tracker->ReleaseResource(buffers_[i].buffer->pp_resource());
295 } 293 }
296 buffers_.clear(); 294 buffers_.clear();
297 } 295 }
298 296
299 void PPB_VideoCapture_Impl::SendStatus() { 297 void PPB_VideoCapture_Impl::SendStatus() {
300 DCHECK(!is_dead_); 298 DCHECK(!is_dead_);
301 ppp_videocapture_->OnStatus(pp_instance(), pp_resource(), status_); 299 ppp_videocapture_->OnStatus(pp_instance(), pp_resource(), status_);
302 } 300 }
303 301
304 PPB_VideoCapture_Impl::BufferInfo::BufferInfo() 302 PPB_VideoCapture_Impl::BufferInfo::BufferInfo()
305 : in_use(false), 303 : in_use(false),
306 data(NULL), 304 data(NULL),
307 buffer() { 305 buffer() {
308 } 306 }
309 307
310 PPB_VideoCapture_Impl::BufferInfo::~BufferInfo() { 308 PPB_VideoCapture_Impl::BufferInfo::~BufferInfo() {
311 } 309 }
312 310
313 } // namespace ppapi 311 } // namespace ppapi
314 } // namespace webkit 312 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/ppb_var_impl.cc ('k') | webkit/plugins/ppapi/quota_file_io.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698