| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "webkit/glue/plugins/plugin_data_stream.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 | |
| 9 namespace NPAPI { | |
| 10 | |
| 11 PluginDataStream::PluginDataStream(PluginInstance *instance, | |
| 12 const std::string& url, | |
| 13 const std::string& mime_type, | |
| 14 const std::string& headers, | |
| 15 uint32 expected_length, | |
| 16 uint32 last_modified) | |
| 17 : PluginStream(instance, url.c_str(), false, 0), | |
| 18 mime_type_(mime_type), | |
| 19 headers_(headers), | |
| 20 expected_length_(expected_length), | |
| 21 last_modified_(last_modified), | |
| 22 stream_open_failed_(false) { | |
| 23 } | |
| 24 | |
| 25 PluginDataStream::~PluginDataStream() { | |
| 26 } | |
| 27 | |
| 28 void PluginDataStream::SendToPlugin(const char* buffer, int length) { | |
| 29 if (stream_open_failed_) | |
| 30 return; | |
| 31 | |
| 32 if (!open()) { | |
| 33 if (!Open(mime_type_, headers_, expected_length_, last_modified_)) { | |
| 34 stream_open_failed_ = true; | |
| 35 return; | |
| 36 } | |
| 37 } | |
| 38 | |
| 39 // TODO(iyengar) - check if it was not fully sent, and figure out a | |
| 40 // backup plan. | |
| 41 int written = Write(buffer, length); | |
| 42 DCHECK(written == length); | |
| 43 } | |
| 44 | |
| 45 } // namespace NPAPI | |
| 46 | |
| OLD | NEW |