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

Side by Side Diff: base/platform_file.h

Issue 2878062: Asynchronously open the temp file used for Pepper StreamToFile, and delete th... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 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 | « base/base.gypi ('k') | base/scoped_callback_factory.h » ('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) 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 #ifndef BASE_PLATFORM_FILE_H_ 5 #ifndef BASE_PLATFORM_FILE_H_
6 #define BASE_PLATFORM_FILE_H_ 6 #define BASE_PLATFORM_FILE_H_
7 #pragma once 7 #pragma once
8 8
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #if defined(OS_WIN) 10 #if defined(OS_WIN)
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 int flags, 47 int flags,
48 bool* created); 48 bool* created);
49 // Deprecated. 49 // Deprecated.
50 PlatformFile CreatePlatformFile(const std::wstring& name, 50 PlatformFile CreatePlatformFile(const std::wstring& name,
51 int flags, 51 int flags,
52 bool* created); 52 bool* created);
53 53
54 // Closes a file handle 54 // Closes a file handle
55 bool ClosePlatformFile(PlatformFile file); 55 bool ClosePlatformFile(PlatformFile file);
56 56
57 // Use this class to pass ownership of a PlatformFile to a receiver that may or
58 // may not want to accept it. This class does not own the storage for the
59 // PlatformFile.
60 //
61 // EXAMPLE:
62 //
63 // void MaybeProcessFile(PassPlatformFile pass_file) {
64 // if (...) {
65 // PlatformFile file = pass_file.ReleaseValue();
66 // // Now, we are responsible for closing |file|.
67 // }
68 // }
69 //
70 // void OpenAndMaybeProcessFile(const FilePath& path) {
71 // PlatformFile file = CreatePlatformFile(path, ...);
72 // MaybeProcessFile(PassPlatformFile(&file));
73 // if (file != kInvalidPlatformFileValue)
74 // ClosePlatformFile(file);
75 // }
76 //
77 class PassPlatformFile {
78 public:
79 explicit PassPlatformFile(PlatformFile* value) : value_(value) {
80 }
81
82 // Called to retrieve the PlatformFile stored in this object. The caller
83 // gains ownership of the PlatformFile and is now responsible for closing it.
84 // Any subsequent calls to this method will return an invalid PlatformFile.
85 PlatformFile ReleaseValue() {
86 PlatformFile temp = *value_;
87 *value_ = kInvalidPlatformFileValue;
88 return temp;
89 }
90
91 private:
92 PlatformFile* value_;
93 };
94
57 } // namespace base 95 } // namespace base
58 96
59 #endif // BASE_PLATFORM_FILE_H_ 97 #endif // BASE_PLATFORM_FILE_H_
OLDNEW
« no previous file with comments | « base/base.gypi ('k') | base/scoped_callback_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698