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

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

Issue 10081020: PPAPI: Make blocking completion callbacks work. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: export AssertLockHeld Created 8 years, 6 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_api.h ('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) 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/shared_impl/tracked_callback.h"
7 #include "ppapi/thunk/enter.h" 8 #include "ppapi/thunk/enter.h"
8 #include "ppapi/thunk/thunk.h" 9 #include "ppapi/thunk/thunk.h"
9 #include "ppapi/thunk/ppb_file_io_api.h" 10 #include "ppapi/thunk/ppb_file_io_api.h"
10 #include "ppapi/thunk/resource_creation_api.h" 11 #include "ppapi/thunk/resource_creation_api.h"
11 12
12 namespace ppapi { 13 namespace ppapi {
13 namespace thunk { 14 namespace thunk {
14 15
15 namespace { 16 namespace {
16 17
(...skipping 11 matching lines...) Expand all
28 return PP_FromBool(enter.succeeded()); 29 return PP_FromBool(enter.succeeded());
29 } 30 }
30 31
31 int32_t Open(PP_Resource file_io, 32 int32_t Open(PP_Resource file_io,
32 PP_Resource file_ref, 33 PP_Resource file_ref,
33 int32_t open_flags, 34 int32_t open_flags,
34 PP_CompletionCallback callback) { 35 PP_CompletionCallback callback) {
35 EnterFileIO enter(file_io, callback, true); 36 EnterFileIO enter(file_io, callback, true);
36 if (enter.failed()) 37 if (enter.failed())
37 return enter.retval(); 38 return enter.retval();
38 return enter.SetResult(enter.object()->Open(file_ref, open_flags, callback)); 39 return enter.SetResult(enter.object()->Open(file_ref, open_flags,
40 enter.callback()));
39 } 41 }
40 42
41 int32_t Query(PP_Resource file_io, 43 int32_t Query(PP_Resource file_io,
42 PP_FileInfo* info, 44 PP_FileInfo* info,
43 PP_CompletionCallback callback) { 45 PP_CompletionCallback callback) {
44 EnterFileIO enter(file_io, callback, true); 46 EnterFileIO enter(file_io, callback, true);
45 if (enter.failed()) 47 if (enter.failed())
46 return enter.retval(); 48 return enter.retval();
47 return enter.SetResult(enter.object()->Query(info, callback)); 49 return enter.SetResult(enter.object()->Query(info, enter.callback()));
48 } 50 }
49 51
50 int32_t Touch(PP_Resource file_io, 52 int32_t Touch(PP_Resource file_io,
51 PP_Time last_access_time, 53 PP_Time last_access_time,
52 PP_Time last_modified_time, 54 PP_Time last_modified_time,
53 PP_CompletionCallback callback) { 55 PP_CompletionCallback callback) {
54 EnterFileIO enter(file_io, callback, true); 56 EnterFileIO enter(file_io, callback, true);
55 if (enter.failed()) 57 if (enter.failed())
56 return enter.retval(); 58 return enter.retval();
57 return enter.SetResult(enter.object()->Touch( 59 return enter.SetResult(enter.object()->Touch(
58 last_access_time, last_modified_time, callback)); 60 last_access_time, last_modified_time, enter.callback()));
59 } 61 }
60 62
61 int32_t Read(PP_Resource file_io, 63 int32_t Read(PP_Resource file_io,
62 int64_t offset, 64 int64_t offset,
63 char* buffer, 65 char* buffer,
64 int32_t bytes_to_read, 66 int32_t bytes_to_read,
65 PP_CompletionCallback callback) { 67 PP_CompletionCallback callback) {
66 EnterFileIO enter(file_io, callback, true); 68 EnterFileIO enter(file_io, callback, true);
67 if (enter.failed()) 69 if (enter.failed())
68 return enter.retval(); 70 return enter.retval();
69 return enter.SetResult(enter.object()->Read(offset, buffer, bytes_to_read, 71 return enter.SetResult(enter.object()->Read(offset, buffer, bytes_to_read,
70 callback)); 72 enter.callback()));
71 } 73 }
72 74
73 int32_t Write(PP_Resource file_io, 75 int32_t Write(PP_Resource file_io,
74 int64_t offset, 76 int64_t offset,
75 const char* buffer, 77 const char* buffer,
76 int32_t bytes_to_write, 78 int32_t bytes_to_write,
77 PP_CompletionCallback callback) { 79 PP_CompletionCallback callback) {
78 EnterFileIO enter(file_io, callback, true); 80 EnterFileIO enter(file_io, callback, true);
79 if (enter.failed()) 81 if (enter.failed())
80 return enter.retval(); 82 return enter.retval();
81 return enter.SetResult(enter.object()->Write(offset, buffer, bytes_to_write, 83 return enter.SetResult(enter.object()->Write(offset, buffer, bytes_to_write,
82 callback)); 84 enter.callback()));
83 } 85 }
84 86
85 int32_t SetLength(PP_Resource file_io, 87 int32_t SetLength(PP_Resource file_io,
86 int64_t length, 88 int64_t length,
87 PP_CompletionCallback callback) { 89 PP_CompletionCallback callback) {
88 EnterFileIO enter(file_io, callback, true); 90 EnterFileIO enter(file_io, callback, true);
89 if (enter.failed()) 91 if (enter.failed())
90 return enter.retval(); 92 return enter.retval();
91 return enter.SetResult(enter.object()->SetLength(length, callback)); 93 return enter.SetResult(enter.object()->SetLength(length, enter.callback()));
92 } 94 }
93 95
94 int32_t Flush(PP_Resource file_io, 96 int32_t Flush(PP_Resource file_io,
95 PP_CompletionCallback callback) { 97 PP_CompletionCallback callback) {
96 EnterFileIO enter(file_io, callback, true); 98 EnterFileIO enter(file_io, callback, true);
97 if (enter.failed()) 99 if (enter.failed())
98 return enter.retval(); 100 return enter.retval();
99 return enter.SetResult(enter.object()->Flush(callback)); 101 return enter.SetResult(enter.object()->Flush(enter.callback()));
100 } 102 }
101 103
102 void Close(PP_Resource file_io) { 104 void Close(PP_Resource file_io) {
103 EnterFileIO enter(file_io, true); 105 EnterFileIO enter(file_io, true);
104 if (enter.succeeded()) 106 if (enter.succeeded())
105 enter.object()->Close(); 107 enter.object()->Close();
106 } 108 }
107 109
108 const PPB_FileIO g_ppb_file_io_thunk = { 110 const PPB_FileIO g_ppb_file_io_thunk = {
109 &Create, 111 &Create,
110 &IsFileIO, 112 &IsFileIO,
111 &Open, 113 &Open,
112 &Query, 114 &Query,
113 &Touch, 115 &Touch,
114 &Read, 116 &Read,
115 &Write, 117 &Write,
116 &SetLength, 118 &SetLength,
117 &Flush, 119 &Flush,
118 &Close 120 &Close
119 }; 121 };
120 122
121 } // namespace 123 } // namespace
122 124
123 const PPB_FileIO_1_0* GetPPB_FileIO_1_0_Thunk() { 125 const PPB_FileIO_1_0* GetPPB_FileIO_1_0_Thunk() {
124 return &g_ppb_file_io_thunk; 126 return &g_ppb_file_io_thunk;
125 } 127 }
126 128
127 } // namespace thunk 129 } // namespace thunk
128 } // namespace ppapi 130 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/thunk/ppb_file_io_api.h ('k') | ppapi/thunk/ppb_file_io_trusted_thunk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698