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

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

Issue 393017: This CL fixes the document-open.html and window-open.html plugin layout tests... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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) 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 "webkit/glue/plugins/plugin_stream_url.h" 5 #include "webkit/glue/plugins/plugin_stream_url.h"
6 6
7 #include "webkit/glue/glue_util.h" 7 #include "webkit/glue/glue_util.h"
8 #include "webkit/glue/webplugin.h" 8 #include "webkit/glue/webplugin.h"
9 #include "webkit/glue/plugins/plugin_host.h" 9 #include "webkit/glue/plugins/plugin_host.h"
10 #include "webkit/glue/plugins/plugin_instance.h" 10 #include "webkit/glue/plugins/plugin_instance.h"
(...skipping 11 matching lines...) Expand all
22 id_(resource_id) { 22 id_(resource_id) {
23 } 23 }
24 24
25 PluginStreamUrl::~PluginStreamUrl() { 25 PluginStreamUrl::~PluginStreamUrl() {
26 if (instance() && instance()->webplugin()) { 26 if (instance() && instance()->webplugin()) {
27 instance()->webplugin()->ResourceClientDeleted(AsResourceClient()); 27 instance()->webplugin()->ResourceClientDeleted(AsResourceClient());
28 } 28 }
29 } 29 }
30 30
31 bool PluginStreamUrl::Close(NPReason reason) { 31 bool PluginStreamUrl::Close(NPReason reason) {
32 // Protect the stream against it being destroyed or the whole plugin instance
33 // being destroyed within the destroy stream handler.
34 scoped_refptr<PluginStream> protect(this);
32 CancelRequest(); 35 CancelRequest();
33 bool result = PluginStream::Close(reason); 36 bool result = PluginStream::Close(reason);
34 instance()->RemoveStream(this); 37 instance()->RemoveStream(this);
35 return result; 38 return result;
36 } 39 }
37 40
38 void PluginStreamUrl::WillSendRequest(const GURL& url) { 41 void PluginStreamUrl::WillSendRequest(const GURL& url) {
39 url_ = url; 42 url_ = url;
40 UpdateUrl(url.spec().c_str()); 43 UpdateUrl(url.spec().c_str());
41 } 44 }
42 45
43 void PluginStreamUrl::DidReceiveResponse(const std::string& mime_type, 46 void PluginStreamUrl::DidReceiveResponse(const std::string& mime_type,
44 const std::string& headers, 47 const std::string& headers,
45 uint32 expected_length, 48 uint32 expected_length,
46 uint32 last_modified, 49 uint32 last_modified,
47 bool request_is_seekable) { 50 bool request_is_seekable) {
51 // Protect the stream against it being destroyed or the whole plugin instance
52 // being destroyed within the new stream handler.
53 scoped_refptr<PluginStream> protect(this);
54
48 bool opened = Open(mime_type, 55 bool opened = Open(mime_type,
49 headers, 56 headers,
50 expected_length, 57 expected_length,
51 last_modified, 58 last_modified,
52 request_is_seekable); 59 request_is_seekable);
53 if (!opened) { 60 if (!opened) {
54 CancelRequest(); 61 CancelRequest();
55 instance()->RemoveStream(this); 62 instance()->RemoveStream(this);
56 } else { 63 } else {
57 if (id_ > 0) 64 if (id_ > 0)
58 instance()->webplugin()->SetDeferResourceLoading(id_, false); 65 instance()->webplugin()->SetDeferResourceLoading(id_, false);
59 } 66 }
60 } 67 }
61 68
62 void PluginStreamUrl::DidReceiveData(const char* buffer, int length, 69 void PluginStreamUrl::DidReceiveData(const char* buffer, int length,
63 int data_offset) { 70 int data_offset) {
64 if (!open()) 71 if (!open())
65 return; 72 return;
66 73
74 // Protect the stream against it being destroyed or the whole plugin instance
75 // being destroyed within the write handlers
76 scoped_refptr<PluginStream> protect(this);
77
67 if (length > 0) { 78 if (length > 0) {
68 // The PluginStreamUrl instance could get deleted if the plugin fails to 79 // The PluginStreamUrl instance could get deleted if the plugin fails to
69 // accept data in NPP_Write. 80 // accept data in NPP_Write.
70 if (Write(const_cast<char*>(buffer), length, data_offset) > 0) { 81 if (Write(const_cast<char*>(buffer), length, data_offset) > 0) {
71 if (id_ > 0) 82 if (id_ > 0)
72 instance()->webplugin()->SetDeferResourceLoading(id_, false); 83 instance()->webplugin()->SetDeferResourceLoading(id_, false);
73 } 84 }
74 } 85 }
75 } 86 }
76 87
(...skipping 10 matching lines...) Expand all
87 void PluginStreamUrl::CancelRequest() { 98 void PluginStreamUrl::CancelRequest() {
88 if (id_ > 0) { 99 if (id_ > 0) {
89 if (instance()->webplugin()) { 100 if (instance()->webplugin()) {
90 instance()->webplugin()->CancelResource(id_); 101 instance()->webplugin()->CancelResource(id_);
91 } 102 }
92 id_ = 0; 103 id_ = 0;
93 } 104 }
94 } 105 }
95 106
96 } // namespace NPAPI 107 } // namespace NPAPI
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698