1 // Copyright (c) 2013 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 WEBKIT_FILEAPI_UPLOAD_FILE_SYSTEM_FILE_ELEMENT_READER_H_
6 #define WEBKIT_FILEAPI_UPLOAD_FILE_SYSTEM_FILE_ELEMENT_READER_H_
8 #include "base/memory/weak_ptr.h"
10 #include "googleurl/src/gurl.h"
11 #include "net/base/upload_element_reader.h"
12 #include "webkit/storage/webkit_storage_export.h"
14 namespace webkit_blob
{
15 class FileStreamReader
;
20 class FileSystemContext
;
22 // An UploadElementReader implementation for filesystem file.
23 class WEBKIT_STORAGE_EXPORT UploadFileSystemFileElementReader
24 : public net::UploadElementReader
{
26 UploadFileSystemFileElementReader(
27 FileSystemContext
* file_system_context
,
31 const base::Time
& expected_modification_time
);
32 virtual ~UploadFileSystemFileElementReader();
34 // UploadElementReader overrides:
35 virtual int Init(const net::CompletionCallback
& callback
) OVERRIDE
;
36 virtual uint64
GetContentLength() const OVERRIDE
;
37 virtual uint64
BytesRemaining() const OVERRIDE
;
38 virtual int Read(net::IOBuffer
* buf
,
40 const net::CompletionCallback
& callback
) OVERRIDE
;
43 void OnGetLength(const net::CompletionCallback
& callback
, int64 result
);
44 void OnRead(const net::CompletionCallback
& callback
, int result
);
46 scoped_refptr
<FileSystemContext
> file_system_context_
;
48 const uint64 range_offset_
;
49 const uint64 range_length_
;
50 const base::Time expected_modification_time_
;
52 scoped_ptr
<webkit_blob::FileStreamReader
> stream_reader_
;
54 uint64 stream_length_
;
57 base::WeakPtrFactory
<UploadFileSystemFileElementReader
> weak_ptr_factory_
;
59 DISALLOW_COPY_AND_ASSIGN(UploadFileSystemFileElementReader
);
62 } // namespace fileapi
64 #endif // WEBKIT_FILEAPI_UPLOAD_FILE_SYSTEM_FILE_ELEMENT_READER_H_