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/plugins/npapi/plugin_stream_url.h" | 5 #include "webkit/plugins/npapi/plugin_stream_url.h" |
6 | 6 |
7 #include "net/http/http_response_headers.h" | 7 #include "net/http/http_response_headers.h" |
8 #include "webkit/plugins/npapi/plugin_host.h" | 8 #include "webkit/plugins/npapi/plugin_host.h" |
9 #include "webkit/plugins/npapi/plugin_instance.h" | 9 #include "webkit/plugins/npapi/plugin_instance.h" |
10 #include "webkit/plugins/npapi/plugin_lib.h" | 10 #include "webkit/plugins/npapi/plugin_lib.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 instance()->webplugin()->ResourceClientDeleted(AsResourceClient()); | 29 instance()->webplugin()->ResourceClientDeleted(AsResourceClient()); |
30 } | 30 } |
31 } | 31 } |
32 | 32 |
33 bool PluginStreamUrl::Close(NPReason reason) { | 33 bool PluginStreamUrl::Close(NPReason reason) { |
34 // Protect the stream against it being destroyed or the whole plugin instance | 34 // Protect the stream against it being destroyed or the whole plugin instance |
35 // being destroyed within the destroy stream handler. | 35 // being destroyed within the destroy stream handler. |
36 scoped_refptr<PluginStream> protect(this); | 36 scoped_refptr<PluginStream> protect(this); |
37 CancelRequest(); | 37 CancelRequest(); |
38 bool result = PluginStream::Close(reason); | 38 bool result = PluginStream::Close(reason); |
39 instance()->RemoveStream(this); | 39 instance()->RemoveStream(protect); |
40 return result; | 40 return result; |
41 } | 41 } |
42 | 42 |
43 WebPluginResourceClient* PluginStreamUrl::AsResourceClient() { | 43 WebPluginResourceClient* PluginStreamUrl::AsResourceClient() { |
44 return static_cast<WebPluginResourceClient*>(this); | 44 return static_cast<WebPluginResourceClient*>(this); |
45 } | 45 } |
46 | 46 |
47 void PluginStreamUrl::WillSendRequest(const GURL& url, int http_status_code) { | 47 void PluginStreamUrl::WillSendRequest(const GURL& url, int http_status_code) { |
48 if (notify_needed()) { | 48 if (notify_needed()) { |
49 // If the plugin participates in HTTP url redirect handling then notify it. | 49 // If the plugin participates in HTTP url redirect handling then notify it. |
(...skipping 18 matching lines...) Expand all Loading... |
68 // being destroyed within the new stream handler. | 68 // being destroyed within the new stream handler. |
69 scoped_refptr<PluginStream> protect(this); | 69 scoped_refptr<PluginStream> protect(this); |
70 | 70 |
71 bool opened = Open(mime_type, | 71 bool opened = Open(mime_type, |
72 headers, | 72 headers, |
73 expected_length, | 73 expected_length, |
74 last_modified, | 74 last_modified, |
75 request_is_seekable); | 75 request_is_seekable); |
76 if (!opened) { | 76 if (!opened) { |
77 CancelRequest(); | 77 CancelRequest(); |
78 instance()->RemoveStream(this); | 78 instance()->RemoveStream(protect); |
79 } else { | 79 } else { |
80 if (id_ > 0) | 80 if (id_ > 0) |
81 instance()->webplugin()->SetDeferResourceLoading(id_, false); | 81 instance()->webplugin()->SetDeferResourceLoading(id_, false); |
82 } | 82 } |
83 } | 83 } |
84 | 84 |
85 void PluginStreamUrl::DidReceiveData(const char* buffer, int length, | 85 void PluginStreamUrl::DidReceiveData(const char* buffer, int length, |
86 int data_offset) { | 86 int data_offset) { |
87 if (!open()) | 87 if (!open()) |
88 return; | 88 return; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 if (id_ > 0) { | 123 if (id_ > 0) { |
124 if (instance()->webplugin()) { | 124 if (instance()->webplugin()) { |
125 instance()->webplugin()->CancelResource(id_); | 125 instance()->webplugin()->CancelResource(id_); |
126 } | 126 } |
127 id_ = 0; | 127 id_ = 0; |
128 } | 128 } |
129 } | 129 } |
130 | 130 |
131 } // namespace npapi | 131 } // namespace npapi |
132 } // namespace webkit | 132 } // namespace webkit |
OLD | NEW |