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

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

Issue 9651002: Add C++ wrappers for output parameters. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ppapi/cpp/array_output.h"
6
7 #include "ppapi/cpp/logging.h"
8
9 namespace pp {
10
11 // static
12 void* ArrayOutputAdapterBase::GetDataBufferThunk(void* user_data,
13 uint32_t element_count,
14 uint32_t element_size) {
15 return static_cast<ArrayOutputAdapterBase*>(user_data)->
16 GetDataBuffer(element_count, element_size);
17 }
18
19 VarArrayOutputAdapterWithStorage::VarArrayOutputAdapterWithStorage()
20 : ArrayOutputAdapter<PP_Var>() {
21 set_output(&temp_storage_);
22 }
23
24 VarArrayOutputAdapterWithStorage::VarArrayOutputAdapterWithStorage(
25 const VarArrayOutputAdapterWithStorage& other)
26 : ArrayOutputAdapter<PP_Var>() {
27 // We can't actually make copies of this adapter once it's been used. But
28 // we need to support copying before it's been used because the completion
29 // callback factory uses this. So ensure that we're empty.
dmichael (off chromium) 2012/03/09 18:23:27 Ah. A comment of explanation in the header or a re
30 PP_DCHECK(other.temp_storage_.empty());
31 set_output(&temp_storage_);
32 }
33
34 VarArrayOutputAdapterWithStorage&
35 VarArrayOutputAdapterWithStorage::operator=(
36 const VarArrayOutputAdapterWithStorage& other) {
37 set_output(&temp_storage_);
38 return *this;
39 }
40
41 std::vector<Var>& VarArrayOutputAdapterWithStorage::output() {
42 PP_DCHECK(output_storage_.empty());
43
44 output_storage_.reserve(temp_storage_.size());
45 for (size_t i = 0; i < temp_storage_.size(); i++)
46 output_storage_.push_back(Var(PASS_REF, temp_storage_[i]));
47 temp_storage_.clear();
48 return output_storage_;
49 }
50
51 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698