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

Side by Side Diff: content/child/npapi/plugin_stream_posix.cc

Issue 99923002: Move temp file functions to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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
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 "content/child/npapi/plugin_stream.h" 5 #include "content/child/npapi/plugin_stream.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 15 matching lines...) Expand all
26 instance_->NPP_StreamAsFile(&stream_, temp_file_path_.value().c_str()); 26 instance_->NPP_StreamAsFile(&stream_, temp_file_path_.value().c_str());
27 } 27 }
28 28
29 size_t PluginStream::WriteBytes(const char* buf, size_t length) { 29 size_t PluginStream::WriteBytes(const char* buf, size_t length) {
30 return fwrite(buf, sizeof(char), length, temp_file_); 30 return fwrite(buf, sizeof(char), length, temp_file_);
31 } 31 }
32 32
33 bool PluginStream::OpenTempFile() { 33 bool PluginStream::OpenTempFile() {
34 DCHECK_EQ(static_cast<FILE*>(NULL), temp_file_); 34 DCHECK_EQ(static_cast<FILE*>(NULL), temp_file_);
35 35
36 if (file_util::CreateTemporaryFile(&temp_file_path_)) 36 if (base::CreateTemporaryFile(&temp_file_path_))
37 temp_file_ = file_util::OpenFile(temp_file_path_, "a"); 37 temp_file_ = file_util::OpenFile(temp_file_path_, "a");
38 38
39 if (!temp_file_) { 39 if (!temp_file_) {
40 base::DeleteFile(temp_file_path_, false); 40 base::DeleteFile(temp_file_path_, false);
41 ResetTempFileName(); 41 ResetTempFileName();
42 return false; 42 return false;
43 } 43 }
44 return true; 44 return true;
45 } 45 }
46 46
47 void PluginStream::CloseTempFile() { 47 void PluginStream::CloseTempFile() {
48 if (!TempFileIsValid()) 48 if (!TempFileIsValid())
49 return; 49 return;
50 50
51 file_util::CloseFile(temp_file_); 51 file_util::CloseFile(temp_file_);
52 ResetTempFileHandle(); 52 ResetTempFileHandle();
53 } 53 }
54 54
55 bool PluginStream::TempFileIsValid() const { 55 bool PluginStream::TempFileIsValid() const {
56 return temp_file_ != NULL; 56 return temp_file_ != NULL;
57 } 57 }
58 58
59 } // namespace content 59 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_drag_win.cc ('k') | content/common/sandbox_mac_diraccess_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698