OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "webkit/glue/plugins/pepper_url_loader.h" | 5 #include "webkit/glue/plugins/pepper_url_loader.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "third_party/ppapi/c/pp_completion_callback.h" | 8 #include "third_party/ppapi/c/pp_completion_callback.h" |
9 #include "third_party/ppapi/c/pp_errors.h" | 9 #include "third_party/ppapi/c/pp_errors.h" |
10 #include "third_party/ppapi/c/ppb_url_loader.h" | 10 #include "third_party/ppapi/c/dev/ppb_url_loader_dev.h" |
11 #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h" | 11 #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h" |
12 #include "third_party/WebKit/WebKit/chromium/public/WebElement.h" | 12 #include "third_party/WebKit/WebKit/chromium/public/WebElement.h" |
13 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" | 13 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" |
14 #include "third_party/WebKit/WebKit/chromium/public/WebKit.h" | 14 #include "third_party/WebKit/WebKit/chromium/public/WebKit.h" |
15 #include "third_party/WebKit/WebKit/chromium/public/WebKitClient.h" | 15 #include "third_party/WebKit/WebKit/chromium/public/WebKitClient.h" |
16 #include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h" | 16 #include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h" |
17 #include "third_party/WebKit/WebKit/chromium/public/WebURLRequest.h" | 17 #include "third_party/WebKit/WebKit/chromium/public/WebURLRequest.h" |
18 #include "third_party/WebKit/WebKit/chromium/public/WebURLResponse.h" | 18 #include "third_party/WebKit/WebKit/chromium/public/WebURLResponse.h" |
19 #include "webkit/glue/plugins/pepper_plugin_instance.h" | 19 #include "webkit/glue/plugins/pepper_plugin_instance.h" |
20 #include "webkit/glue/plugins/pepper_url_request_info.h" | 20 #include "webkit/glue/plugins/pepper_url_request_info.h" |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 } | 132 } |
133 | 133 |
134 void Close(PP_Resource loader_id) { | 134 void Close(PP_Resource loader_id) { |
135 scoped_refptr<URLLoader> loader(Resource::GetAs<URLLoader>(loader_id)); | 135 scoped_refptr<URLLoader> loader(Resource::GetAs<URLLoader>(loader_id)); |
136 if (!loader) | 136 if (!loader) |
137 return; | 137 return; |
138 | 138 |
139 loader->Close(); | 139 loader->Close(); |
140 } | 140 } |
141 | 141 |
142 const PPB_URLLoader ppb_urlloader = { | 142 const PPB_URLLoader_Dev ppb_urlloader = { |
143 &Create, | 143 &Create, |
144 &IsURLLoader, | 144 &IsURLLoader, |
145 &Open, | 145 &Open, |
146 &FollowRedirect, | 146 &FollowRedirect, |
147 &GetUploadProgress, | 147 &GetUploadProgress, |
148 &GetDownloadProgress, | 148 &GetDownloadProgress, |
149 &GetResponseInfo, | 149 &GetResponseInfo, |
150 &ReadResponseBody, | 150 &ReadResponseBody, |
151 &FinishStreamingToFile, | 151 &FinishStreamingToFile, |
152 &Close | 152 &Close |
(...skipping 11 matching lines...) Expand all Loading... |
164 total_bytes_to_be_received_(-1), | 164 total_bytes_to_be_received_(-1), |
165 user_buffer_(NULL), | 165 user_buffer_(NULL), |
166 user_buffer_size_(0), | 166 user_buffer_size_(0), |
167 done_status_(PP_ERROR_WOULDBLOCK) { | 167 done_status_(PP_ERROR_WOULDBLOCK) { |
168 } | 168 } |
169 | 169 |
170 URLLoader::~URLLoader() { | 170 URLLoader::~URLLoader() { |
171 } | 171 } |
172 | 172 |
173 // static | 173 // static |
174 const PPB_URLLoader* URLLoader::GetInterface() { | 174 const PPB_URLLoader_Dev* URLLoader::GetInterface() { |
175 return &ppb_urlloader; | 175 return &ppb_urlloader; |
176 } | 176 } |
177 | 177 |
178 int32_t URLLoader::Open(URLRequestInfo* request, | 178 int32_t URLLoader::Open(URLRequestInfo* request, |
179 PP_CompletionCallback callback) { | 179 PP_CompletionCallback callback) { |
180 if (loader_.get()) | 180 if (loader_.get()) |
181 return PP_ERROR_INPROGRESS; | 181 return PP_ERROR_INPROGRESS; |
182 | 182 |
183 // We only support non-blocking calls. | 183 // We only support non-blocking calls. |
184 if (!callback.func) | 184 if (!callback.func) |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 std::copy(buffer_.begin(), buffer_.begin() + bytes_to_copy, user_buffer_); | 329 std::copy(buffer_.begin(), buffer_.begin() + bytes_to_copy, user_buffer_); |
330 buffer_.erase(buffer_.begin(), buffer_.begin() + bytes_to_copy); | 330 buffer_.erase(buffer_.begin(), buffer_.begin() + bytes_to_copy); |
331 | 331 |
332 // Reset for next time. | 332 // Reset for next time. |
333 user_buffer_ = NULL; | 333 user_buffer_ = NULL; |
334 user_buffer_size_ = 0; | 334 user_buffer_size_ = 0; |
335 return bytes_to_copy; | 335 return bytes_to_copy; |
336 } | 336 } |
337 | 337 |
338 } // namespace pepper | 338 } // namespace pepper |
OLD | NEW |