Pepper_47_C++_interfaces
file_io_trusted.cc
Go to the documentation of this file.
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
3 // found in the LICENSE file.
4 
6 
7 #include "ppapi/c/pp_errors.h"
8 #include "ppapi/c/trusted/ppb_file_io_trusted.h"
10 #include "ppapi/cpp/file_io.h"
11 #include "ppapi/cpp/module_impl.h"
12 
13 namespace pp {
14 
15 namespace {
16 
17 template <> const char* interface_name<PPB_FileIOTrusted>() {
18  return PPB_FILEIOTRUSTED_INTERFACE_0_4;
19 }
20 
21 } // namespace
22 
24 }
25 
27  const int32_t kInvalidOSFileDescriptor = -1;
28  if (!has_interface<PPB_FileIOTrusted>())
29  return kInvalidOSFileDescriptor;
30  return get_interface<PPB_FileIOTrusted>()->GetOSFileDescriptor(
31  file_io.pp_resource());
32 }
33 
35  int64_t offset,
36  int32_t bytes_to_write,
37  const CompletionCallback& callback) {
38  if (!has_interface<PPB_FileIOTrusted>())
39  return callback.MayForce(PP_ERROR_NOINTERFACE);
40  return get_interface<PPB_FileIOTrusted>()->WillWrite(
41  file_io.pp_resource(), offset, bytes_to_write,
42  callback.pp_completion_callback());
43 }
44 
46  int64_t length,
47  const CompletionCallback& callback) {
48  if (!has_interface<PPB_FileIOTrusted>())
49  return callback.MayForce(PP_ERROR_NOINTERFACE);
50  return get_interface<PPB_FileIOTrusted>()->WillSetLength(
51  file_io.pp_resource(), length, callback.pp_completion_callback());
52 }
53 
54 } // namespace pp
int32_t GetOSFileDescriptor(const FileIO &file_io)
FileIO_Trusted()
Creates a FileIO_Trusted object.
The FileIO class represents a regular file.
Definition: file_io.h:23
int32_t MayForce(int32_t result) const
const PP_CompletionCallback & pp_completion_callback() const
int32_t WillWrite(const FileIO &file_io, int64_t offset, int32_t bytes_to_write, const CompletionCallback &callback)
PP_Resource pp_resource() const
Definition: resource.h:47
int32_t WillSetLength(const FileIO &file_io, int64_t length, const CompletionCallback &callback)