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

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

Issue 6899055: PPAPI: Force async callback invocation option. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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) 2011 The Chromium Authors. All rights reserved. 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 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/dev/ppb_file_io_trusted_dev.h" 5 #include "ppapi/c/dev/ppb_file_io_trusted_dev.h"
6 #include "ppapi/c/pp_completion_callback.h" 6 #include "ppapi/c/pp_completion_callback.h"
7 #include "ppapi/c/pp_errors.h" 7 #include "ppapi/c/pp_errors.h"
8 #include "ppapi/thunk/common.h"
9 #include "ppapi/thunk/enter.h"
8 #include "ppapi/thunk/thunk.h" 10 #include "ppapi/thunk/thunk.h"
9 #include "ppapi/thunk/enter.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 int32_t GetOSFileDescriptor(PP_Resource file_io) { 19 int32_t GetOSFileDescriptor(PP_Resource file_io) {
19 EnterResource<PPB_FileIO_API> enter(file_io, true); 20 EnterResource<PPB_FileIO_API> enter(file_io, true);
20 if (enter.failed()) 21 if (enter.failed())
21 return PP_ERROR_BADRESOURCE; 22 return PP_ERROR_BADRESOURCE;
22 return enter.object()->GetOSFileDescriptor(); 23 return enter.object()->GetOSFileDescriptor();
23 } 24 }
24 25
25 int32_t WillWrite(PP_Resource file_io, 26 int32_t WillWrite(PP_Resource file_io,
26 int64_t offset, 27 int64_t offset,
27 int32_t bytes_to_write, 28 int32_t bytes_to_write,
28 PP_CompletionCallback callback) { 29 PP_CompletionCallback callback) {
29 EnterResource<PPB_FileIO_API> enter(file_io, true); 30 EnterResource<PPB_FileIO_API> enter(file_io, true);
30 if (enter.failed()) 31 if (enter.failed())
31 return PP_ERROR_BADRESOURCE; 32 return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
32 return enter.object()->WillWrite(offset, bytes_to_write, callback); 33 int32_t result = enter.object()->WillWrite(offset, bytes_to_write, callback);
34 return MayForceCallback(callback, result);
33 } 35 }
34 36
35 int32_t WillSetLength(PP_Resource file_io, 37 int32_t WillSetLength(PP_Resource file_io,
36 int64_t length, 38 int64_t length,
37 PP_CompletionCallback callback) { 39 PP_CompletionCallback callback) {
38 EnterResource<PPB_FileIO_API> enter(file_io, true); 40 EnterResource<PPB_FileIO_API> enter(file_io, true);
39 if (enter.failed()) 41 if (enter.failed())
40 return PP_ERROR_BADRESOURCE; 42 return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
41 return enter.object()->WillSetLength(length, callback); 43 int32_t result = enter.object()->WillSetLength(length, callback);
44 return MayForceCallback(callback, result);
42 } 45 }
43 46
44 const PPB_FileIOTrusted_Dev g_ppb_file_io_trusted_thunk = { 47 const PPB_FileIOTrusted_Dev g_ppb_file_io_trusted_thunk = {
45 &GetOSFileDescriptor, 48 &GetOSFileDescriptor,
46 &WillWrite, 49 &WillWrite,
47 &WillSetLength 50 &WillSetLength
48 }; 51 };
49 52
50 } // namespace 53 } // namespace
51 54
52 const PPB_FileIOTrusted_Dev* GetPPB_FileIOTrusted_Thunk() { 55 const PPB_FileIOTrusted_Dev* GetPPB_FileIOTrusted_Thunk() {
53 return &g_ppb_file_io_trusted_thunk; 56 return &g_ppb_file_io_trusted_thunk;
54 } 57 }
55 58
56 } // namespace thunk 59 } // namespace thunk
57 } // 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