| OLD | NEW |
| 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/shared_impl/tracked_callback.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_url_loader_api.h" | 10 #include "ppapi/thunk/ppb_url_loader_api.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 void* buffer, | 83 void* buffer, |
| 84 int32_t bytes_to_read, | 84 int32_t bytes_to_read, |
| 85 PP_CompletionCallback callback) { | 85 PP_CompletionCallback callback) { |
| 86 EnterURLLoader enter(loader, callback, true); | 86 EnterURLLoader enter(loader, callback, true); |
| 87 if (enter.failed()) | 87 if (enter.failed()) |
| 88 return enter.retval(); | 88 return enter.retval(); |
| 89 return enter.SetResult(enter.object()->ReadResponseBody(buffer, bytes_to_read, | 89 return enter.SetResult(enter.object()->ReadResponseBody(buffer, bytes_to_read, |
| 90 enter.callback())); | 90 enter.callback())); |
| 91 } | 91 } |
| 92 | 92 |
| 93 int32_t ReadResponseBodyToArray(PP_Resource loader, |
| 94 int32_t max_read_length, |
| 95 PP_ArrayOutput* buffer, |
| 96 PP_CompletionCallback callback) { |
| 97 EnterURLLoader enter(loader, callback, true); |
| 98 if (enter.failed()) |
| 99 return enter.retval(); |
| 100 return enter.SetResult(enter.object()->ReadResponseBodyToArray( |
| 101 max_read_length, buffer, enter.callback())); |
| 102 } |
| 103 |
| 93 int32_t FinishStreamingToFile(PP_Resource loader, | 104 int32_t FinishStreamingToFile(PP_Resource loader, |
| 94 PP_CompletionCallback callback) { | 105 PP_CompletionCallback callback) { |
| 95 EnterURLLoader enter(loader, callback, true); | 106 EnterURLLoader enter(loader, callback, true); |
| 96 if (enter.failed()) | 107 if (enter.failed()) |
| 97 return enter.retval(); | 108 return enter.retval(); |
| 98 return enter.SetResult( | 109 return enter.SetResult( |
| 99 enter.object()->FinishStreamingToFile(enter.callback())); | 110 enter.object()->FinishStreamingToFile(enter.callback())); |
| 100 } | 111 } |
| 101 | 112 |
| 102 void Close(PP_Resource loader) { | 113 void Close(PP_Resource loader) { |
| 103 EnterURLLoader enter(loader, true); | 114 EnterURLLoader enter(loader, true); |
| 104 if (enter.succeeded()) | 115 if (enter.succeeded()) |
| 105 enter.object()->Close(); | 116 enter.object()->Close(); |
| 106 } | 117 } |
| 107 | 118 |
| 108 void GrantUniversalAccess(PP_Resource loader) { | 119 void GrantUniversalAccess(PP_Resource loader) { |
| 109 EnterURLLoader enter(loader, true); | 120 EnterURLLoader enter(loader, true); |
| 110 if (enter.succeeded()) | 121 if (enter.succeeded()) |
| 111 enter.object()->GrantUniversalAccess(); | 122 enter.object()->GrantUniversalAccess(); |
| 112 } | 123 } |
| 113 | 124 |
| 114 void SetStatusCallback(PP_Resource loader, | 125 void SetStatusCallback(PP_Resource loader, |
| 115 PP_URLLoaderTrusted_StatusCallback cb) { | 126 PP_URLLoaderTrusted_StatusCallback cb) { |
| 116 EnterURLLoader enter(loader, true); | 127 EnterURLLoader enter(loader, true); |
| 117 if (enter.succeeded()) | 128 if (enter.succeeded()) |
| 118 enter.object()->SetStatusCallback(cb); | 129 enter.object()->SetStatusCallback(cb); |
| 119 } | 130 } |
| 120 | 131 |
| 121 const PPB_URLLoader g_ppb_urlloader_thunk = { | 132 const PPB_URLLoader_1_1 g_ppb_urlloader_thunk = { |
| 122 &Create, | 133 &Create, |
| 123 &IsURLLoader, | 134 &IsURLLoader, |
| 124 &Open, | 135 &Open, |
| 136 &FollowRedirect, |
| 137 &GetUploadProgress, |
| 138 &GetDownloadProgress, |
| 139 &GetResponseInfo, |
| 140 &ReadResponseBody, |
| 141 &FinishStreamingToFile, |
| 142 &Close, |
| 143 &ReadResponseBodyToArray |
| 144 }; |
| 145 |
| 146 const PPB_URLLoader_1_0 g_ppb_urlloader_thunk_1_0 = { |
| 147 &Create, |
| 148 &IsURLLoader, |
| 149 &Open, |
| 125 &FollowRedirect, | 150 &FollowRedirect, |
| 126 &GetUploadProgress, | 151 &GetUploadProgress, |
| 127 &GetDownloadProgress, | 152 &GetDownloadProgress, |
| 128 &GetResponseInfo, | 153 &GetResponseInfo, |
| 129 &ReadResponseBody, | 154 &ReadResponseBody, |
| 130 &FinishStreamingToFile, | 155 &FinishStreamingToFile, |
| 131 &Close | 156 &Close |
| 132 }; | 157 }; |
| 133 | 158 |
| 134 const PPB_URLLoaderTrusted g_ppb_urlloader_trusted_thunk = { | 159 const PPB_URLLoaderTrusted g_ppb_urlloader_trusted_thunk = { |
| 135 &GrantUniversalAccess, | 160 &GrantUniversalAccess, |
| 136 &SetStatusCallback | 161 &SetStatusCallback |
| 137 }; | 162 }; |
| 138 | 163 |
| 139 } // namespace | 164 } // namespace |
| 140 | 165 |
| 166 const PPB_URLLoader_1_1* GetPPB_URLLoader_1_1_Thunk() { |
| 167 return &g_ppb_urlloader_thunk; |
| 168 } |
| 169 |
| 141 const PPB_URLLoader_1_0* GetPPB_URLLoader_1_0_Thunk() { | 170 const PPB_URLLoader_1_0* GetPPB_URLLoader_1_0_Thunk() { |
| 142 return &g_ppb_urlloader_thunk; | 171 return &g_ppb_urlloader_thunk_1_0; |
| 143 } | 172 } |
| 144 | 173 |
| 145 const PPB_URLLoaderTrusted_0_3* GetPPB_URLLoaderTrusted_0_3_Thunk() { | 174 const PPB_URLLoaderTrusted_0_3* GetPPB_URLLoaderTrusted_0_3_Thunk() { |
| 146 return &g_ppb_urlloader_trusted_thunk; | 175 return &g_ppb_urlloader_trusted_thunk; |
| 147 } | 176 } |
| 148 | 177 |
| 149 } // namespace thunk | 178 } // namespace thunk |
| 150 } // namespace ppapi | 179 } // namespace ppapi |
| OLD | NEW |