| OLD | NEW |
| 1 // Copyright (c) 2010 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/plugins/npapi/plugin_string_stream.h" | 5 #include "webkit/glue/plugins/plugin_string_stream.h" |
| 6 | 6 |
| 7 #include "googleurl/src/gurl.h" | 7 #include "googleurl/src/gurl.h" |
| 8 | 8 |
| 9 namespace webkit { | 9 namespace NPAPI { |
| 10 namespace npapi { | |
| 11 | 10 |
| 12 PluginStringStream::PluginStringStream( | 11 PluginStringStream::PluginStringStream( |
| 13 PluginInstance* instance, | 12 PluginInstance* instance, |
| 14 const GURL& url, | 13 const GURL& url, |
| 15 bool notify_needed, | 14 bool notify_needed, |
| 16 void* notify_data) | 15 void* notify_data) |
| 17 : PluginStream(instance, url.spec().c_str(), notify_needed, notify_data) { | 16 : PluginStream(instance, url.spec().c_str(), notify_needed, notify_data) { |
| 18 } | 17 } |
| 19 | 18 |
| 20 PluginStringStream::~PluginStringStream() { | 19 PluginStringStream::~PluginStringStream() { |
| 21 } | 20 } |
| 22 | 21 |
| 23 void PluginStringStream::SendToPlugin(const std::string &data, | 22 void PluginStringStream::SendToPlugin(const std::string &data, |
| 24 const std::string &mime_type) { | 23 const std::string &mime_type) { |
| 25 // Protect the stream against it being destroyed or the whole plugin instance | 24 // Protect the stream against it being destroyed or the whole plugin instance |
| 26 // being destroyed within the plugin stream callbacks. | 25 // being destroyed within the plugin stream callbacks. |
| 27 scoped_refptr<PluginStringStream> protect(this); | 26 scoped_refptr<PluginStringStream> protect(this); |
| 28 | 27 |
| 29 int length = static_cast<int>(data.length()); | 28 int length = static_cast<int>(data.length()); |
| 30 if (Open(mime_type, std::string(), length, 0, false)) { | 29 if (Open(mime_type, std::string(), length, 0, false)) { |
| 31 // TODO - check if it was not fully sent, and figure out a backup plan. | 30 // TODO - check if it was not fully sent, and figure out a backup plan. |
| 32 int written = Write(data.c_str(), length, 0); | 31 int written = Write(data.c_str(), length, 0); |
| 33 NPReason reason = written == length ? NPRES_DONE : NPRES_NETWORK_ERR; | 32 NPReason reason = written == length ? NPRES_DONE : NPRES_NETWORK_ERR; |
| 34 Close(reason); | 33 Close(reason); |
| 35 } | 34 } |
| 36 } | 35 } |
| 37 | 36 |
| 38 } // namespace npapi | 37 } |
| 39 } // namespace webkit | |
| OLD | NEW |