Pepper_47_C++_interfaces
pass_file_handle.cc
Go to the documentation of this file.
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
3 // found in the LICENSE file.
4 
6 
7 #ifdef _WIN32
8 # include <windows.h>
9 #else
10 # include <unistd.h>
11 #endif
12 
13 namespace pp {
14 
16  : handle_(PP_kInvalidFileHandle) {
17 }
18 
19 PassFileHandle::PassFileHandle(PP_FileHandle handle)
20  : handle_(handle) {
21 }
22 
24  : handle_(handle.Release()) {
25 }
26 
28  Close();
29 }
30 
31 PP_FileHandle PassFileHandle::Release() {
32  PP_FileHandle released = handle_;
33  handle_ = PP_kInvalidFileHandle;
34  return released;
35 }
36 
37 void PassFileHandle::Close() {
38  if (handle_ != PP_kInvalidFileHandle) {
39 #ifdef _WIN32
40  CloseHandle(handle_);
41 #else
42  close(handle_);
43 #endif
44  handle_ = PP_kInvalidFileHandle;
45  }
46 }
47 
48 } // namespace pp
PP_FileHandle Release()