OLD | NEW |
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" |
(...skipping 24 matching lines...) Expand all Loading... |
35 // (or earlier -- immediately unlinked on POSIX systems). The file is only | 35 // (or earlier -- immediately unlinked on POSIX systems). The file is only |
36 // opened, once, but because both reading and writing are necessary (and in | 36 // opened, once, but because both reading and writing are necessary (and in |
37 // different processes), the user should reset / seek back to the beginning | 37 // different processes), the user should reset / seek back to the beginning |
38 // of the file between sessions. | 38 // of the file between sessions. |
39 class TempFile { | 39 class TempFile { |
40 public: | 40 public: |
41 // Create a TempFile. | 41 // Create a TempFile. |
42 TempFile(Plugin* plugin, PP_FileHandle handle); | 42 TempFile(Plugin* plugin, PP_FileHandle handle); |
43 ~TempFile(); | 43 ~TempFile(); |
44 | 44 |
45 int32_t CheckValidity(); | 45 bool IsValid() { return file_handle_.IsValid(); } |
46 // Resets file position of the handle, for reuse. | 46 // Resets file position of the handle, for reuse. |
47 bool Reset(); | 47 bool Reset(); |
48 | 48 |
49 // Returns the current size of this file. | 49 // Returns the current size of this file. |
50 int64_t GetLength(); | 50 int64_t GetLength(); |
51 | 51 |
52 // Returns a handle to the file, transferring ownership of it. | 52 // Returns a handle to the file, transferring ownership of it. |
53 PP_FileHandle TakeFileHandle(); | 53 PP_FileHandle TakeFileHandle(); |
54 | 54 |
55 // Returns a handle to the file, without transferring ownership of it. | 55 // Returns a handle to the file, without transferring ownership of it. |
56 // This handle remains valid until the TempFile object is destroyed or | 56 // This handle remains valid until the TempFile object is destroyed or |
57 // TakeFileHandle() is called. | 57 // TakeFileHandle() is called. |
58 PP_FileHandle GetFileHandle(); | 58 PP_FileHandle GetFileHandle(); |
59 | 59 |
60 private: | 60 private: |
61 Plugin* plugin_; | 61 Plugin* plugin_; |
62 base::File file_handle_; | 62 base::File file_handle_; |
63 | 63 |
64 DISALLOW_COPY_AND_ASSIGN(TempFile); | 64 DISALLOW_COPY_AND_ASSIGN(TempFile); |
65 }; | 65 }; |
66 | 66 |
67 } // namespace plugin | 67 } // namespace plugin |
68 | 68 |
69 #endif // COMPONENTS_NACL_RENDERER_PLUGIN_TEMPORARY_FILE_H_ | 69 #endif // COMPONENTS_NACL_RENDERER_PLUGIN_TEMPORARY_FILE_H_ |
OLD | NEW |