Fix Win8 metro startup crash from window switcher button
[chromium-blink-merge.git] / webkit / fileapi / upload_file_system_file_element_reader.h
blob19b3db1a61e45a3cf140e85ebdcd789b8b4fb0be
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"
9 #include "base/time.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;
18 namespace fileapi {
20 class FileSystemContext;
22 // An UploadElementReader implementation for filesystem file.
23 class WEBKIT_STORAGE_EXPORT UploadFileSystemFileElementReader
24 : public net::UploadElementReader {
25 public:
26 UploadFileSystemFileElementReader(
27 FileSystemContext* file_system_context,
28 const GURL& url,
29 uint64 range_offset,
30 uint64 range_length,
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,
39 int buf_length,
40 const net::CompletionCallback& callback) OVERRIDE;
42 private:
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_;
47 const GURL url_;
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_;
55 uint64 position_;
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_