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

Side by Side Diff: trunk/src/ppapi/native_client/src/trusted/plugin/temporary_file.h

Issue 406383002: Revert 284766 "Pepper: Simplify TempFile in trusted plugin." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 5 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
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 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_TEMPORARY_FILE_H_ 5 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_TEMPORARY_FILE_H_
6 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_TEMPORARY_FILE_H_ 6 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_TEMPORARY_FILE_H_
7 7
8 #include "native_client/src/include/nacl_macros.h" 8 #include "native_client/src/include/nacl_macros.h"
9 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h" 9 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h"
10 10
(...skipping 17 matching lines...) Expand all
28 // 28 //
29 29
30 // TempFile represents a file used as a temporary between stages in 30 // TempFile represents a file used as a temporary between stages in
31 // translation. It is automatically deleted when all handles are closed 31 // translation. It is automatically deleted when all handles are closed
32 // (or earlier -- immediately unlinked on POSIX systems). The file is only 32 // (or earlier -- immediately unlinked on POSIX systems). The file is only
33 // opened, once, but because both reading and writing are necessary (and in 33 // opened, once, but because both reading and writing are necessary (and in
34 // different processes), the user should reset / seek back to the beginning 34 // different processes), the user should reset / seek back to the beginning
35 // of the file between sessions. 35 // of the file between sessions.
36 class TempFile { 36 class TempFile {
37 public: 37 public:
38 TempFile(Plugin* plugin, PP_FileHandle handle); 38 // Create a TempFile.
39 explicit TempFile(Plugin* plugin);
39 ~TempFile(); 40 ~TempFile();
40 41
41 // Opens a temporary file object and descriptor wrapper referring to the file. 42 // Opens a temporary file object and descriptor wrapper referring to the file.
42 // If |writeable| is true, the descriptor will be opened for writing, and 43 // If |writeable| is true, the descriptor will be opened for writing, and
43 // write_wrapper will return a valid pointer, otherwise it will return NULL. 44 // write_wrapper will return a valid pointer, otherwise it will return NULL.
44 int32_t Open(bool writeable); 45 int32_t Open(bool writeable);
45 // Resets file position of the handle, for reuse. 46 // Resets file position of the handle, for reuse.
46 bool Reset(); 47 bool Reset();
47 48
48 // Accessors. 49 // Accessors.
49 // The nacl::DescWrapper* for the writeable version of the file. 50 // The nacl::DescWrapper* for the writeable version of the file.
50 nacl::DescWrapper* write_wrapper() { return write_wrapper_.get(); } 51 nacl::DescWrapper* write_wrapper() { return write_wrapper_.get(); }
51 nacl::DescWrapper* read_wrapper() { return read_wrapper_.get(); } 52 nacl::DescWrapper* read_wrapper() { return read_wrapper_.get(); }
52 53
53 // Returns the handle to the file repesented and resets the internal handle 54 // Returns the handle to the file repesented and resets the internal handle
54 // and all wrappers. 55 // and all wrappers.
55 PP_FileHandle TakeFileHandle(); 56 PP_FileHandle TakeFileHandle();
56 57
58 // Used by GetNexeFd() to set the underlying internal handle.
59 PP_FileHandle* internal_handle() { return &internal_handle_; }
60
57 private: 61 private:
58 NACL_DISALLOW_COPY_AND_ASSIGN(TempFile); 62 NACL_DISALLOW_COPY_AND_ASSIGN(TempFile);
59 63
60 Plugin* plugin_; 64 Plugin* plugin_;
61 nacl::scoped_ptr<nacl::DescWrapper> read_wrapper_; 65 nacl::scoped_ptr<nacl::DescWrapper> read_wrapper_;
62 nacl::scoped_ptr<nacl::DescWrapper> write_wrapper_; 66 nacl::scoped_ptr<nacl::DescWrapper> write_wrapper_;
63 PP_FileHandle internal_handle_; 67 PP_FileHandle internal_handle_;
64 }; 68 };
65 69
66 } // namespace plugin 70 } // namespace plugin
67 71
68 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_TEMPORARY_FILE_H_ 72 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_TEMPORARY_FILE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698