summaryrefslogtreecommitdiffstats
path: root/ppapi/cpp/trusted
diff options
context:
space:
mode:
authorsehr@google.com <sehr@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-15 23:26:56 +0000
committersehr@google.com <sehr@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-15 23:26:56 +0000
commit6c8011ba4444175246f07a70db95806bdfbf3562 (patch)
treec1cbe947dd29368206919746313e172a284cc66c /ppapi/cpp/trusted
parente7c2e57b18604ee0b05c7203b8088f21a85710e8 (diff)
downloadchromium_src-6c8011ba4444175246f07a70db95806bdfbf3562.zip
chromium_src-6c8011ba4444175246f07a70db95806bdfbf3562.tar.gz
chromium_src-6c8011ba4444175246f07a70db95806bdfbf3562.tar.bz2
Add FileIOTrusted class.
BUG=none TEST=none Review URL: http://codereview.chromium.org/8965007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114720 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/cpp/trusted')
-rw-r--r--ppapi/cpp/trusted/file_io_trusted.cc54
-rw-r--r--ppapi/cpp/trusted/file_io_trusted.h36
2 files changed, 90 insertions, 0 deletions
diff --git a/ppapi/cpp/trusted/file_io_trusted.cc b/ppapi/cpp/trusted/file_io_trusted.cc
new file mode 100644
index 0000000..a3123ca
--- /dev/null
+++ b/ppapi/cpp/trusted/file_io_trusted.cc
@@ -0,0 +1,54 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ppapi/cpp/trusted/file_io_trusted.h"
+
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/c/trusted/ppb_file_io_trusted.h"
+#include "ppapi/cpp/completion_callback.h"
+#include "ppapi/cpp/file_io.h"
+#include "ppapi/cpp/module_impl.h"
+
+namespace pp {
+
+namespace {
+
+template <> const char* interface_name<PPB_FileIOTrusted>() {
+ return PPB_FILEIOTRUSTED_INTERFACE_0_4;
+}
+
+} // namespace
+
+FileIO_Trusted::FileIO_Trusted() {
+}
+
+int32_t FileIO_Trusted::GetOSFileDescriptor(const FileIO& file_io) {
+ const int32_t kInvalidOSFileDescriptor = -1;
+ if (!has_interface<PPB_FileIOTrusted>())
+ return kInvalidOSFileDescriptor;
+ return get_interface<PPB_FileIOTrusted>()->GetOSFileDescriptor(
+ file_io.pp_resource());
+}
+
+int32_t FileIO_Trusted::WillWrite(const FileIO& file_io,
+ int64_t offset,
+ int32_t bytes_to_write,
+ const CompletionCallback& callback) {
+ if (!has_interface<PPB_FileIOTrusted>())
+ return callback.MayForce(PP_ERROR_NOINTERFACE);
+ return get_interface<PPB_FileIOTrusted>()->WillWrite(
+ file_io.pp_resource(), offset, bytes_to_write,
+ callback.pp_completion_callback());
+}
+
+int32_t FileIO_Trusted::WillSetLength(const FileIO& file_io,
+ int64_t length,
+ const CompletionCallback& callback) {
+ if (!has_interface<PPB_FileIOTrusted>())
+ return callback.MayForce(PP_ERROR_NOINTERFACE);
+ return get_interface<PPB_FileIOTrusted>()->WillSetLength(
+ file_io.pp_resource(), length, callback.pp_completion_callback());
+}
+
+} // namespace pp
diff --git a/ppapi/cpp/trusted/file_io_trusted.h b/ppapi/cpp/trusted/file_io_trusted.h
new file mode 100644
index 0000000..3ba2140
--- /dev/null
+++ b/ppapi/cpp/trusted/file_io_trusted.h
@@ -0,0 +1,36 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef PPAPI_CPP_TRUSTED_FILE_IO_TRUSTED_H_
+#define PPAPI_CPP_TRUSTED_FILE_IO_TRUSTED_H_
+
+#include <string>
+
+#include "ppapi/c/pp_stdint.h"
+
+namespace pp {
+
+class FileIO;
+class CompletionCallback;
+
+class FileIO_Trusted {
+ public:
+ /// Creates a FileIO_Trusted object.
+ FileIO_Trusted();
+
+ int32_t GetOSFileDescriptor(const FileIO& file_io);
+
+ int32_t WillWrite(const FileIO& file_io,
+ int64_t offset,
+ int32_t bytes_to_write,
+ const CompletionCallback& callback);
+
+ int32_t WillSetLength(const FileIO& file_io,
+ int64_t length,
+ const CompletionCallback& callback);
+};
+
+} // namespace pp
+
+#endif // PPAPI_CPP_TRUSTED_FILE_IO_TRUSTED_H_