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 #include "webkit/plugins/npapi/plugin_stream.h" | 5 #include "webkit/plugins/npapi/plugin_stream.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "webkit/plugins/npapi/plugin_instance.h" | 8 #include "webkit/plugins/npapi/plugin_instance.h" |
9 | 9 |
10 namespace webkit { | 10 namespace webkit { |
11 namespace npapi { | 11 namespace npapi { |
12 | 12 |
13 void PluginStream::ResetTempFileHandle() { | 13 void PluginStream::ResetTempFileHandle() { |
14 temp_file_handle_ = INVALID_HANDLE_VALUE; | 14 temp_file_handle_ = INVALID_HANDLE_VALUE; |
15 } | 15 } |
16 | 16 |
17 void PluginStream::ResetTempFileName() { | 17 void PluginStream::ResetTempFileName() { |
18 temp_file_name_[0] = '\0'; | 18 temp_file_name_[0] = '\0'; |
19 } | 19 } |
20 | 20 |
21 void PluginStream::WriteAsFile() { | 21 void PluginStream::WriteAsFile() { |
22 if (requested_plugin_mode_ == NP_ASFILE || | 22 if (RequestedPluginModeIsAsFile()) |
23 requested_plugin_mode_ == NP_ASFILEONLY) | |
24 instance_->NPP_StreamAsFile(&stream_, temp_file_name_); | 23 instance_->NPP_StreamAsFile(&stream_, temp_file_name_); |
25 } | 24 } |
26 | 25 |
27 size_t PluginStream::WriteBytes(const char *buf, size_t length) { | 26 size_t PluginStream::WriteBytes(const char *buf, size_t length) { |
28 DWORD bytes; | 27 DWORD bytes; |
29 | 28 |
30 if (!WriteFile(temp_file_handle_, buf, length, &bytes, 0)) | 29 if (!WriteFile(temp_file_handle_, buf, length, &bytes, 0)) |
31 return 0U; | 30 return 0U; |
32 | 31 |
33 return static_cast<size_t>(bytes); | 32 return static_cast<size_t>(bytes); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 CloseHandle(temp_file_handle_); | 72 CloseHandle(temp_file_handle_); |
74 ResetTempFileHandle(); | 73 ResetTempFileHandle(); |
75 } | 74 } |
76 | 75 |
77 bool PluginStream::TempFileIsValid() const { | 76 bool PluginStream::TempFileIsValid() const { |
78 return temp_file_handle_ != INVALID_HANDLE_VALUE; | 77 return temp_file_handle_ != INVALID_HANDLE_VALUE; |
79 } | 78 } |
80 | 79 |
81 } // namespace npapi | 80 } // namespace npapi |
82 } // namespace webkit | 81 } // namespace webkit |
OLD | NEW |