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