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 #include "components/nacl/renderer/plugin/temporary_file.h" | 5 #include "components/nacl/renderer/plugin/temporary_file.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "components/nacl/renderer/plugin/plugin.h" | 9 #include "components/nacl/renderer/plugin/plugin.h" |
10 #include "components/nacl/renderer/plugin/utility.h" | 10 #include "components/nacl/renderer/plugin/utility.h" |
11 #include "ppapi/c/private/pp_file_handle.h" | 11 #include "ppapi/c/private/pp_file_handle.h" |
12 #include "ppapi/cpp/core.h" | 12 #include "ppapi/cpp/core.h" |
13 #include "ppapi/cpp/instance.h" | 13 #include "ppapi/cpp/instance.h" |
14 #include "ppapi/cpp/module.h" | 14 #include "ppapi/cpp/module.h" |
15 | 15 |
16 namespace plugin { | 16 namespace plugin { |
17 | 17 |
18 TempFile::TempFile(Plugin* plugin, PP_FileHandle handle) | 18 TempFile::TempFile(Plugin* plugin, PP_FileHandle handle) |
19 : plugin_(plugin), | 19 : plugin_(plugin), |
20 file_handle_(handle) { } | 20 file_handle_(handle) { } |
21 | 21 |
22 TempFile::~TempFile() { } | 22 TempFile::~TempFile() { } |
23 | 23 |
24 int32_t TempFile::CheckValidity() { | |
25 if (!file_handle_.IsValid()) | |
26 return PP_ERROR_FAILED; | |
27 return PP_OK; | |
28 } | |
29 | |
30 bool TempFile::Reset() { | 24 bool TempFile::Reset() { |
31 // file_handle_, read_wrapper_ and write_wrapper_ are all backed by the | 25 // file_handle_, read_wrapper_ and write_wrapper_ are all backed by the |
32 // same file handle/descriptor, so resetting the seek position of one | 26 // same file handle/descriptor, so resetting the seek position of one |
33 // will reset them all. | 27 // will reset them all. |
34 int64_t newpos = file_handle_.Seek(base::File::FROM_BEGIN, 0); | 28 int64_t newpos = file_handle_.Seek(base::File::FROM_BEGIN, 0); |
35 return newpos == 0; | 29 return newpos == 0; |
36 } | 30 } |
37 | 31 |
38 int64_t TempFile::GetLength() { | 32 int64_t TempFile::GetLength() { |
39 return file_handle_.GetLength(); | 33 return file_handle_.GetLength(); |
40 } | 34 } |
41 | 35 |
42 PP_FileHandle TempFile::TakeFileHandle() { | 36 PP_FileHandle TempFile::TakeFileHandle() { |
43 DCHECK(file_handle_.IsValid()); | 37 DCHECK(file_handle_.IsValid()); |
44 return file_handle_.TakePlatformFile(); | 38 return file_handle_.TakePlatformFile(); |
45 } | 39 } |
46 | 40 |
47 PP_FileHandle TempFile::GetFileHandle() { | 41 PP_FileHandle TempFile::GetFileHandle() { |
48 DCHECK(file_handle_.IsValid()); | 42 DCHECK(file_handle_.IsValid()); |
49 return file_handle_.GetPlatformFile(); | 43 return file_handle_.GetPlatformFile(); |
50 } | 44 } |
51 | 45 |
52 } // namespace plugin | 46 } // namespace plugin |
OLD | NEW |