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 // TODO : Support NP_ASFILEONLY mode | 5 // TODO : Support NP_ASFILEONLY mode |
6 // TODO : Support NP_SEEK mode | 6 // TODO : Support NP_SEEK mode |
7 // TODO : Support SEEKABLE=true in NewStream | 7 // TODO : Support SEEKABLE=true in NewStream |
8 | 8 |
9 #include "webkit/plugins/npapi/plugin_stream.h" | 9 #include "webkit/plugins/npapi/plugin_stream.h" |
10 | 10 |
| 11 #include "base/bind.h" |
11 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
12 #include "base/string_util.h" | 13 #include "base/string_util.h" |
13 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
14 #include "net/base/mime_util.h" | 15 #include "net/base/mime_util.h" |
15 #include "webkit/plugins/npapi/plugin_instance.h" | 16 #include "webkit/plugins/npapi/plugin_instance.h" |
16 #include "googleurl/src/gurl.h" | 17 #include "googleurl/src/gurl.h" |
17 | 18 |
18 namespace webkit { | 19 namespace webkit { |
19 namespace npapi { | 20 namespace npapi { |
20 | 21 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 if (written == -1) | 139 if (written == -1) |
139 return false; | 140 return false; |
140 | 141 |
141 if (written < length) { | 142 if (written < length) { |
142 // Buffer the remaining data. | 143 // Buffer the remaining data. |
143 size_t remaining = length - written; | 144 size_t remaining = length - written; |
144 size_t previous_size = delivery_data_.size(); | 145 size_t previous_size = delivery_data_.size(); |
145 delivery_data_.resize(previous_size + remaining); | 146 delivery_data_.resize(previous_size + remaining); |
146 data_offset_ = data_offset; | 147 data_offset_ = data_offset; |
147 memcpy(&delivery_data_[previous_size], buf + written, remaining); | 148 memcpy(&delivery_data_[previous_size], buf + written, remaining); |
148 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( | 149 MessageLoop::current()->PostTask( |
149 this, &PluginStream::OnDelayDelivery)); | 150 FROM_HERE, base::Bind(&PluginStream::OnDelayDelivery, this)); |
150 } | 151 } |
151 | 152 |
152 return true; | 153 return true; |
153 } | 154 } |
154 | 155 |
155 void PluginStream::OnDelayDelivery() { | 156 void PluginStream::OnDelayDelivery() { |
156 // It is possible that the plugin stream may have closed before the task | 157 // It is possible that the plugin stream may have closed before the task |
157 // was hit. | 158 // was hit. |
158 if (!opened_) { | 159 if (!opened_) { |
159 return; | 160 return; |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 | 252 |
252 void PluginStream::Notify(NPReason reason) { | 253 void PluginStream::Notify(NPReason reason) { |
253 if (notify_needed_) { | 254 if (notify_needed_) { |
254 instance_->NPP_URLNotify(stream_.url, reason, notify_data_); | 255 instance_->NPP_URLNotify(stream_.url, reason, notify_data_); |
255 notify_needed_ = false; | 256 notify_needed_ = false; |
256 } | 257 } |
257 } | 258 } |
258 | 259 |
259 } // namespace npapi | 260 } // namespace npapi |
260 } // namespace webkit | 261 } // namespace webkit |
OLD | NEW |