Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: webkit/plugins/npapi/plugin_stream_posix.cc

Issue 10495008: Further cleanup in PluginStream. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: rebase Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/plugins/npapi/plugin_stream.cc ('k') | webkit/plugins/npapi/plugin_stream_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <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"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "webkit/plugins/npapi/plugin_instance.h" 12 #include "webkit/plugins/npapi/plugin_instance.h"
13 13
14 namespace webkit { 14 namespace webkit {
15 namespace npapi { 15 namespace npapi {
16 16
17 void PluginStream::ResetTempFileHandle() { 17 void PluginStream::ResetTempFileHandle() {
18 temp_file_ = NULL; 18 temp_file_ = NULL;
19 } 19 }
20 20
21 void PluginStream::ResetTempFileName() { 21 void PluginStream::ResetTempFileName() {
22 temp_file_path_ = FilePath(); 22 temp_file_path_ = FilePath();
23 } 23 }
24 24
25 void PluginStream::WriteAsFile() { 25 void PluginStream::WriteAsFile() {
26 if (requested_plugin_mode_ == NP_ASFILE || 26 if (RequestedPluginModeIsAsFile())
27 requested_plugin_mode_ == NP_ASFILEONLY) {
28 instance_->NPP_StreamAsFile(&stream_, temp_file_path_.value().c_str()); 27 instance_->NPP_StreamAsFile(&stream_, temp_file_path_.value().c_str());
29 }
30 } 28 }
31 29
32 size_t PluginStream::WriteBytes(const char* buf, size_t length) { 30 size_t PluginStream::WriteBytes(const char* buf, size_t length) {
33 return fwrite(buf, sizeof(char), length, temp_file_); 31 return fwrite(buf, sizeof(char), length, temp_file_);
34 } 32 }
35 33
36 bool PluginStream::OpenTempFile() { 34 bool PluginStream::OpenTempFile() {
37 DCHECK_EQ(static_cast<FILE*>(NULL), temp_file_); 35 DCHECK_EQ(static_cast<FILE*>(NULL), temp_file_);
38 36
39 if (file_util::CreateTemporaryFile(&temp_file_path_)) 37 if (file_util::CreateTemporaryFile(&temp_file_path_))
(...skipping 14 matching lines...) Expand all
54 file_util::CloseFile(temp_file_); 52 file_util::CloseFile(temp_file_);
55 ResetTempFileHandle(); 53 ResetTempFileHandle();
56 } 54 }
57 55
58 bool PluginStream::TempFileIsValid() const { 56 bool PluginStream::TempFileIsValid() const {
59 return temp_file_ != NULL; 57 return temp_file_ != NULL;
60 } 58 }
61 59
62 } // namespace npapi 60 } // namespace npapi
63 } // namespace webkit 61 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/npapi/plugin_stream.cc ('k') | webkit/plugins/npapi/plugin_stream_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698