Whitelist window states to persist on ASH app windows.
[chromium-blink-merge.git] / ppapi / thunk / ppb_file_io_trusted_thunk.cc
blob3336026e8e487a0438990a4f36daeecfce7cb635
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.
5 #include "ppapi/c/pp_completion_callback.h"
6 #include "ppapi/c/pp_errors.h"
7 #include "ppapi/c/trusted/ppb_file_io_trusted.h"
8 #include "ppapi/shared_impl/tracked_callback.h"
9 #include "ppapi/thunk/enter.h"
10 #include "ppapi/thunk/thunk.h"
11 #include "ppapi/thunk/ppb_file_io_api.h"
12 #include "ppapi/thunk/resource_creation_api.h"
14 namespace ppapi {
15 namespace thunk {
17 namespace {
19 typedef EnterResource<PPB_FileIO_API> EnterFileIO;
21 int32_t GetOSFileDescriptor(PP_Resource file_io) {
22 EnterFileIO enter(file_io, true);
23 if (enter.failed())
24 return enter.retval();
25 return enter.object()->GetOSFileDescriptor();
28 int32_t WillWrite(PP_Resource file_io,
29 int64_t offset,
30 int32_t bytes_to_write,
31 PP_CompletionCallback callback) {
32 EnterFileIO enter(file_io, callback, true);
33 if (enter.failed())
34 return enter.retval();
35 return enter.SetResult(enter.object()->WillWrite(offset, bytes_to_write,
36 enter.callback()));
39 int32_t WillSetLength(PP_Resource file_io,
40 int64_t length,
41 PP_CompletionCallback callback) {
42 EnterFileIO enter(file_io, callback, true);
43 if (enter.failed())
44 return enter.retval();
45 return enter.SetResult(enter.object()->WillSetLength(length,
46 enter.callback()));
49 const PPB_FileIOTrusted g_ppb_file_io_trusted_thunk = {
50 &GetOSFileDescriptor,
51 &WillWrite,
52 &WillSetLength
55 } // namespace
57 const PPB_FileIOTrusted_0_4* GetPPB_FileIOTrusted_0_4_Thunk() {
58 return &g_ppb_file_io_trusted_thunk;
61 } // namespace thunk
62 } // namespace ppapi