1 // Copyright 2014 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 CONTENT_BROWSER_FILEAPI_UPLOAD_FILE_SYSTEM_FILE_ELEMENT_READER_H_
6 #define CONTENT_BROWSER_FILEAPI_UPLOAD_FILE_SYSTEM_FILE_ELEMENT_READER_H_
8 #include "base/memory/weak_ptr.h"
9 #include "base/time/time.h"
10 #include "content/common/content_export.h"
11 #include "net/base/upload_element_reader.h"
15 class FileStreamReader
;
19 class FileSystemContext
;
24 // An UploadElementReader implementation for filesystem file.
25 class CONTENT_EXPORT UploadFileSystemFileElementReader
:
26 NON_EXPORTED_BASE(public net::UploadElementReader
) {
28 UploadFileSystemFileElementReader(
29 storage::FileSystemContext
* file_system_context
,
33 const base::Time
& expected_modification_time
);
34 ~UploadFileSystemFileElementReader() override
;
36 // UploadElementReader overrides:
37 int Init(const net::CompletionCallback
& callback
) override
;
38 uint64
GetContentLength() const override
;
39 uint64
BytesRemaining() const override
;
40 int Read(net::IOBuffer
* buf
,
42 const net::CompletionCallback
& callback
) override
;
45 void OnGetLength(const net::CompletionCallback
& callback
, int64 result
);
46 void OnRead(const net::CompletionCallback
& callback
, int result
);
48 scoped_refptr
<storage::FileSystemContext
> file_system_context_
;
50 const uint64 range_offset_
;
51 const uint64 range_length_
;
52 const base::Time expected_modification_time_
;
54 scoped_ptr
<storage::FileStreamReader
> stream_reader_
;
56 uint64 stream_length_
;
59 base::WeakPtrFactory
<UploadFileSystemFileElementReader
> weak_ptr_factory_
;
61 DISALLOW_COPY_AND_ASSIGN(UploadFileSystemFileElementReader
);
64 } // namespace content
66 #endif // CONTENT_BROWSER_FILEAPI_UPLOAD_FILE_SYSTEM_FILE_ELEMENT_READER_H_