diff options
Diffstat (limited to 'webkit/plugins/npapi/plugin_stream_win.cc')
-rw-r--r-- | webkit/plugins/npapi/plugin_stream_win.cc | 41 |
1 files changed, 11 insertions, 30 deletions
diff --git a/webkit/plugins/npapi/plugin_stream_win.cc b/webkit/plugins/npapi/plugin_stream_win.cc index edc9770..62ecc11d9 100644 --- a/webkit/plugins/npapi/plugin_stream_win.cc +++ b/webkit/plugins/npapi/plugin_stream_win.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -10,32 +10,11 @@ namespace webkit { namespace npapi { -PluginStream::PluginStream( - PluginInstance *instance, - const char *url, - bool need_notify, - void *notify_data) - : instance_(instance), - notify_needed_(need_notify), - notify_data_(notify_data), - close_on_write_data_(false), - opened_(false), - requested_plugin_mode_(NP_NORMAL), - temp_file_handle_(INVALID_HANDLE_VALUE), - seekable_stream_(false), - data_offset_(0) { - memset(&stream_, 0, sizeof(stream_)); - stream_.url = _strdup(url); +void PluginStream::ResetTempFilenameAndHandle() { + temp_file_handle_ = INVALID_HANDLE_VALUE; temp_file_name_[0] = '\0'; } -void PluginStream::UpdateUrl(const char* url) { - DCHECK(!opened_); - free(const_cast<char*>(stream_.url)); - stream_.url = _strdup(url); - pending_redirect_url_.clear(); -} - void PluginStream::WriteAsFile() { if (requested_plugin_mode_ == NP_ASFILE || requested_plugin_mode_ == NP_ASFILEONLY) @@ -52,7 +31,7 @@ size_t PluginStream::WriteBytes(const char *buf, size_t length) { } bool PluginStream::OpenTempFile() { - DCHECK(temp_file_handle_ == INVALID_HANDLE_VALUE); + DCHECK_EQ(INVALID_HANDLE_VALUE, temp_file_handle_); // The reason for using all the Ascii versions of these filesystem // calls is that the filename which we pass back to the plugin @@ -85,13 +64,15 @@ bool PluginStream::OpenTempFile() { } void PluginStream::CloseTempFile() { - if (temp_file_handle_ != INVALID_HANDLE_VALUE) { - CloseHandle(temp_file_handle_); - temp_file_handle_ = INVALID_HANDLE_VALUE; - } + if (!TempFileIsValid()) + return; + + CloseHandle(temp_file_handle_); + DeleteFileA(temp_file_name_); + ResetTempFilenameAndHandle(); } -bool PluginStream::TempFileIsValid() { +bool PluginStream::TempFileIsValid() const { return temp_file_handle_ != INVALID_HANDLE_VALUE; } |