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

Side by Side Diff: components/nacl/renderer/plugin/temporary_file.h

Issue 1575573002: PNaCl: Remove now-unneeded use of nacl::DescWrapper in TempFile (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 4 years, 11 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
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 COMPONENTS_NACL_RENDERER_PLUGIN_TEMPORARY_FILE_H_ 5 #ifndef COMPONENTS_NACL_RENDERER_PLUGIN_TEMPORARY_FILE_H_
6 #define COMPONENTS_NACL_RENDERER_PLUGIN_TEMPORARY_FILE_H_ 6 #define COMPONENTS_NACL_RENDERER_PLUGIN_TEMPORARY_FILE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/files/file.h" 10 #include "base/files/file.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "native_client/src/include/nacl_macros.h" 13 #include "native_client/src/include/nacl_macros.h"
14 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h"
15 14
16 #include "ppapi/c/private/pp_file_handle.h" 15 #include "ppapi/c/private/pp_file_handle.h"
17 16
18 namespace plugin { 17 namespace plugin {
19 18
20 class Plugin; 19 class Plugin;
21 20
22 // Translation creates two temporary files. The first temporary file holds 21 // Translation creates two temporary files. The first temporary file holds
23 // the object file created by llc. The second holds the nexe produced by 22 // the object file created by llc. The second holds the nexe produced by
24 // the linker. Both of these temporary files are used to both write and 23 // the linker. Both of these temporary files are used to both write and
(...skipping 12 matching lines...) Expand all
37 // (or earlier -- immediately unlinked on POSIX systems). The file is only 36 // (or earlier -- immediately unlinked on POSIX systems). The file is only
38 // opened, once, but because both reading and writing are necessary (and in 37 // opened, once, but because both reading and writing are necessary (and in
39 // different processes), the user should reset / seek back to the beginning 38 // different processes), the user should reset / seek back to the beginning
40 // of the file between sessions. 39 // of the file between sessions.
41 class TempFile { 40 class TempFile {
42 public: 41 public:
43 // Create a TempFile. 42 // Create a TempFile.
44 TempFile(Plugin* plugin, PP_FileHandle handle); 43 TempFile(Plugin* plugin, PP_FileHandle handle);
45 ~TempFile(); 44 ~TempFile();
46 45
47 // Opens a temporary file object and descriptor wrapper referring to the file. 46 int32_t CheckValidity();
48 // If |writeable| is true, the descriptor will be opened for writing, and
49 // write_wrapper will return a valid pointer, otherwise it will return NULL.
50 int32_t Open(bool writeable);
51 // Resets file position of the handle, for reuse. 47 // Resets file position of the handle, for reuse.
52 bool Reset(); 48 bool Reset();
53 49
54 // Returns the current size of this file. 50 // Returns the current size of this file.
55 int64_t GetLength(); 51 int64_t GetLength();
56 52
57 // Accessors. 53 // Returns a handle to the file, transferring ownership of it.
58 // The nacl::DescWrapper* for the writeable version of the file.
59 nacl::DescWrapper* write_wrapper() { return write_wrapper_.get(); }
60 nacl::DescWrapper* read_wrapper() { return read_wrapper_.get(); }
61
62 // Returns a handle to the file, transferring ownership of it. Note that
63 // the objects returned by write_wrapper() and read_wrapper() remain
64 // valid after TakeFileHandle() is called.
65 PP_FileHandle TakeFileHandle(); 54 PP_FileHandle TakeFileHandle();
66 55
67 // Returns a handle to the file, without transferring ownership of it. 56 // Returns a handle to the file, without transferring ownership of it.
68 // This handle remains valid until the TempFile object is destroyed or 57 // This handle remains valid until the TempFile object is destroyed or
69 // TakeFileHandle() is called. 58 // TakeFileHandle() is called.
70 PP_FileHandle GetFileHandle(); 59 PP_FileHandle GetFileHandle();
71 60
72 private: 61 private:
73 NACL_DISALLOW_COPY_AND_ASSIGN(TempFile); 62 NACL_DISALLOW_COPY_AND_ASSIGN(TempFile);
74 63
75 nacl::DescWrapper* MakeDescWrapper(int nacl_file_flags);
76
77 Plugin* plugin_; 64 Plugin* plugin_;
78 scoped_ptr<nacl::DescWrapper> read_wrapper_;
79 scoped_ptr<nacl::DescWrapper> write_wrapper_;
80 base::File file_handle_; 65 base::File file_handle_;
81 }; 66 };
82 67
83 } // namespace plugin 68 } // namespace plugin
84 69
85 #endif // COMPONENTS_NACL_RENDERER_PLUGIN_TEMPORARY_FILE_H_ 70 #endif // COMPONENTS_NACL_RENDERER_PLUGIN_TEMPORARY_FILE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698