| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 PPAPI_CPP_PRIVATE_PASS_FILE_HANDLE_H_ | 5 #ifndef PPAPI_CPP_PRIVATE_PASS_FILE_HANDLE_H_ |
| 6 #define PPAPI_CPP_PRIVATE_PASS_FILE_HANDLE_H_ | 6 #define PPAPI_CPP_PRIVATE_PASS_FILE_HANDLE_H_ |
| 7 | 7 |
| 8 #include <string.h> |
| 9 |
| 8 #include "ppapi/c/private/pp_file_handle.h" | 10 #include "ppapi/c/private/pp_file_handle.h" |
| 9 #include "ppapi/cpp/output_traits.h" | 11 #include "ppapi/cpp/output_traits.h" |
| 10 | 12 |
| 11 namespace pp { | 13 namespace pp { |
| 12 | 14 |
| 13 // A wrapper class for PP_FileHandle to make sure a file handle is | 15 // A wrapper class for PP_FileHandle to make sure a file handle is |
| 14 // closed. This object takes the ownership of the file handle when it | 16 // closed. This object takes the ownership of the file handle when it |
| 15 // is constructed. This loses the ownership when this object is | 17 // is constructed. This loses the ownership when this object is |
| 16 // assigned to another object, just like auto_ptr. | 18 // assigned to another object, just like auto_ptr. |
| 17 class PassFileHandle { | 19 class PassFileHandle { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 typedef PP_FileHandle* APIArgType; | 62 typedef PP_FileHandle* APIArgType; |
| 61 typedef PP_FileHandle StorageType; | 63 typedef PP_FileHandle StorageType; |
| 62 | 64 |
| 63 static inline APIArgType StorageToAPIArg(StorageType& t) { | 65 static inline APIArgType StorageToAPIArg(StorageType& t) { |
| 64 return &t; | 66 return &t; |
| 65 } | 67 } |
| 66 | 68 |
| 67 static inline PassFileHandle StorageToPluginArg(StorageType& t) { | 69 static inline PassFileHandle StorageToPluginArg(StorageType& t) { |
| 68 return PassFileHandle(t); | 70 return PassFileHandle(t); |
| 69 } | 71 } |
| 72 |
| 73 static inline void Initialize(StorageType* t) { |
| 74 memset(t, 0, sizeof(*t)); |
| 75 } |
| 70 }; | 76 }; |
| 71 | 77 |
| 72 } // namespace internal | 78 } // namespace internal |
| 73 } // namespace pp | 79 } // namespace pp |
| 74 | 80 |
| 75 #endif // PPAPI_CPP_PRIVATE_PASS_FILE_HANDLE_H_ | 81 #endif // PPAPI_CPP_PRIVATE_PASS_FILE_HANDLE_H_ |
| OLD | NEW |