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

Side by Side Diff: content/renderer/npapi/webplugin_impl.cc

Issue 1547073003: Switch to standard integer types in content/renderer/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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
OLDNEW
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 "content/renderer/npapi/webplugin_impl.h" 5 #include "content/renderer/npapi/webplugin_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/crash_logging.h" 9 #include "base/debug/crash_logging.h"
10 #include "base/location.h" 10 #include "base/location.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/linked_ptr.h" 12 #include "base/memory/linked_ptr.h"
13 #include "base/metrics/user_metrics_action.h" 13 #include "base/metrics/user_metrics_action.h"
14 #include "base/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
15 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
16 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
17 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
18 #include "base/thread_task_runner_handle.h" 18 #include "base/thread_task_runner_handle.h"
19 #include "build/build_config.h"
19 #include "cc/blink/web_layer_impl.h" 20 #include "cc/blink/web_layer_impl.h"
20 #include "cc/layers/io_surface_layer.h" 21 #include "cc/layers/io_surface_layer.h"
21 #include "content/child/appcache/web_application_cache_host_impl.h" 22 #include "content/child/appcache/web_application_cache_host_impl.h"
22 #include "content/child/multipart_response_delegate.h" 23 #include "content/child/multipart_response_delegate.h"
23 #include "content/child/npapi/plugin_host.h" 24 #include "content/child/npapi/plugin_host.h"
24 #include "content/child/npapi/plugin_instance.h" 25 #include "content/child/npapi/plugin_instance.h"
25 #include "content/child/npapi/webplugin_delegate_impl.h" 26 #include "content/child/npapi/webplugin_delegate_impl.h"
26 #include "content/child/npapi/webplugin_resource_client.h" 27 #include "content/child/npapi/webplugin_resource_client.h"
27 #include "content/common/view_messages.h" 28 #include "content/common/view_messages.h"
28 #include "content/public/common/content_constants.h" 29 #include "content/public/common/content_constants.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 WebURLRequest&, 107 WebURLRequest&,
107 const WebURLResponse&) override {} 108 const WebURLResponse&) override {}
108 void didSendData(WebURLLoader*, 109 void didSendData(WebURLLoader*,
109 unsigned long long, 110 unsigned long long,
110 unsigned long long) override {} 111 unsigned long long) override {}
111 112
112 // Called when the multipart parser encounters an embedded multipart 113 // Called when the multipart parser encounters an embedded multipart
113 // response. 114 // response.
114 void didReceiveResponse(WebURLLoader*, 115 void didReceiveResponse(WebURLLoader*,
115 const WebURLResponse& response) override { 116 const WebURLResponse& response) override {
116 int64 byte_range_upper_bound, instance_size; 117 int64_t byte_range_upper_bound, instance_size;
117 if (!MultipartResponseDelegate::ReadContentRanges( 118 if (!MultipartResponseDelegate::ReadContentRanges(
118 response, 119 response,
119 &byte_range_lower_bound_, 120 &byte_range_lower_bound_,
120 &byte_range_upper_bound, 121 &byte_range_upper_bound,
121 &instance_size)) { 122 &instance_size)) {
122 NOTREACHED(); 123 NOTREACHED();
123 } 124 }
124 } 125 }
125 126
126 // Receives individual part data from a multipart response. 127 // Receives individual part data from a multipart response.
127 void didReceiveData(WebURLLoader*, 128 void didReceiveData(WebURLLoader*,
128 const char* data, 129 const char* data,
129 int data_length, 130 int data_length,
130 int encoded_data_length) override { 131 int encoded_data_length) override {
131 // TODO(ananta) 132 // TODO(ananta)
132 // We should defer further loads on multipart resources on the same lines 133 // We should defer further loads on multipart resources on the same lines
133 // as regular resources requested by plugins to prevent reentrancy. 134 // as regular resources requested by plugins to prevent reentrancy.
134 resource_client_->DidReceiveData( 135 resource_client_->DidReceiveData(
135 data, data_length, byte_range_lower_bound_); 136 data, data_length, byte_range_lower_bound_);
136 byte_range_lower_bound_ += data_length; 137 byte_range_lower_bound_ += data_length;
137 } 138 }
138 139
139 void didFinishLoading(WebURLLoader*, 140 void didFinishLoading(WebURLLoader*,
140 double finishTime, 141 double finishTime,
141 int64_t total_encoded_data_length) override {} 142 int64_t total_encoded_data_length) override {}
142 void didFail(WebURLLoader*, const WebURLError&) override {} 143 void didFail(WebURLLoader*, const WebURLError&) override {}
143 144
144 private: 145 private:
145 // The lower bound of the byte range. 146 // The lower bound of the byte range.
146 int64 byte_range_lower_bound_; 147 int64_t byte_range_lower_bound_;
147 // The handler for the data. 148 // The handler for the data.
148 WebPluginResourceClient* resource_client_; 149 WebPluginResourceClient* resource_client_;
149 }; 150 };
150 151
151 class HeaderFlattener : public WebHTTPHeaderVisitor { 152 class HeaderFlattener : public WebHTTPHeaderVisitor {
152 public: 153 public:
153 explicit HeaderFlattener(std::string* buf) : buf_(buf) { 154 explicit HeaderFlattener(std::string* buf) : buf_(buf) {
154 } 155 }
155 156
156 void visitHeader(const WebString& name, const WebString& value) override { 157 void visitHeader(const WebString& name, const WebString& value) override {
(...skipping 25 matching lines...) Expand all
182 183
183 HeaderFlattener flattener(&result); 184 HeaderFlattener flattener(&result);
184 response.visitHTTPHeaderFields(&flattener); 185 response.visitHTTPHeaderFields(&flattener);
185 186
186 return result; 187 return result;
187 } 188 }
188 189
189 struct ResponseInfo { 190 struct ResponseInfo {
190 GURL url; 191 GURL url;
191 std::string mime_type; 192 std::string mime_type;
192 uint32 last_modified; 193 uint32_t last_modified;
193 uint32 expected_length; 194 uint32_t expected_length;
194 }; 195 };
195 196
196 void GetResponseInfo(const WebURLResponse& response, 197 void GetResponseInfo(const WebURLResponse& response,
197 ResponseInfo* response_info) { 198 ResponseInfo* response_info) {
198 response_info->url = response.url(); 199 response_info->url = response.url();
199 response_info->mime_type = response.mimeType().utf8(); 200 response_info->mime_type = response.mimeType().utf8();
200 201
201 // Measured in seconds since 12:00 midnight GMT, January 1, 1970. 202 // Measured in seconds since 12:00 midnight GMT, January 1, 1970.
202 response_info->last_modified = 203 response_info->last_modified =
203 static_cast<uint32>(response.lastModifiedDate()); 204 static_cast<uint32_t>(response.lastModifiedDate());
204 205
205 // If the length comes in as -1, then it indicates that it was not 206 // If the length comes in as -1, then it indicates that it was not
206 // read off the HTTP headers. We replicate Safari webkit behavior here, 207 // read off the HTTP headers. We replicate Safari webkit behavior here,
207 // which is to set it to 0. 208 // which is to set it to 0.
208 response_info->expected_length = 209 response_info->expected_length =
209 static_cast<uint32>(std::max(response.expectedContentLength(), 0LL)); 210 static_cast<uint32_t>(std::max(response.expectedContentLength(), 0LL));
210 211
211 WebString content_encoding = 212 WebString content_encoding =
212 response.httpHeaderField(WebString::fromUTF8("Content-Encoding")); 213 response.httpHeaderField(WebString::fromUTF8("Content-Encoding"));
213 if (!content_encoding.isNull() && 214 if (!content_encoding.isNull() &&
214 !base::EqualsASCII(base::StringPiece16(content_encoding), "identity")) { 215 !base::EqualsASCII(base::StringPiece16(content_encoding), "identity")) {
215 // Don't send the compressed content length to the plugin, which only 216 // Don't send the compressed content length to the plugin, which only
216 // cares about the decoded length. 217 // cares about the decoded length.
217 response_info->expected_length = 0; 218 response_info->expected_length = 0;
218 } 219 }
219 } 220 }
220 221
221 } // namespace 222 } // namespace
222 223
223 // blink::WebPlugin ---------------------------------------------------------- 224 // blink::WebPlugin ----------------------------------------------------------
224 225
225 struct WebPluginImpl::ClientInfo { 226 struct WebPluginImpl::ClientInfo {
226 unsigned long id; 227 unsigned long id;
227 WebPluginResourceClient* client; 228 WebPluginResourceClient* client;
228 blink::WebURLRequest request; 229 blink::WebURLRequest request;
229 bool pending_failure_notification; 230 bool pending_failure_notification;
230 linked_ptr<blink::WebURLLoader> loader; 231 linked_ptr<blink::WebURLLoader> loader;
231 bool notify_redirects; 232 bool notify_redirects;
232 bool is_plugin_src_load; 233 bool is_plugin_src_load;
233 int64 data_offset; 234 int64_t data_offset;
234 }; 235 };
235 236
236 bool WebPluginImpl::initialize(WebPluginContainer* container) { 237 bool WebPluginImpl::initialize(WebPluginContainer* container) {
237 if (!render_view_.get()) { 238 if (!render_view_.get()) {
238 LOG(ERROR) << "No RenderView"; 239 LOG(ERROR) << "No RenderView";
239 return false; 240 return false;
240 } 241 }
241 242
242 WebPluginDelegateProxy* plugin_delegate = new WebPluginDelegateProxy( 243 WebPluginDelegateProxy* plugin_delegate = new WebPluginDelegateProxy(
243 this, mime_type_, render_view_, render_frame_); 244 this, mime_type_, render_view_, render_frame_);
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 clients_[i].loader->setDefersLoading(false); 562 clients_[i].loader->setDefersLoading(false);
562 clients_[i].loader->cancel(); 563 clients_[i].loader->cancel();
563 RemoveClient(i); 564 RemoveClient(i);
564 } 565 }
565 return; 566 return;
566 } 567 }
567 } 568 }
568 } 569 }
569 570
570 bool WebPluginImpl::SetPostData(WebURLRequest* request, 571 bool WebPluginImpl::SetPostData(WebURLRequest* request,
571 const char *buf, 572 const char* buf,
572 uint32 length) { 573 uint32_t length) {
573 std::vector<std::string> names; 574 std::vector<std::string> names;
574 std::vector<std::string> values; 575 std::vector<std::string> values;
575 std::vector<char> body; 576 std::vector<char> body;
576 bool rv = PluginHost::SetPostData(buf, length, &names, &values, &body); 577 bool rv = PluginHost::SetPostData(buf, length, &names, &values, &body);
577 578
578 for (size_t i = 0; i < names.size(); ++i) { 579 for (size_t i = 0; i < names.size(); ++i) {
579 request->addHTTPHeaderField(WebString::fromUTF8(names[i]), 580 request->addHTTPHeaderField(WebString::fromUTF8(names[i]),
580 WebString::fromUTF8(values[i])); 581 WebString::fromUTF8(values[i]));
581 } 582 }
582 583
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 772
772 #if defined(OS_MACOSX) 773 #if defined(OS_MACOSX)
773 WebPluginAcceleratedSurface* WebPluginImpl::GetAcceleratedSurface( 774 WebPluginAcceleratedSurface* WebPluginImpl::GetAcceleratedSurface(
774 gfx::GpuPreference gpu_preference) { 775 gfx::GpuPreference gpu_preference) {
775 return NULL; 776 return NULL;
776 } 777 }
777 778
778 void WebPluginImpl::AcceleratedPluginEnabledRendering() { 779 void WebPluginImpl::AcceleratedPluginEnabledRendering() {
779 } 780 }
780 781
781 void WebPluginImpl::AcceleratedPluginAllocatedIOSurface(int32 width, 782 void WebPluginImpl::AcceleratedPluginAllocatedIOSurface(int32_t width,
782 int32 height, 783 int32_t height,
783 uint32 surface_id) { 784 uint32_t surface_id) {
784 next_io_surface_allocated_ = true; 785 next_io_surface_allocated_ = true;
785 next_io_surface_width_ = width; 786 next_io_surface_width_ = width;
786 next_io_surface_height_ = height; 787 next_io_surface_height_ = height;
787 next_io_surface_id_ = surface_id; 788 next_io_surface_id_ = surface_id;
788 } 789 }
789 790
790 void WebPluginImpl::AcceleratedPluginSwappedIOSurface() { 791 void WebPluginImpl::AcceleratedPluginSwappedIOSurface() {
791 if (!container_) 792 if (!container_)
792 return; 793 return;
793 // Deferring the call to setBackingIOSurfaceId is an attempt to 794 // Deferring the call to setBackingIOSurfaceId is an attempt to
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
1218 case PLUGIN_SRC: 1219 case PLUGIN_SRC:
1219 webframe_->setReferrerForRequest(*request, plugin_url_); 1220 webframe_->setReferrerForRequest(*request, plugin_url_);
1220 break; 1221 break;
1221 1222
1222 default: 1223 default:
1223 break; 1224 break;
1224 } 1225 }
1225 } 1226 }
1226 1227
1227 } // namespace content 1228 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/npapi/webplugin_impl.h ('k') | content/renderer/npapi/webplugin_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698