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

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

Issue 413493002: Pepper: Simplify TempFile in trusted plugin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
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 // Create a TempFile. 38 TempFile(Plugin* plugin, PP_FileHandle handle);
39 explicit TempFile(Plugin* plugin);
40 ~TempFile(); 39 ~TempFile();
41 40
42 // Opens a temporary file object and descriptor wrapper referring to the file. 41 // Opens a temporary file object and descriptor wrapper referring to the file.
43 // If |writeable| is true, the descriptor will be opened for writing, and 42 // If |writeable| is true, the descriptor will be opened for writing, and
44 // write_wrapper will return a valid pointer, otherwise it will return NULL. 43 // write_wrapper will return a valid pointer, otherwise it will return NULL.
45 int32_t Open(bool writeable); 44 int32_t Open(bool writeable);
46 // Resets file position of the handle, for reuse. 45 // Resets file position of the handle, for reuse.
47 bool Reset(); 46 bool Reset();
48 47
49 // Accessors. 48 // Accessors.
50 // The nacl::DescWrapper* for the writeable version of the file. 49 // The nacl::DescWrapper* for the writeable version of the file.
51 nacl::DescWrapper* write_wrapper() { return write_wrapper_.get(); } 50 nacl::DescWrapper* write_wrapper() { return write_wrapper_.get(); }
52 nacl::DescWrapper* read_wrapper() { return read_wrapper_.get(); } 51 nacl::DescWrapper* read_wrapper() { return read_wrapper_.get(); }
53 52
54 // Returns the handle to the file repesented and resets the internal handle 53 // Returns the handle to the file repesented and resets the internal handle
55 // and all wrappers. 54 // and all wrappers.
56 PP_FileHandle TakeFileHandle(); 55 PP_FileHandle TakeFileHandle();
57 56
58 // Used by GetNexeFd() to set the underlying internal handle.
59 PP_FileHandle* internal_handle() { return &internal_handle_; }
60
61 private: 57 private:
62 NACL_DISALLOW_COPY_AND_ASSIGN(TempFile); 58 NACL_DISALLOW_COPY_AND_ASSIGN(TempFile);
63 59
64 Plugin* plugin_; 60 Plugin* plugin_;
65 nacl::scoped_ptr<nacl::DescWrapper> read_wrapper_; 61 nacl::scoped_ptr<nacl::DescWrapper> read_wrapper_;
66 nacl::scoped_ptr<nacl::DescWrapper> write_wrapper_; 62 nacl::scoped_ptr<nacl::DescWrapper> write_wrapper_;
67 PP_FileHandle internal_handle_; 63 PP_FileHandle internal_handle_;
68 }; 64 };
69 65
70 } // namespace plugin 66 } // namespace plugin
71 67
72 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_TEMPORARY_FILE_H_ 68 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_TEMPORARY_FILE_H_
OLDNEW
« no previous file with comments | « ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc ('k') | ppapi/native_client/src/trusted/plugin/temporary_file.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698