| 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 // 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 "content/child/npapi/plugin_stream.h" | 9 #include "content/child/npapi/plugin_stream.h" |
| 10 | 10 |
| 11 #include <algorithm> | 11 #include <algorithm> |
| 12 | 12 |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/message_loop/message_loop.h" | 14 #include "base/location.h" |
| 15 #include "base/single_thread_task_runner.h" |
| 15 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 18 #include "base/thread_task_runner_handle.h" |
| 17 #include "content/child/npapi/plugin_instance.h" | 19 #include "content/child/npapi/plugin_instance.h" |
| 18 #include "net/base/mime_util.h" | 20 #include "net/base/mime_util.h" |
| 19 #include "url/gurl.h" | 21 #include "url/gurl.h" |
| 20 | 22 |
| 21 namespace content { | 23 namespace content { |
| 22 | 24 |
| 23 PluginStream::PluginStream( | 25 PluginStream::PluginStream( |
| 24 PluginInstance* instance, | 26 PluginInstance* instance, |
| 25 const char* url, | 27 const char* url, |
| 26 bool need_notify, | 28 bool need_notify, |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 if (written == -1) | 158 if (written == -1) |
| 157 return false; | 159 return false; |
| 158 | 160 |
| 159 if (written < length) { | 161 if (written < length) { |
| 160 // Buffer the remaining data. | 162 // Buffer the remaining data. |
| 161 size_t remaining = length - written; | 163 size_t remaining = length - written; |
| 162 size_t previous_size = delivery_data_.size(); | 164 size_t previous_size = delivery_data_.size(); |
| 163 delivery_data_.resize(previous_size + remaining); | 165 delivery_data_.resize(previous_size + remaining); |
| 164 data_offset_ = data_offset; | 166 data_offset_ = data_offset; |
| 165 memcpy(&delivery_data_[previous_size], buf + written, remaining); | 167 memcpy(&delivery_data_[previous_size], buf + written, remaining); |
| 166 base::MessageLoop::current()->PostTask( | 168 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 167 FROM_HERE, base::Bind(&PluginStream::OnDelayDelivery, this)); | 169 FROM_HERE, base::Bind(&PluginStream::OnDelayDelivery, this)); |
| 168 } | 170 } |
| 169 | 171 |
| 170 return true; | 172 return true; |
| 171 } | 173 } |
| 172 | 174 |
| 173 void PluginStream::OnDelayDelivery() { | 175 void PluginStream::OnDelayDelivery() { |
| 174 // It is possible that the plugin stream may have closed before the task | 176 // It is possible that the plugin stream may have closed before the task |
| 175 // was hit. | 177 // was hit. |
| 176 if (!opened_) | 178 if (!opened_) |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 notify_needed_ = false; | 273 notify_needed_ = false; |
| 272 } | 274 } |
| 273 } | 275 } |
| 274 | 276 |
| 275 bool PluginStream::RequestedPluginModeIsAsFile() const { | 277 bool PluginStream::RequestedPluginModeIsAsFile() const { |
| 276 return (requested_plugin_mode_ == NP_ASFILE || | 278 return (requested_plugin_mode_ == NP_ASFILE || |
| 277 requested_plugin_mode_ == NP_ASFILEONLY); | 279 requested_plugin_mode_ == NP_ASFILEONLY); |
| 278 } | 280 } |
| 279 | 281 |
| 280 } // namespace content | 282 } // namespace content |
| OLD | NEW |