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

Side by Side Diff: webkit/glue/webplugin_impl.cc

Issue 174383: Fixes a crash caused due to a call to NPP_DestroyStream occuring in the conte... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « webkit/glue/webplugin_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "config.h" 5 #include "config.h"
6 6
7 #include "Document.h" 7 #include "Document.h"
8 #include "DocumentLoader.h" 8 #include "DocumentLoader.h"
9 #include "FormState.h" 9 #include "FormState.h"
10 #include "Frame.h" 10 #include "Frame.h"
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 // error codes in the stream header and as a result, was unaware of the 762 // error codes in the stream header and as a result, was unaware of the
763 // fate of the HTTP requests issued via NPN_GetURLNotify. Webkit and FF 763 // fate of the HTTP requests issued via NPN_GetURLNotify. Webkit and FF
764 // destroy the stream and invoke the NPP_DestroyStream function on the 764 // destroy the stream and invoke the NPP_DestroyStream function on the
765 // plugin if the HTTP request fails. 765 // plugin if the HTTP request fails.
766 const GURL& url = response.url(); 766 const GURL& url = response.url();
767 if (url.SchemeIs("http") || url.SchemeIs("https")) { 767 if (url.SchemeIs("http") || url.SchemeIs("https")) {
768 if (response.httpStatusCode() < 100 || response.httpStatusCode() >= 400) { 768 if (response.httpStatusCode() < 100 || response.httpStatusCode() >= 400) {
769 // The plugin instance could be in the process of deletion here. 769 // The plugin instance could be in the process of deletion here.
770 // Verify if the WebPluginResourceClient instance still exists before 770 // Verify if the WebPluginResourceClient instance still exists before
771 // use. 771 // use.
772 WebPluginResourceClient* resource_client = GetClientFromLoader(loader); 772 ClientInfo* client_info = GetClientInfoFromLoader(loader);
773 if (resource_client) { 773 if (client_info) {
774 loader->cancel(); 774 client_info->pending_failure_notification = true;
775 resource_client->DidFail();
776 RemoveClient(loader);
777 } 775 }
778 } 776 }
779 } 777 }
780 } 778 }
781 779
782 void WebPluginImpl::didReceiveData(WebURLLoader* loader, 780 void WebPluginImpl::didReceiveData(WebURLLoader* loader,
783 const char *buffer, 781 const char *buffer,
784 int length, long long) { 782 int length, long long) {
785 WebPluginResourceClient* client = GetClientFromLoader(loader); 783 WebPluginResourceClient* client = GetClientFromLoader(loader);
786 if (!client) 784 if (!client)
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 } 933 }
936 934
937 ClientInfo info; 935 ClientInfo info;
938 info.id = resource_id; 936 info.id = resource_id;
939 info.client = client; 937 info.client = client;
940 info.request.initialize(); 938 info.request.initialize();
941 info.request.setURL(url); 939 info.request.setURL(url);
942 info.request.setRequestorProcessID(delegate_->GetProcessId()); 940 info.request.setRequestorProcessID(delegate_->GetProcessId());
943 info.request.setTargetType(WebURLRequest::TargetIsObject); 941 info.request.setTargetType(WebURLRequest::TargetIsObject);
944 info.request.setHTTPMethod(WebString::fromUTF8(method)); 942 info.request.setHTTPMethod(WebString::fromUTF8(method));
943 info.pending_failure_notification = false;
945 944
946 if (range_info) { 945 if (range_info) {
947 info.request.addHTTPHeaderField(WebString::fromUTF8("Range"), 946 info.request.addHTTPHeaderField(WebString::fromUTF8("Range"),
948 WebString::fromUTF8(range_info)); 947 WebString::fromUTF8(range_info));
949 } 948 }
950 949
951 if (strcmp(method, "POST") == 0) { 950 if (strcmp(method, "POST") == 0) {
952 // Adds headers or form data to a request. This must be called before 951 // Adds headers or form data to a request. This must be called before
953 // we initiate the actual request. 952 // we initiate the actual request.
954 SetPostData(&info.request, buf, buf_len); 953 SetPostData(&info.request, buf, buf_len);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 true); 994 true);
996 } 995 }
997 996
998 void WebPluginImpl::SetDeferResourceLoading(int resource_id, bool defer) { 997 void WebPluginImpl::SetDeferResourceLoading(int resource_id, bool defer) {
999 std::vector<ClientInfo>::iterator client_index = clients_.begin(); 998 std::vector<ClientInfo>::iterator client_index = clients_.begin();
1000 while (client_index != clients_.end()) { 999 while (client_index != clients_.end()) {
1001 ClientInfo& client_info = *client_index; 1000 ClientInfo& client_info = *client_index;
1002 1001
1003 if (client_info.id == resource_id) { 1002 if (client_info.id == resource_id) {
1004 client_info.loader->setDefersLoading(defer); 1003 client_info.loader->setDefersLoading(defer);
1004
1005 // If we determined that the request had failed via the HTTP headers
1006 // in the response then we send out a failure notification to the
1007 // plugin process, as certain plugins don't handle HTTP failure codes
1008 // correctly.
1009 if (!defer && client_info.client &&
1010 client_info.pending_failure_notification) {
1011 client_info.loader->cancel();
1012 client_info.client->DidFail();
1013 clients_.erase(client_index++);
1014 }
1005 break; 1015 break;
1006 } 1016 }
1007 client_index++; 1017 client_index++;
1008 } 1018 }
1009 } 1019 }
1010 1020
1011 void WebPluginImpl::HandleHttpMultipartResponse( 1021 void WebPluginImpl::HandleHttpMultipartResponse(
1012 const WebURLResponse& response, WebPluginResourceClient* client) { 1022 const WebURLResponse& response, WebPluginResourceClient* client) {
1013 std::string multipart_boundary; 1023 std::string multipart_boundary;
1014 if (!MultipartResponseDelegate::ReadMultipartBoundary( 1024 if (!MultipartResponseDelegate::ReadMultipartBoundary(
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1122 ClientInfo& client_info = *client_index; 1132 ClientInfo& client_info = *client_index;
1123 1133
1124 if (loader_to_ignore == client_info.loader) { 1134 if (loader_to_ignore == client_info.loader) {
1125 client_index++; 1135 client_index++;
1126 continue; 1136 continue;
1127 } 1137 }
1128 1138
1129 if (client_info.loader.get()) 1139 if (client_info.loader.get())
1130 client_info.loader->cancel(); 1140 client_info.loader->cancel();
1131 1141
1132 WebPluginResourceClient* resource_client = client_info.client;
1133 client_index = clients_.erase(client_index); 1142 client_index = clients_.erase(client_index);
1134 if (resource_client)
1135 resource_client->DidFail();
1136 } 1143 }
1137 1144
1138 // This needs to be called now and not in the destructor since the 1145 // This needs to be called now and not in the destructor since the
1139 // webframe_ might not be valid anymore. 1146 // webframe_ might not be valid anymore.
1140 webframe_->set_plugin_delegate(NULL); 1147 webframe_->set_plugin_delegate(NULL);
1141 webframe_ = NULL; 1148 webframe_ = NULL;
1142 method_factory_.RevokeAll(); 1149 method_factory_.RevokeAll();
1143 } 1150 }
1144 1151
1145 WebViewDelegate* WebPluginImpl::GetWebViewDelegate() { 1152 WebViewDelegate* WebPluginImpl::GetWebViewDelegate() {
1146 if (!webframe_) 1153 if (!webframe_)
1147 return NULL; 1154 return NULL;
1148 WebViewImpl* webview = webframe_->GetWebViewImpl(); 1155 WebViewImpl* webview = webframe_->GetWebViewImpl();
1149 return webview ? webview->delegate() : NULL; 1156 return webview ? webview->delegate() : NULL;
1150 } 1157 }
OLDNEW
« no previous file with comments | « webkit/glue/webplugin_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698