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

Side by Side Diff: ppapi/thunk/ppb_file_io_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_chooser_thunk.cc ('k') | ppapi/thunk/ppb_file_io_trusted_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_dev.h" 5 #include "ppapi/c/dev/ppb_file_io_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 PP_Resource Create(PP_Instance instance) { 19 PP_Resource Create(PP_Instance instance) {
19 EnterFunction<ResourceCreationAPI> enter(instance, true); 20 EnterFunction<ResourceCreationAPI> enter(instance, true);
20 if (enter.failed()) 21 if (enter.failed())
21 return 0; 22 return 0;
22 return enter.functions()->CreateFileIO(instance); 23 return enter.functions()->CreateFileIO(instance);
23 } 24 }
24 25
25 PP_Bool IsFileIO(PP_Resource resource) { 26 PP_Bool IsFileIO(PP_Resource resource) {
26 EnterResource<PPB_FileIO_API> enter(resource, false); 27 EnterResource<PPB_FileIO_API> enter(resource, false);
27 return PP_FromBool(enter.succeeded()); 28 return PP_FromBool(enter.succeeded());
28 } 29 }
29 30
30 int32_t Open(PP_Resource file_io, 31 int32_t Open(PP_Resource file_io,
31 PP_Resource file_ref, 32 PP_Resource file_ref,
32 int32_t open_flags, 33 int32_t open_flags,
33 PP_CompletionCallback callback) { 34 PP_CompletionCallback callback) {
34 EnterResource<PPB_FileIO_API> enter(file_io, true); 35 EnterResource<PPB_FileIO_API> enter(file_io, true);
35 if (enter.failed()) 36 if (enter.failed())
36 return PP_ERROR_BADRESOURCE; 37 return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
37 return enter.object()->Open(file_ref, open_flags, callback); 38 int32_t result = enter.object()->Open(file_ref, open_flags, callback);
39 return MayForceCallback(callback, result);
38 } 40 }
39 41
40 int32_t Query(PP_Resource file_io, 42 int32_t Query(PP_Resource file_io,
41 PP_FileInfo_Dev* info, 43 PP_FileInfo_Dev* info,
42 PP_CompletionCallback callback) { 44 PP_CompletionCallback callback) {
43 EnterResource<PPB_FileIO_API> enter(file_io, true); 45 EnterResource<PPB_FileIO_API> enter(file_io, true);
44 if (enter.failed()) 46 if (enter.failed())
45 return PP_ERROR_BADRESOURCE; 47 return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
46 return enter.object()->Query(info, callback); 48 int32_t result = enter.object()->Query(info, callback);
49 return MayForceCallback(callback, result);
47 } 50 }
48 51
49 int32_t Touch(PP_Resource file_io, 52 int32_t Touch(PP_Resource file_io,
50 PP_Time last_access_time, 53 PP_Time last_access_time,
51 PP_Time last_modified_time, 54 PP_Time last_modified_time,
52 PP_CompletionCallback callback) { 55 PP_CompletionCallback callback) {
53 EnterResource<PPB_FileIO_API> enter(file_io, true); 56 EnterResource<PPB_FileIO_API> enter(file_io, true);
54 if (enter.failed()) 57 if (enter.failed())
55 return PP_ERROR_BADRESOURCE; 58 return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
56 return enter.object()->Touch(last_access_time, last_modified_time, callback); 59 int32_t result = enter.object()->Touch(last_access_time, last_modified_time,
60 callback);
61 return MayForceCallback(callback, result);
57 } 62 }
58 63
59 int32_t Read(PP_Resource file_io, 64 int32_t Read(PP_Resource file_io,
60 int64_t offset, 65 int64_t offset,
61 char* buffer, 66 char* buffer,
62 int32_t bytes_to_read, 67 int32_t bytes_to_read,
63 PP_CompletionCallback callback) { 68 PP_CompletionCallback callback) {
64 EnterResource<PPB_FileIO_API> enter(file_io, true); 69 EnterResource<PPB_FileIO_API> enter(file_io, true);
65 if (enter.failed()) 70 if (enter.failed())
66 return PP_ERROR_BADRESOURCE; 71 return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
67 return enter.object()->Read(offset, buffer, bytes_to_read, callback); 72 int32_t result = enter.object()->Read(offset, buffer, bytes_to_read,
73 callback);
74 return MayForceCallback(callback, result);
68 } 75 }
69 76
70 int32_t Write(PP_Resource file_io, 77 int32_t Write(PP_Resource file_io,
71 int64_t offset, 78 int64_t offset,
72 const char* buffer, 79 const char* buffer,
73 int32_t bytes_to_write, 80 int32_t bytes_to_write,
74 PP_CompletionCallback callback) { 81 PP_CompletionCallback callback) {
75 EnterResource<PPB_FileIO_API> enter(file_io, true); 82 EnterResource<PPB_FileIO_API> enter(file_io, true);
76 if (enter.failed()) 83 if (enter.failed())
77 return PP_ERROR_BADRESOURCE; 84 return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
78 return enter.object()->Write(offset, buffer, bytes_to_write, callback); 85 int32_t result = enter.object()->Write(offset, buffer, bytes_to_write,
86 callback);
87 return MayForceCallback(callback, result);
79 } 88 }
80 89
81 int32_t SetLength(PP_Resource file_io, 90 int32_t SetLength(PP_Resource file_io,
82 int64_t length, 91 int64_t length,
83 PP_CompletionCallback callback) { 92 PP_CompletionCallback callback) {
84 EnterResource<PPB_FileIO_API> enter(file_io, true); 93 EnterResource<PPB_FileIO_API> enter(file_io, true);
85 if (enter.failed()) 94 if (enter.failed())
86 return PP_ERROR_BADRESOURCE; 95 return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
87 return enter.object()->SetLength(length, callback); 96 int32_t result = enter.object()->SetLength(length, callback);
97 return MayForceCallback(callback, result);
88 } 98 }
89 99
90 int32_t Flush(PP_Resource file_io, 100 int32_t Flush(PP_Resource file_io,
91 PP_CompletionCallback callback) { 101 PP_CompletionCallback callback) {
92 EnterResource<PPB_FileIO_API> enter(file_io, true); 102 EnterResource<PPB_FileIO_API> enter(file_io, true);
93 if (enter.failed()) 103 if (enter.failed())
94 return PP_ERROR_BADRESOURCE; 104 return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
95 return enter.object()->Flush(callback); 105 int32_t result = enter.object()->Flush(callback);
106 return MayForceCallback(callback, result);
96 } 107 }
97 108
98 void Close(PP_Resource file_io) { 109 void Close(PP_Resource file_io) {
99 EnterResource<PPB_FileIO_API> enter(file_io, true); 110 EnterResource<PPB_FileIO_API> enter(file_io, true);
100 if (enter.succeeded()) 111 if (enter.succeeded())
101 enter.object()->Close(); 112 enter.object()->Close();
102 } 113 }
103 114
104 const PPB_FileIO_Dev g_ppb_file_io_thunk = { 115 const PPB_FileIO_Dev g_ppb_file_io_thunk = {
105 &Create, 116 &Create,
106 &IsFileIO, 117 &IsFileIO,
107 &Open, 118 &Open,
108 &Query, 119 &Query,
109 &Touch, 120 &Touch,
110 &Read, 121 &Read,
111 &Write, 122 &Write,
112 &SetLength, 123 &SetLength,
113 &Flush, 124 &Flush,
114 &Close 125 &Close
115 }; 126 };
116 127
117 } // namespace 128 } // namespace
118 129
119 const PPB_FileIO_Dev* GetPPB_FileIO_Thunk() { 130 const PPB_FileIO_Dev* GetPPB_FileIO_Thunk() {
120 return &g_ppb_file_io_thunk; 131 return &g_ppb_file_io_thunk;
121 } 132 }
122 133
123 } // namespace thunk 134 } // namespace thunk
124 } // namespace ppapi 135 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/thunk/ppb_file_chooser_thunk.cc ('k') | ppapi/thunk/ppb_file_io_trusted_thunk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698