Pepper_47_C++_interfaces
directory_entry.cc
Go to the documentation of this file.
1 // Copyright (c) 2010 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 
6 
7 #include <string.h>
8 
9 #include "ppapi/cpp/logging.h"
10 #include "ppapi/cpp/module.h"
11 
12 namespace pp {
13 
15  memset(&data_, 0, sizeof(data_));
16 }
17 
19  PassRef, const PP_DirectoryEntry& data) {
20  data_.file_ref = data.file_ref;
21  data_.file_type = data.file_type;
22 }
23 
25  data_.file_ref = other.data_.file_ref;
26  data_.file_type = other.data_.file_type;
27  if (data_.file_ref)
28  Module::Get()->core()->AddRefResource(data_.file_ref);
29 }
30 
32  if (data_.file_ref)
33  Module::Get()->core()->ReleaseResource(data_.file_ref);
34 }
35 
37  const DirectoryEntry& other) {
38  if (data_.file_ref)
39  Module::Get()->core()->ReleaseResource(data_.file_ref);
40  data_ = other.data_;
41  if (data_.file_ref)
42  Module::Get()->core()->AddRefResource(data_.file_ref);
43  return *this;
44 }
45 
46 namespace internal {
47 
50  set_output(&temp_storage_);
51 }
52 
55  if (!temp_storage_.empty()) {
56  // An easy way to release the resource references held by |temp_storage_|.
57  // A destructor for PP_DirectoryEntry will release them.
58  output();
59  }
60 }
61 
62 std::vector<DirectoryEntry>&
64  PP_DCHECK(output_storage_.empty());
65  typedef std::vector<PP_DirectoryEntry> Entries;
66  for (Entries::iterator it = temp_storage_.begin();
67  it != temp_storage_.end();
68  ++it) {
69  output_storage_.push_back(DirectoryEntry(PASS_REF, *it));
70  }
71  temp_storage_.clear();
72  return output_storage_;
73 }
74 
75 } // namespace internal
76 } // namespace pp
virtual ~DirectoryEntryArrayOutputAdapterWithStorage()
void AddRefResource(PP_Resource resource)
Definition: core.h:31
~DirectoryEntry()
DirectoryEntry()
Core * core()
Definition: module.h:74
#define PP_DCHECK(a)
Definition: logging.h:16
void ReleaseResource(PP_Resource resource)
Definition: core.h:41
void set_output(std::vector< PP_DirectoryEntry > *output)
Definition: array_output.h:91
std::vector< DirectoryEntry > & output()
PassRef
Definition: pass_ref.h:17
static Module * Get()
DirectoryEntry & operator=(const DirectoryEntry &other)
DirectoryEntryArrayOutputAdapterWithStorage()