blob: 5735d33a71f5ae6461ad9f4c07552b3cb1dff022 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ppapi/cpp/private/pass_file_handle.h"
#ifdef _WIN32
# include <windows.h>
#else
# include <unistd.h>
#endif
namespace pp {
PassFileHandle::PassFileHandle()
: handle_(PP_kInvalidFileHandle) {
}
PassFileHandle::PassFileHandle(PP_FileHandle handle)
: handle_(handle) {
}
PassFileHandle::PassFileHandle(PassFileHandle& handle)
: handle_(handle.Release()) {
}
PassFileHandle::~PassFileHandle() {
Close();
}
PP_FileHandle PassFileHandle::Release() {
PP_FileHandle released = handle_;
handle_ = PP_kInvalidFileHandle;
return released;
}
void PassFileHandle::Close() {
if (handle_ != PP_kInvalidFileHandle) {
#ifdef _WIN32
CloseHandle(handle_);
#else
close(handle_);
#endif
handle_ = PP_kInvalidFileHandle;
}
}
} // namespace pp
|