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

Side by Side Diff: ppapi/thunk/ppb_url_loader_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_transport_thunk.cc ('k') | ppapi/thunk/ppb_video_decoder_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/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/thunk/common.h"
8 #include "ppapi/thunk/enter.h"
7 #include "ppapi/thunk/thunk.h" 9 #include "ppapi/thunk/thunk.h"
8 #include "ppapi/thunk/enter.h"
9 #include "ppapi/thunk/ppb_url_loader_api.h" 10 #include "ppapi/thunk/ppb_url_loader_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
17 PP_Resource Create(PP_Instance instance) { 18 PP_Resource Create(PP_Instance instance) {
18 EnterFunction<ResourceCreationAPI> enter(instance, true); 19 EnterFunction<ResourceCreationAPI> enter(instance, true);
19 if (enter.failed()) 20 if (enter.failed())
20 return 0; 21 return 0;
21 return enter.functions()->CreateURLLoader(instance); 22 return enter.functions()->CreateURLLoader(instance);
22 } 23 }
23 24
24 PP_Bool IsURLLoader(PP_Resource resource) { 25 PP_Bool IsURLLoader(PP_Resource resource) {
25 EnterResource<PPB_URLLoader_API> enter(resource, false); 26 EnterResource<PPB_URLLoader_API> enter(resource, false);
26 return PP_FromBool(enter.succeeded()); 27 return PP_FromBool(enter.succeeded());
27 } 28 }
28 29
29 int32_t Open(PP_Resource loader, 30 int32_t Open(PP_Resource loader,
30 PP_Resource request_id, 31 PP_Resource request_id,
31 PP_CompletionCallback callback) { 32 PP_CompletionCallback callback) {
32 EnterResource<PPB_URLLoader_API> enter(loader, true); 33 EnterResource<PPB_URLLoader_API> enter(loader, true);
33 if (enter.failed()) 34 if (enter.failed())
34 return PP_ERROR_BADRESOURCE; 35 return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
35 return enter.object()->Open(request_id, callback); 36 int32_t result = enter.object()->Open(request_id, callback);
37 return MayForceCallback(callback, result);
36 } 38 }
37 39
38 int32_t FollowRedirect(PP_Resource loader, 40 int32_t FollowRedirect(PP_Resource loader,
39 PP_CompletionCallback callback) { 41 PP_CompletionCallback callback) {
40 EnterResource<PPB_URLLoader_API> enter(loader, true); 42 EnterResource<PPB_URLLoader_API> enter(loader, true);
41 if (enter.failed()) 43 if (enter.failed())
42 return PP_ERROR_BADRESOURCE; 44 return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
43 return enter.object()->FollowRedirect(callback); 45 int32_t result = enter.object()->FollowRedirect(callback);
46 return MayForceCallback(callback, result);
44 } 47 }
45 48
46 PP_Bool GetUploadProgress(PP_Resource loader, 49 PP_Bool GetUploadProgress(PP_Resource loader,
47 int64_t* bytes_sent, 50 int64_t* bytes_sent,
48 int64_t* total_bytes_to_be_sent) { 51 int64_t* total_bytes_to_be_sent) {
49 EnterResource<PPB_URLLoader_API> enter(loader, true); 52 EnterResource<PPB_URLLoader_API> enter(loader, true);
50 if (enter.failed()) { 53 if (enter.failed()) {
51 *bytes_sent = 0; 54 *bytes_sent = 0;
52 *total_bytes_to_be_sent = 0; 55 *total_bytes_to_be_sent = 0;
53 return PP_FALSE; 56 return PP_FALSE;
(...skipping 21 matching lines...) Expand all
75 return 0; 78 return 0;
76 return enter.object()->GetResponseInfo(); 79 return enter.object()->GetResponseInfo();
77 } 80 }
78 81
79 int32_t ReadResponseBody(PP_Resource loader, 82 int32_t ReadResponseBody(PP_Resource loader,
80 void* buffer, 83 void* buffer,
81 int32_t bytes_to_read, 84 int32_t bytes_to_read,
82 PP_CompletionCallback callback) { 85 PP_CompletionCallback callback) {
83 EnterResource<PPB_URLLoader_API> enter(loader, true); 86 EnterResource<PPB_URLLoader_API> enter(loader, true);
84 if (enter.failed()) 87 if (enter.failed())
85 return PP_ERROR_BADRESOURCE; 88 return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
86 return enter.object()->ReadResponseBody(buffer, bytes_to_read, callback); 89 int32_t result = enter.object()->ReadResponseBody(buffer, bytes_to_read,
90 callback);
91 return MayForceCallback(callback, result);
87 } 92 }
88 93
89 int32_t FinishStreamingToFile(PP_Resource loader, 94 int32_t FinishStreamingToFile(PP_Resource loader,
90 PP_CompletionCallback callback) { 95 PP_CompletionCallback callback) {
91 EnterResource<PPB_URLLoader_API> enter(loader, true); 96 EnterResource<PPB_URLLoader_API> enter(loader, true);
92 if (enter.failed()) 97 if (enter.failed())
93 return PP_ERROR_BADRESOURCE; 98 return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
94 return enter.object()->FinishStreamingToFile(callback); 99 int32_t result = enter.object()->FinishStreamingToFile(callback);
100 return MayForceCallback(callback, result);
95 } 101 }
96 102
97 void Close(PP_Resource loader) { 103 void Close(PP_Resource loader) {
98 EnterResource<PPB_URLLoader_API> enter(loader, true); 104 EnterResource<PPB_URLLoader_API> enter(loader, true);
99 if (enter.succeeded()) 105 if (enter.succeeded())
100 enter.object()->Close(); 106 enter.object()->Close();
101 } 107 }
102 108
103 void GrantUniversalAccess(PP_Resource loader) { 109 void GrantUniversalAccess(PP_Resource loader) {
104 EnterResource<PPB_URLLoader_API> enter(loader, true); 110 EnterResource<PPB_URLLoader_API> enter(loader, true);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 const PPB_URLLoader* GetPPB_URLLoader_Thunk() { 142 const PPB_URLLoader* GetPPB_URLLoader_Thunk() {
137 return &g_ppb_urlloader_thunk; 143 return &g_ppb_urlloader_thunk;
138 } 144 }
139 145
140 const PPB_URLLoaderTrusted* GetPPB_URLLoaderTrusted_Thunk() { 146 const PPB_URLLoaderTrusted* GetPPB_URLLoaderTrusted_Thunk() {
141 return &g_ppb_urlloader_trusted_thunk; 147 return &g_ppb_urlloader_trusted_thunk;
142 } 148 }
143 149
144 } // namespace thunk 150 } // namespace thunk
145 } // namespace ppapi 151 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/thunk/ppb_transport_thunk.cc ('k') | ppapi/thunk/ppb_video_decoder_thunk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698