OLD | NEW |
1 // Copyright (c) 2006-2008 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/glue/plugins/plugin_stream.h" | 5 #include "webkit/glue/plugins/plugin_stream.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 instance_->NPP_StreamAsFile(&stream_, temp_file_path_.value().c_str()); | 44 instance_->NPP_StreamAsFile(&stream_, temp_file_path_.value().c_str()); |
45 } | 45 } |
46 | 46 |
47 size_t PluginStream::WriteBytes(const char *buf, size_t length) { | 47 size_t PluginStream::WriteBytes(const char *buf, size_t length) { |
48 return fwrite(buf, sizeof(char), length, temp_file_); | 48 return fwrite(buf, sizeof(char), length, temp_file_); |
49 } | 49 } |
50 | 50 |
51 bool PluginStream::OpenTempFile() { | 51 bool PluginStream::OpenTempFile() { |
52 DCHECK(temp_file_ == NULL); | 52 DCHECK(temp_file_ == NULL); |
53 | 53 |
54 if (file_util::CreateTemporaryFileName(&temp_file_path_)) | 54 if (file_util::CreateTemporaryFile(&temp_file_path_)) |
55 temp_file_ = file_util::OpenFile(temp_file_path_, "a"); | 55 temp_file_ = file_util::OpenFile(temp_file_path_, "a"); |
56 | 56 |
57 if (!temp_file_) { | 57 if (!temp_file_) { |
58 temp_file_path_ = FilePath(""); | 58 temp_file_path_ = FilePath(""); |
59 return false; | 59 return false; |
60 } | 60 } |
61 | 61 |
62 return true; | 62 return true; |
63 } | 63 } |
64 | 64 |
65 void PluginStream::CloseTempFile() { | 65 void PluginStream::CloseTempFile() { |
66 file_util::CloseFile(temp_file_); | 66 file_util::CloseFile(temp_file_); |
67 temp_file_ = NULL; | 67 temp_file_ = NULL; |
68 } | 68 } |
69 | 69 |
70 bool PluginStream::TempFileIsValid() { | 70 bool PluginStream::TempFileIsValid() { |
71 return temp_file_ != NULL; | 71 return temp_file_ != NULL; |
72 } | 72 } |
73 | 73 |
74 } // namespace NPAPI | 74 } // namespace NPAPI |
OLD | NEW |