1 // Copyright 2015 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.
5 #ifndef COMPONENTS_FILESYSTEM_FILE_IMPL_H_
6 #define COMPONENTS_FILESYSTEM_FILE_IMPL_H_
8 #include "base/files/scoped_file.h"
9 #include "base/macros.h"
10 #include "components/filesystem/public/interfaces/directory.mojom.h"
11 #include "mojo/public/cpp/bindings/interface_request.h"
12 #include "mojo/public/cpp/bindings/strong_binding.h"
14 namespace filesystem
{
16 class FileImpl
: public File
{
18 // TODO(vtl): Will need more for, e.g., |Reopen()|.
19 FileImpl(mojo::InterfaceRequest
<File
> request
, base::ScopedFD file_fd
);
22 // |File| implementation:
23 void Close(const CloseCallback
& callback
) override
;
24 void Read(uint32_t num_bytes_to_read
,
27 const ReadCallback
& callback
) override
;
28 void Write(mojo::Array
<uint8_t> bytes_to_write
,
31 const WriteCallback
& callback
) override
;
32 void ReadToStream(mojo::ScopedDataPipeProducerHandle source
,
35 int64_t num_bytes_to_read
,
36 const ReadToStreamCallback
& callback
) override
;
37 void WriteFromStream(mojo::ScopedDataPipeConsumerHandle sink
,
40 const WriteFromStreamCallback
& callback
) override
;
41 void Tell(const TellCallback
& callback
) override
;
42 void Seek(int64_t offset
,
44 const SeekCallback
& callback
) override
;
45 void Stat(const StatCallback
& callback
) override
;
46 void Truncate(int64_t size
, const TruncateCallback
& callback
) override
;
47 void Touch(TimespecOrNowPtr atime
,
48 TimespecOrNowPtr mtime
,
49 const TouchCallback
& callback
) override
;
50 void Dup(mojo::InterfaceRequest
<File
> file
,
51 const DupCallback
& callback
) override
;
52 void Reopen(mojo::InterfaceRequest
<File
> file
,
54 const ReopenCallback
& callback
) override
;
55 void AsBuffer(const AsBufferCallback
& callback
) override
;
56 void Ioctl(uint32_t request
,
57 mojo::Array
<uint32_t> in_values
,
58 const IoctlCallback
& callback
) override
;
61 mojo::StrongBinding
<File
> binding_
;
62 base::ScopedFD file_fd_
;
64 DISALLOW_COPY_AND_ASSIGN(FileImpl
);
67 } // namespace filesystem
69 #endif // COMPONENTS_FILESYSTEM_FILE_IMPL_H_