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

Side by Side Diff: webkit/glue/plugins/pepper_url_request_info.cc

Issue 4310002: Make PPAPI headers compile with C compilers (gcc on Linux & Mac and MSVS on W... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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
OLDNEW
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_request_info.h" 5 #include "webkit/glue/plugins/pepper_url_request_info.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "googleurl/src/gurl.h" 9 #include "googleurl/src/gurl.h"
10 #include "net/http/http_util.h" 10 #include "net/http/http_util.h"
11 #include "ppapi/c/pp_var.h" 11 #include "ppapi/c/pp_var.h"
12 #include "third_party/WebKit/WebKit/chromium/public/WebData.h" 12 #include "third_party/WebKit/WebKit/chromium/public/WebData.h"
13 #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h" 13 #include "third_party/WebKit/WebKit/chromium/public/WebDocument.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/WebHTTPBody.h" 15 #include "third_party/WebKit/WebKit/chromium/public/WebHTTPBody.h"
16 #include "third_party/WebKit/WebKit/chromium/public/WebURL.h" 16 #include "third_party/WebKit/WebKit/chromium/public/WebURL.h"
17 #include "third_party/WebKit/WebKit/chromium/public/WebURLRequest.h" 17 #include "third_party/WebKit/WebKit/chromium/public/WebURLRequest.h"
18 #include "webkit/glue/plugins/pepper_common.h"
18 #include "webkit/glue/plugins/pepper_file_ref.h" 19 #include "webkit/glue/plugins/pepper_file_ref.h"
19 #include "webkit/glue/plugins/pepper_plugin_module.h" 20 #include "webkit/glue/plugins/pepper_plugin_module.h"
20 #include "webkit/glue/plugins/pepper_string.h" 21 #include "webkit/glue/plugins/pepper_string.h"
21 #include "webkit/glue/plugins/pepper_var.h" 22 #include "webkit/glue/plugins/pepper_var.h"
22 #include "webkit/glue/webkit_glue.h" 23 #include "webkit/glue/webkit_glue.h"
23 24
24 using WebKit::WebData; 25 using WebKit::WebData;
25 using WebKit::WebHTTPBody; 26 using WebKit::WebHTTPBody;
26 using WebKit::WebString; 27 using WebKit::WebString;
27 using WebKit::WebFrame; 28 using WebKit::WebFrame;
28 using WebKit::WebURL; 29 using WebKit::WebURL;
29 using WebKit::WebURLRequest; 30 using WebKit::WebURLRequest;
30 31
31 namespace pepper { 32 namespace pepper {
32 33
33 namespace { 34 namespace {
34 35
35 // If any of these request headers are specified, they will not be sent. 36 // If any of these request headers are specified, they will not be sent.
36 // TODO(darin): Add more based on security considerations? 37 // TODO(darin): Add more based on security considerations?
37 const char* const kIgnoredRequestHeaders[] = { 38 const char* const kIgnoredRequestHeaders[] = {
38 "content-length" 39 "content-length"
39 }; 40 };
40 41
41 bool IsIgnoredRequestHeader(const std::string& name) { 42 PP_Bool IsIgnoredRequestHeader(const std::string& name) {
42 for (size_t i = 0; i < arraysize(kIgnoredRequestHeaders); ++i) { 43 for (size_t i = 0; i < arraysize(kIgnoredRequestHeaders); ++i) {
43 if (LowerCaseEqualsASCII(name, kIgnoredRequestHeaders[i])) 44 if (LowerCaseEqualsASCII(name, kIgnoredRequestHeaders[i]))
44 return true; 45 return PP_TRUE;
45 } 46 }
46 return false; 47 return PP_FALSE;
47 } 48 }
48 49
49 PP_Resource Create(PP_Module module_id) { 50 PP_Resource Create(PP_Module module_id) {
50 PluginModule* module = ResourceTracker::Get()->GetModule(module_id); 51 PluginModule* module = ResourceTracker::Get()->GetModule(module_id);
51 if (!module) 52 if (!module)
52 return 0; 53 return 0;
53 54
54 URLRequestInfo* request = new URLRequestInfo(module); 55 URLRequestInfo* request = new URLRequestInfo(module);
55 56
56 return request->GetReference(); 57 return request->GetReference();
57 } 58 }
58 59
59 bool IsURLRequestInfo(PP_Resource resource) { 60 PP_Bool IsURLRequestInfo(PP_Resource resource) {
60 return !!Resource::GetAs<URLRequestInfo>(resource); 61 return BoolToPPBool(!!Resource::GetAs<URLRequestInfo>(resource));
61 } 62 }
62 63
63 bool SetProperty(PP_Resource request_id, 64 PP_Bool SetProperty(PP_Resource request_id,
64 PP_URLRequestProperty_Dev property, 65 PP_URLRequestProperty_Dev property,
65 PP_Var var) { 66 PP_Var var) {
66 scoped_refptr<URLRequestInfo> request( 67 scoped_refptr<URLRequestInfo> request(
67 Resource::GetAs<URLRequestInfo>(request_id)); 68 Resource::GetAs<URLRequestInfo>(request_id));
68 if (!request) 69 if (!request)
69 return false; 70 return PP_FALSE;
70 71
71 if (var.type == PP_VARTYPE_BOOL) 72 if (var.type == PP_VARTYPE_BOOL) {
72 return request->SetBooleanProperty(property, var.value.as_bool); 73 return BoolToPPBool(
74 request->SetBooleanProperty(property,
75 PPBoolToBool(var.value.as_bool)));
76 }
73 77
74 if (var.type == PP_VARTYPE_STRING) { 78 if (var.type == PP_VARTYPE_STRING) {
75 scoped_refptr<StringVar> string(StringVar::FromPPVar(var)); 79 scoped_refptr<StringVar> string(StringVar::FromPPVar(var));
76 if (string) 80 if (string) {
77 return request->SetStringProperty(property, string->value()); 81 return BoolToPPBool(request->SetStringProperty(property,
82 string->value()));
83 }
78 } 84 }
79 85
80 return false; 86 return PP_FALSE;
81 } 87 }
82 88
83 bool AppendDataToBody(PP_Resource request_id, const char* data, uint32_t len) { 89 PP_Bool AppendDataToBody(PP_Resource request_id,
90 const char* data,
91 uint32_t len) {
84 scoped_refptr<URLRequestInfo> request( 92 scoped_refptr<URLRequestInfo> request(
85 Resource::GetAs<URLRequestInfo>(request_id)); 93 Resource::GetAs<URLRequestInfo>(request_id));
86 if (!request) 94 if (!request)
87 return false; 95 return PP_FALSE;
88 96
89 return request->AppendDataToBody(std::string(data, len)); 97 return BoolToPPBool(request->AppendDataToBody(std::string(data, len)));
90 } 98 }
91 99
92 bool AppendFileToBody(PP_Resource request_id, 100 PP_Bool AppendFileToBody(PP_Resource request_id,
93 PP_Resource file_ref_id, 101 PP_Resource file_ref_id,
94 int64_t start_offset, 102 int64_t start_offset,
95 int64_t number_of_bytes, 103 int64_t number_of_bytes,
96 PP_Time expected_last_modified_time) { 104 PP_Time expected_last_modified_time) {
97 scoped_refptr<URLRequestInfo> request( 105 scoped_refptr<URLRequestInfo> request(
98 Resource::GetAs<URLRequestInfo>(request_id)); 106 Resource::GetAs<URLRequestInfo>(request_id));
99 if (!request) 107 if (!request)
100 return false; 108 return PP_FALSE;
101 109
102 scoped_refptr<FileRef> file_ref(Resource::GetAs<FileRef>(file_ref_id)); 110 scoped_refptr<FileRef> file_ref(Resource::GetAs<FileRef>(file_ref_id));
103 if (!file_ref) 111 if (!file_ref)
104 return false; 112 return PP_FALSE;
105 113
106 return request->AppendFileToBody(file_ref, 114 return BoolToPPBool(request->AppendFileToBody(file_ref,
107 start_offset, 115 start_offset,
108 number_of_bytes, 116 number_of_bytes,
109 expected_last_modified_time); 117 expected_last_modified_time));
110 } 118 }
111 119
112 const PPB_URLRequestInfo_Dev ppb_urlrequestinfo = { 120 const PPB_URLRequestInfo_Dev ppb_urlrequestinfo = {
113 &Create, 121 &Create,
114 &IsURLRequestInfo, 122 &IsURLRequestInfo,
115 &SetProperty, 123 &SetProperty,
116 &AppendDataToBody, 124 &AppendDataToBody,
117 &AppendFileToBody 125 &AppendFileToBody
118 }; 126 };
119 127
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 } 265 }
258 } 266 }
259 web_request.setHTTPBody(http_body); 267 web_request.setHTTPBody(http_body);
260 } 268 }
261 269
262 frame->setReferrerForRequest(web_request, WebURL()); // Use default. 270 frame->setReferrerForRequest(web_request, WebURL()); // Use default.
263 return web_request; 271 return web_request;
264 } 272 }
265 273
266 } // namespace pepper 274 } // namespace pepper
OLDNEW
« no previous file with comments | « webkit/glue/plugins/pepper_url_loader.cc ('k') | webkit/glue/plugins/pepper_url_response_info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698