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

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

Issue 10081020: PPAPI: Make blocking completion callbacks work. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated TestURLLoader to test blocking callbacks. Created 8 years, 8 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
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/enter.h" 8 #include "ppapi/thunk/enter.h"
9 #include "ppapi/thunk/thunk.h" 9 #include "ppapi/thunk/thunk.h"
10 #include "ppapi/thunk/ppb_file_io_api.h" 10 #include "ppapi/thunk/ppb_file_io_api.h"
11 #include "ppapi/thunk/resource_creation_api.h" 11 #include "ppapi/thunk/resource_creation_api.h"
12 12
13 namespace ppapi { 13 namespace ppapi {
14 namespace thunk { 14 namespace thunk {
15 15
16 namespace { 16 namespace {
17 17
18 typedef EnterResource<PPB_FileIO_API> EnterFileIO; 18 typedef EnterResource<PPB_FileIO_API> EnterFileIO;
19 19
20 int32_t GetOSFileDescriptor(PP_Resource file_io) { 20 int32_t GetOSFileDescriptor(PP_Resource file_io) {
21 EnterFileIO enter(file_io, true); 21 EnterFileIO enter(file_io, true);
22 if (enter.failed()) 22 if (enter.failed())
23 return enter.retval(); 23 return enter.retval();
24 return enter.SetResult(enter.object()->GetOSFileDescriptor()); 24 return enter.object()->GetOSFileDescriptor();
dmichael (off chromium) 2012/04/19 20:02:00 With no callback, it doesn't make sense to call Se
25 } 25 }
26 26
27 int32_t WillWrite(PP_Resource file_io, 27 int32_t WillWrite(PP_Resource file_io,
28 int64_t offset, 28 int64_t offset,
29 int32_t bytes_to_write, 29 int32_t bytes_to_write,
30 PP_CompletionCallback callback) { 30 PP_CompletionCallback callback) {
31 EnterFileIO enter(file_io, callback, true); 31 EnterFileIO enter(file_io, callback, true);
32 if (enter.failed()) 32 if (enter.failed())
33 return enter.retval(); 33 return enter.retval();
34 return enter.SetResult(enter.object()->WillWrite(offset, bytes_to_write, 34 return enter.SetResult(enter.object()->WillWrite(offset, bytes_to_write,
35 callback)); 35 enter.callback()));
36 } 36 }
37 37
38 int32_t WillSetLength(PP_Resource file_io, 38 int32_t WillSetLength(PP_Resource file_io,
39 int64_t length, 39 int64_t length,
40 PP_CompletionCallback callback) { 40 PP_CompletionCallback callback) {
41 EnterFileIO enter(file_io, callback, true); 41 EnterFileIO enter(file_io, callback, true);
42 if (enter.failed()) 42 if (enter.failed())
43 return enter.retval(); 43 return enter.retval();
44 return enter.SetResult(enter.object()->WillSetLength(length, callback)); 44 return enter.SetResult(enter.object()->WillSetLength(length,
45 enter.callback()));
45 } 46 }
46 47
47 const PPB_FileIOTrusted g_ppb_file_io_trusted_thunk = { 48 const PPB_FileIOTrusted g_ppb_file_io_trusted_thunk = {
48 &GetOSFileDescriptor, 49 &GetOSFileDescriptor,
49 &WillWrite, 50 &WillWrite,
50 &WillSetLength 51 &WillSetLength
51 }; 52 };
52 53
53 } // namespace 54 } // namespace
54 55
55 const PPB_FileIOTrusted_0_4* GetPPB_FileIOTrusted_0_4_Thunk() { 56 const PPB_FileIOTrusted_0_4* GetPPB_FileIOTrusted_0_4_Thunk() {
56 return &g_ppb_file_io_trusted_thunk; 57 return &g_ppb_file_io_trusted_thunk;
57 } 58 }
58 59
59 } // namespace thunk 60 } // namespace thunk
60 } // namespace ppapi 61 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698