OLD | NEW |
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 "webkit/plugins/npapi/plugin_instance.h" | 5 #include "webkit/plugins/npapi/plugin_instance.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 resource_id, url, this, notify, notify_data); | 90 resource_id, url, this, notify, notify_data); |
91 | 91 |
92 AddStream(stream); | 92 AddStream(stream); |
93 return stream; | 93 return stream; |
94 } | 94 } |
95 | 95 |
96 void PluginInstance::AddStream(PluginStream* stream) { | 96 void PluginInstance::AddStream(PluginStream* stream) { |
97 open_streams_.push_back(make_scoped_refptr(stream)); | 97 open_streams_.push_back(make_scoped_refptr(stream)); |
98 } | 98 } |
99 | 99 |
100 void PluginInstance::RemoveStream(PluginStream* stream) { | 100 void PluginInstance::RemoveStream(scoped_refptr<PluginStream> stream) { |
101 if (in_close_streams_) | 101 if (in_close_streams_) |
102 return; | 102 return; |
103 | 103 |
104 std::vector<scoped_refptr<PluginStream> >::iterator stream_index; | 104 std::vector<scoped_refptr<PluginStream> >::iterator stream_index; |
105 for (stream_index = open_streams_.begin(); | 105 for (stream_index = open_streams_.begin(); |
106 stream_index != open_streams_.end(); ++stream_index) { | 106 stream_index != open_streams_.end(); ++stream_index) { |
107 if (*stream_index == stream) { | 107 if (*stream_index == stream) { |
108 open_streams_.erase(stream_index); | 108 open_streams_.erase(stream_index); |
109 break; | 109 break; |
110 } | 110 } |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 | 540 |
541 // The lifetime of a NPStream instance depends on the PluginStream instance | 541 // The lifetime of a NPStream instance depends on the PluginStream instance |
542 // which owns it. When a plugin invokes NPN_RequestRead on a seekable stream, | 542 // which owns it. When a plugin invokes NPN_RequestRead on a seekable stream, |
543 // we don't want to create a new stream when the corresponding response is | 543 // we don't want to create a new stream when the corresponding response is |
544 // received. We send over a cookie which represents the PluginStream | 544 // received. We send over a cookie which represents the PluginStream |
545 // instance which is sent back from the renderer when the response is | 545 // instance which is sent back from the renderer when the response is |
546 // received. | 546 // received. |
547 std::vector<scoped_refptr<PluginStream> >::iterator stream_index; | 547 std::vector<scoped_refptr<PluginStream> >::iterator stream_index; |
548 for (stream_index = open_streams_.begin(); | 548 for (stream_index = open_streams_.begin(); |
549 stream_index != open_streams_.end(); ++stream_index) { | 549 stream_index != open_streams_.end(); ++stream_index) { |
550 PluginStream* plugin_stream = *stream_index; | 550 scoped_refptr<PluginStream> plugin_stream = *stream_index; |
551 if (plugin_stream->stream() == stream) { | 551 if (plugin_stream->stream() == stream) { |
552 // A stream becomes seekable the first time NPN_RequestRead | 552 // A stream becomes seekable the first time NPN_RequestRead |
553 // is called on it. | 553 // is called on it. |
554 plugin_stream->set_seekable(true); | 554 plugin_stream->set_seekable(true); |
555 | 555 |
556 pending_range_requests_[++next_range_request_id_] = plugin_stream; | 556 pending_range_requests_[++next_range_request_id_] = plugin_stream; |
557 webplugin_->InitiateHTTPRangeRequest( | 557 webplugin_->InitiateHTTPRangeRequest( |
558 stream->url, range_info.c_str(), next_range_request_id_); | 558 stream->url, range_info.c_str(), next_range_request_id_); |
559 return; | 559 return; |
560 } | 560 } |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
661 *notify = false; | 661 *notify = false; |
662 *notify_data = NULL; | 662 *notify_data = NULL; |
663 } | 663 } |
664 } | 664 } |
665 | 665 |
666 void PluginInstance::URLRedirectResponse(bool allow, void* notify_data) { | 666 void PluginInstance::URLRedirectResponse(bool allow, void* notify_data) { |
667 // The notify_data passed in allows us to identify the matching stream. | 667 // The notify_data passed in allows us to identify the matching stream. |
668 std::vector<scoped_refptr<PluginStream> >::iterator stream_index; | 668 std::vector<scoped_refptr<PluginStream> >::iterator stream_index; |
669 for (stream_index = open_streams_.begin(); | 669 for (stream_index = open_streams_.begin(); |
670 stream_index != open_streams_.end(); ++stream_index) { | 670 stream_index != open_streams_.end(); ++stream_index) { |
671 PluginStream* plugin_stream = *stream_index; | 671 scoped_refptr<PluginStream> plugin_stream = *stream_index; |
672 if (plugin_stream->notify_data() == notify_data) { | 672 if (plugin_stream->notify_data() == notify_data) { |
673 WebPluginResourceClient* resource_client = | 673 WebPluginResourceClient* resource_client = |
674 plugin_stream->AsResourceClient(); | 674 plugin_stream->AsResourceClient(); |
675 webplugin_->URLRedirectResponse(allow, resource_client->ResourceId()); | 675 webplugin_->URLRedirectResponse(allow, resource_client->ResourceId()); |
676 if (allow) { | 676 if (allow) { |
677 plugin_stream->UpdateUrl( | 677 plugin_stream->UpdateUrl( |
678 plugin_stream->pending_redirect_url().c_str()); | 678 plugin_stream->pending_redirect_url().c_str()); |
679 } | 679 } |
680 break; | 680 break; |
681 } | 681 } |
682 } | 682 } |
683 } | 683 } |
684 | 684 |
685 } // namespace npapi | 685 } // namespace npapi |
686 } // namespace webkit | 686 } // namespace webkit |
OLD | NEW |