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

Side by Side Diff: ppapi/cpp/array_output.cc

Issue 9965080: Change the cpp wrappers of audio input/video capture to use CompletionCallbackWithOutput. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More changes in response to Brett's comments. Created 8 years, 8 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 | « ppapi/cpp/array_output.h ('k') | ppapi/cpp/dev/audio_input_dev.h » ('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 (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 "ppapi/cpp/array_output.h" 5 #include "ppapi/cpp/array_output.h"
6 6
7 #include "ppapi/cpp/logging.h" 7 #include "ppapi/cpp/logging.h"
8 8
9 namespace pp { 9 namespace pp {
10 10
11 // static 11 // static
12 void* ArrayOutputAdapterBase::GetDataBufferThunk(void* user_data, 12 void* ArrayOutputAdapterBase::GetDataBufferThunk(void* user_data,
13 uint32_t element_count, 13 uint32_t element_count,
14 uint32_t element_size) { 14 uint32_t element_size) {
15 return static_cast<ArrayOutputAdapterBase*>(user_data)-> 15 return static_cast<ArrayOutputAdapterBase*>(user_data)->
16 GetDataBuffer(element_count, element_size); 16 GetDataBuffer(element_count, element_size);
17 } 17 }
18 18
19 VarArrayOutputAdapterWithStorage::VarArrayOutputAdapterWithStorage() 19 VarArrayOutputAdapterWithStorage::VarArrayOutputAdapterWithStorage()
20 : ArrayOutputAdapter<PP_Var>() { 20 : ArrayOutputAdapter<PP_Var>() {
21 set_output(&temp_storage_); 21 set_output(&temp_storage_);
22 } 22 }
23 23
24 VarArrayOutputAdapterWithStorage::~VarArrayOutputAdapterWithStorage() {
25 if (!temp_storage_.empty()) {
26 // An easy way to release the var references held by this object.
27 output();
28 }
29 }
30
24 std::vector<Var>& VarArrayOutputAdapterWithStorage::output() { 31 std::vector<Var>& VarArrayOutputAdapterWithStorage::output() {
25 PP_DCHECK(output_storage_.empty()); 32 PP_DCHECK(output_storage_.empty());
26 33
27 output_storage_.reserve(temp_storage_.size()); 34 output_storage_.reserve(temp_storage_.size());
28 for (size_t i = 0; i < temp_storage_.size(); i++) 35 for (size_t i = 0; i < temp_storage_.size(); i++)
29 output_storage_.push_back(Var(PASS_REF, temp_storage_[i])); 36 output_storage_.push_back(Var(PASS_REF, temp_storage_[i]));
30 temp_storage_.clear(); 37 temp_storage_.clear();
31 return output_storage_; 38 return output_storage_;
32 } 39 }
33 40
34 } // namespace pp 41 } // namespace pp
OLDNEW
« no previous file with comments | « ppapi/cpp/array_output.h ('k') | ppapi/cpp/dev/audio_input_dev.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698