OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ppapi/c/pp_completion_callback.h" | 5 #include "ppapi/c/pp_completion_callback.h" |
6 #include "ppapi/c/pp_errors.h" | 6 #include "ppapi/c/pp_errors.h" |
7 #include "ppapi/c/trusted/ppb_file_io_trusted.h" | 7 #include "ppapi/c/trusted/ppb_file_io_trusted.h" |
| 8 #include "ppapi/shared_impl/tracked_callback.h" |
8 #include "ppapi/thunk/enter.h" | 9 #include "ppapi/thunk/enter.h" |
9 #include "ppapi/thunk/thunk.h" | 10 #include "ppapi/thunk/thunk.h" |
10 #include "ppapi/thunk/ppb_file_io_api.h" | 11 #include "ppapi/thunk/ppb_file_io_api.h" |
11 #include "ppapi/thunk/resource_creation_api.h" | 12 #include "ppapi/thunk/resource_creation_api.h" |
12 | 13 |
13 namespace ppapi { | 14 namespace ppapi { |
14 namespace thunk { | 15 namespace thunk { |
15 | 16 |
16 namespace { | 17 namespace { |
17 | 18 |
18 typedef EnterResource<PPB_FileIO_API> EnterFileIO; | 19 typedef EnterResource<PPB_FileIO_API> EnterFileIO; |
19 | 20 |
20 int32_t GetOSFileDescriptor(PP_Resource file_io) { | 21 int32_t GetOSFileDescriptor(PP_Resource file_io) { |
21 EnterFileIO enter(file_io, true); | 22 EnterFileIO enter(file_io, true); |
22 if (enter.failed()) | 23 if (enter.failed()) |
23 return enter.retval(); | 24 return enter.retval(); |
24 return enter.SetResult(enter.object()->GetOSFileDescriptor()); | 25 return enter.object()->GetOSFileDescriptor(); |
25 } | 26 } |
26 | 27 |
27 int32_t WillWrite(PP_Resource file_io, | 28 int32_t WillWrite(PP_Resource file_io, |
28 int64_t offset, | 29 int64_t offset, |
29 int32_t bytes_to_write, | 30 int32_t bytes_to_write, |
30 PP_CompletionCallback callback) { | 31 PP_CompletionCallback callback) { |
31 EnterFileIO enter(file_io, callback, true); | 32 EnterFileIO enter(file_io, callback, true); |
32 if (enter.failed()) | 33 if (enter.failed()) |
33 return enter.retval(); | 34 return enter.retval(); |
34 return enter.SetResult(enter.object()->WillWrite(offset, bytes_to_write, | 35 return enter.SetResult(enter.object()->WillWrite(offset, bytes_to_write, |
35 callback)); | 36 enter.callback())); |
36 } | 37 } |
37 | 38 |
38 int32_t WillSetLength(PP_Resource file_io, | 39 int32_t WillSetLength(PP_Resource file_io, |
39 int64_t length, | 40 int64_t length, |
40 PP_CompletionCallback callback) { | 41 PP_CompletionCallback callback) { |
41 EnterFileIO enter(file_io, callback, true); | 42 EnterFileIO enter(file_io, callback, true); |
42 if (enter.failed()) | 43 if (enter.failed()) |
43 return enter.retval(); | 44 return enter.retval(); |
44 return enter.SetResult(enter.object()->WillSetLength(length, callback)); | 45 return enter.SetResult(enter.object()->WillSetLength(length, |
| 46 enter.callback())); |
45 } | 47 } |
46 | 48 |
47 const PPB_FileIOTrusted g_ppb_file_io_trusted_thunk = { | 49 const PPB_FileIOTrusted g_ppb_file_io_trusted_thunk = { |
48 &GetOSFileDescriptor, | 50 &GetOSFileDescriptor, |
49 &WillWrite, | 51 &WillWrite, |
50 &WillSetLength | 52 &WillSetLength |
51 }; | 53 }; |
52 | 54 |
53 } // namespace | 55 } // namespace |
54 | 56 |
55 const PPB_FileIOTrusted_0_4* GetPPB_FileIOTrusted_0_4_Thunk() { | 57 const PPB_FileIOTrusted_0_4* GetPPB_FileIOTrusted_0_4_Thunk() { |
56 return &g_ppb_file_io_trusted_thunk; | 58 return &g_ppb_file_io_trusted_thunk; |
57 } | 59 } |
58 | 60 |
59 } // namespace thunk | 61 } // namespace thunk |
60 } // namespace ppapi | 62 } // namespace ppapi |
OLD | NEW |