Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(926)

Side by Side Diff: ppapi/thunk/ppb_file_io_trusted_thunk.cc

Issue 9113044: Convert to new enter method (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: PATCH DESCRIPTIONS ARE A STUPID WASTE OF TIME Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/thunk/ppb_file_io_thunk.cc ('k') | ppapi/thunk/ppb_file_ref_thunk.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/thunk/common.h"
9 #include "ppapi/thunk/enter.h" 8 #include "ppapi/thunk/enter.h"
10 #include "ppapi/thunk/thunk.h" 9 #include "ppapi/thunk/thunk.h"
11 #include "ppapi/thunk/ppb_file_io_api.h" 10 #include "ppapi/thunk/ppb_file_io_api.h"
12 #include "ppapi/thunk/resource_creation_api.h" 11 #include "ppapi/thunk/resource_creation_api.h"
13 12
14 namespace ppapi { 13 namespace ppapi {
15 namespace thunk { 14 namespace thunk {
16 15
17 namespace { 16 namespace {
18 17
18 typedef EnterResource<PPB_FileIO_API> EnterFileIO;
19
19 int32_t GetOSFileDescriptor(PP_Resource file_io) { 20 int32_t GetOSFileDescriptor(PP_Resource file_io) {
20 EnterResource<PPB_FileIO_API> enter(file_io, true); 21 EnterFileIO enter(file_io, true);
21 if (enter.failed()) 22 if (enter.failed())
22 return PP_ERROR_BADRESOURCE; 23 return enter.retval();
23 return enter.object()->GetOSFileDescriptor(); 24 return enter.SetResult(enter.object()->GetOSFileDescriptor());
24 } 25 }
25 26
26 int32_t WillWrite(PP_Resource file_io, 27 int32_t WillWrite(PP_Resource file_io,
27 int64_t offset, 28 int64_t offset,
28 int32_t bytes_to_write, 29 int32_t bytes_to_write,
29 PP_CompletionCallback callback) { 30 PP_CompletionCallback callback) {
30 EnterResource<PPB_FileIO_API> enter(file_io, true); 31 EnterFileIO enter(file_io, callback, true);
31 if (enter.failed()) 32 if (enter.failed())
32 return MayForceCallback(callback, PP_ERROR_BADRESOURCE); 33 return enter.retval();
33 int32_t result = enter.object()->WillWrite(offset, bytes_to_write, callback); 34 return enter.SetResult(enter.object()->WillWrite(offset, bytes_to_write,
34 return MayForceCallback(callback, result); 35 callback));
35 } 36 }
36 37
37 int32_t WillSetLength(PP_Resource file_io, 38 int32_t WillSetLength(PP_Resource file_io,
38 int64_t length, 39 int64_t length,
39 PP_CompletionCallback callback) { 40 PP_CompletionCallback callback) {
40 EnterResource<PPB_FileIO_API> enter(file_io, true); 41 EnterFileIO enter(file_io, callback, true);
41 if (enter.failed()) 42 if (enter.failed())
42 return MayForceCallback(callback, PP_ERROR_BADRESOURCE); 43 return enter.retval();
43 int32_t result = enter.object()->WillSetLength(length, callback); 44 return enter.SetResult(enter.object()->WillSetLength(length, callback));
44 return MayForceCallback(callback, result);
45 } 45 }
46 46
47 const PPB_FileIOTrusted g_ppb_file_io_trusted_thunk = { 47 const PPB_FileIOTrusted g_ppb_file_io_trusted_thunk = {
48 &GetOSFileDescriptor, 48 &GetOSFileDescriptor,
49 &WillWrite, 49 &WillWrite,
50 &WillSetLength 50 &WillSetLength
51 }; 51 };
52 52
53 } // namespace 53 } // namespace
54 54
55 const PPB_FileIOTrusted_0_4* GetPPB_FileIOTrusted_0_4_Thunk() { 55 const PPB_FileIOTrusted_0_4* GetPPB_FileIOTrusted_0_4_Thunk() {
56 return &g_ppb_file_io_trusted_thunk; 56 return &g_ppb_file_io_trusted_thunk;
57 } 57 }
58 58
59 } // namespace thunk 59 } // namespace thunk
60 } // namespace ppapi 60 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/thunk/ppb_file_io_thunk.cc ('k') | ppapi/thunk/ppb_file_ref_thunk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698