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 "ppapi/c/pp_completion_callback.h" | 8 #include "ppapi/c/pp_completion_callback.h" |
9 #include "ppapi/c/pp_errors.h" | 9 #include "ppapi/c/pp_errors.h" |
10 #include "ppapi/c/dev/ppb_url_loader_dev.h" | 10 #include "ppapi/c/dev/ppb_url_loader_dev.h" |
11 #include "ppapi/c/dev/ppb_url_loader_trusted_dev.h" | 11 #include "ppapi/c/dev/ppb_url_loader_trusted_dev.h" |
12 #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h" | 12 #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h" |
13 #include "third_party/WebKit/WebKit/chromium/public/WebElement.h" | 13 #include "third_party/WebKit/WebKit/chromium/public/WebElement.h" |
14 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" | 14 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" |
15 #include "third_party/WebKit/WebKit/chromium/public/WebKit.h" | 15 #include "third_party/WebKit/WebKit/chromium/public/WebKit.h" |
16 #include "third_party/WebKit/WebKit/chromium/public/WebKitClient.h" | 16 #include "third_party/WebKit/WebKit/chromium/public/WebKitClient.h" |
17 #include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h" | 17 #include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h" |
18 #include "third_party/WebKit/WebKit/chromium/public/WebSecurityOrigin.h" | 18 #include "third_party/WebKit/WebKit/chromium/public/WebSecurityOrigin.h" |
19 #include "third_party/WebKit/WebKit/chromium/public/WebURLRequest.h" | 19 #include "third_party/WebKit/WebKit/chromium/public/WebURLRequest.h" |
20 #include "third_party/WebKit/WebKit/chromium/public/WebURLResponse.h" | 20 #include "third_party/WebKit/WebKit/chromium/public/WebURLResponse.h" |
21 #include "webkit/appcache/web_application_cache_host_impl.h" | 21 #include "webkit/appcache/web_application_cache_host_impl.h" |
| 22 #include "webkit/glue/plugins/pepper_common.h" |
22 #include "webkit/glue/plugins/pepper_plugin_instance.h" | 23 #include "webkit/glue/plugins/pepper_plugin_instance.h" |
23 #include "webkit/glue/plugins/pepper_url_request_info.h" | 24 #include "webkit/glue/plugins/pepper_url_request_info.h" |
24 #include "webkit/glue/plugins/pepper_url_response_info.h" | 25 #include "webkit/glue/plugins/pepper_url_response_info.h" |
25 | 26 |
26 using appcache::WebApplicationCacheHostImpl; | 27 using appcache::WebApplicationCacheHostImpl; |
27 using WebKit::WebFrame; | 28 using WebKit::WebFrame; |
28 using WebKit::WebString; | 29 using WebKit::WebString; |
29 using WebKit::WebURL; | 30 using WebKit::WebURL; |
30 using WebKit::WebURLError; | 31 using WebKit::WebURLError; |
31 using WebKit::WebURLLoader; | 32 using WebKit::WebURLLoader; |
(...skipping 11 matching lines...) Expand all Loading... |
43 | 44 |
44 PP_Resource Create(PP_Instance instance_id) { | 45 PP_Resource Create(PP_Instance instance_id) { |
45 PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); | 46 PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); |
46 if (!instance) | 47 if (!instance) |
47 return 0; | 48 return 0; |
48 | 49 |
49 URLLoader* loader = new URLLoader(instance, false); | 50 URLLoader* loader = new URLLoader(instance, false); |
50 return loader->GetReference(); | 51 return loader->GetReference(); |
51 } | 52 } |
52 | 53 |
53 bool IsURLLoader(PP_Resource resource) { | 54 PP_Bool IsURLLoader(PP_Resource resource) { |
54 return !!Resource::GetAs<URLLoader>(resource); | 55 return BoolToPPBool(!!Resource::GetAs<URLLoader>(resource)); |
55 } | 56 } |
56 | 57 |
57 int32_t Open(PP_Resource loader_id, | 58 int32_t Open(PP_Resource loader_id, |
58 PP_Resource request_id, | 59 PP_Resource request_id, |
59 PP_CompletionCallback callback) { | 60 PP_CompletionCallback callback) { |
60 scoped_refptr<URLLoader> loader(Resource::GetAs<URLLoader>(loader_id)); | 61 scoped_refptr<URLLoader> loader(Resource::GetAs<URLLoader>(loader_id)); |
61 if (!loader) | 62 if (!loader) |
62 return PP_ERROR_BADRESOURCE; | 63 return PP_ERROR_BADRESOURCE; |
63 | 64 |
64 scoped_refptr<URLRequestInfo> request( | 65 scoped_refptr<URLRequestInfo> request( |
65 Resource::GetAs<URLRequestInfo>(request_id)); | 66 Resource::GetAs<URLRequestInfo>(request_id)); |
66 if (!request) | 67 if (!request) |
67 return PP_ERROR_BADRESOURCE; | 68 return PP_ERROR_BADRESOURCE; |
68 | 69 |
69 return loader->Open(request, callback); | 70 return loader->Open(request, callback); |
70 } | 71 } |
71 | 72 |
72 int32_t FollowRedirect(PP_Resource loader_id, | 73 int32_t FollowRedirect(PP_Resource loader_id, |
73 PP_CompletionCallback callback) { | 74 PP_CompletionCallback callback) { |
74 scoped_refptr<URLLoader> loader(Resource::GetAs<URLLoader>(loader_id)); | 75 scoped_refptr<URLLoader> loader(Resource::GetAs<URLLoader>(loader_id)); |
75 if (!loader) | 76 if (!loader) |
76 return PP_ERROR_BADRESOURCE; | 77 return PP_ERROR_BADRESOURCE; |
77 | 78 |
78 return loader->FollowRedirect(callback); | 79 return loader->FollowRedirect(callback); |
79 } | 80 } |
80 | 81 |
81 bool GetUploadProgress(PP_Resource loader_id, | 82 PP_Bool GetUploadProgress(PP_Resource loader_id, |
82 int64_t* bytes_sent, | 83 int64_t* bytes_sent, |
83 int64_t* total_bytes_to_be_sent) { | 84 int64_t* total_bytes_to_be_sent) { |
84 scoped_refptr<URLLoader> loader(Resource::GetAs<URLLoader>(loader_id)); | 85 scoped_refptr<URLLoader> loader(Resource::GetAs<URLLoader>(loader_id)); |
85 if (!loader) | 86 if (!loader) |
86 return false; | 87 return PP_FALSE; |
87 return loader->GetUploadProgress(bytes_sent, total_bytes_to_be_sent); | 88 |
88 return true; | 89 return BoolToPPBool(loader->GetUploadProgress(bytes_sent, |
| 90 total_bytes_to_be_sent)); |
89 } | 91 } |
90 | 92 |
91 bool GetDownloadProgress(PP_Resource loader_id, | 93 PP_Bool GetDownloadProgress(PP_Resource loader_id, |
92 int64_t* bytes_received, | 94 int64_t* bytes_received, |
93 int64_t* total_bytes_to_be_received) { | 95 int64_t* total_bytes_to_be_received) { |
94 scoped_refptr<URLLoader> loader(Resource::GetAs<URLLoader>(loader_id)); | 96 scoped_refptr<URLLoader> loader(Resource::GetAs<URLLoader>(loader_id)); |
95 if (!loader) | 97 if (!loader) |
96 return false; | 98 return PP_FALSE; |
97 return loader->GetDownloadProgress(bytes_received, | 99 |
98 total_bytes_to_be_received); | 100 return BoolToPPBool(loader->GetDownloadProgress(bytes_received, |
| 101 total_bytes_to_be_received)); |
99 } | 102 } |
100 | 103 |
101 PP_Resource GetResponseInfo(PP_Resource loader_id) { | 104 PP_Resource GetResponseInfo(PP_Resource loader_id) { |
102 scoped_refptr<URLLoader> loader(Resource::GetAs<URLLoader>(loader_id)); | 105 scoped_refptr<URLLoader> loader(Resource::GetAs<URLLoader>(loader_id)); |
103 if (!loader) | 106 if (!loader) |
104 return 0; | 107 return 0; |
105 | 108 |
106 URLResponseInfo* response_info = loader->response_info(); | 109 URLResponseInfo* response_info = loader->response_info(); |
107 if (!response_info) | 110 if (!response_info) |
108 return 0; | 111 return 0; |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 instance_->pp_instance(), pp_resource, | 438 instance_->pp_instance(), pp_resource, |
436 record_upload_progress_ ? bytes_sent_ : -1, | 439 record_upload_progress_ ? bytes_sent_ : -1, |
437 record_upload_progress_ ? total_bytes_to_be_sent_ : -1, | 440 record_upload_progress_ ? total_bytes_to_be_sent_ : -1, |
438 record_download_progress_ ? bytes_received_ : -1, | 441 record_download_progress_ ? bytes_received_ : -1, |
439 record_download_progress_ ? total_bytes_to_be_received_ : -1); | 442 record_download_progress_ ? total_bytes_to_be_received_ : -1); |
440 } | 443 } |
441 } | 444 } |
442 } | 445 } |
443 | 446 |
444 } // namespace pepper | 447 } // namespace pepper |
OLD | NEW |