Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Side by Side Diff: webkit/fileapi/file_system_file_reader.h

Issue 10038019: Add FileReader interface and implement FileSystemFileReader (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/blob/local_file_reader.cc ('k') | webkit/fileapi/file_system_file_reader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_FILE_READER_H_
6 #define WEBKIT_FILEAPI_FILE_SYSTEM_FILE_READER_H_
7 #pragma once
8
9 #include "base/bind.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/platform_file.h"
12 #include "googleurl/src/gurl.h"
13 #include "webkit/blob/file_reader.h"
14
15 class FilePath;
16
17 namespace base {
18 class MessageLoopProxy;
19 }
20
21 namespace webkit_blob {
22 class LocalFileReader;
23 class ShareableFileReference;
24 }
25
26 namespace fileapi {
27
28 class FileSystemContext;
29
30 // TODO(kinaba,satorux): This generic implementation would work for any
31 // filesystems but remote filesystem should implement its own reader
32 // rather than relying on FileSystemOperation::GetSnapshotFile() which
33 // may force downloading the entire contents for remote files.
34 class FileSystemFileReader : public webkit_blob::FileReader {
35 public:
36 // Creates a new FileReader for a filesystem URL |url| form |initial_offset|.
37 FileSystemFileReader(base::MessageLoopProxy* file_thread_proxy,
38 FileSystemContext* file_system_context,
39 const GURL& url,
40 int64 initial_offset);
41 virtual ~FileSystemFileReader();
42
43 // FileReader override.
44 virtual int Read(net::IOBuffer* buf, int buf_len,
45 const net::CompletionCallback& callback) OVERRIDE;
46
47 private:
48 void DidCreateSnapshot(
49 const base::Closure& read_closure,
50 const net::CompletionCallback& callback,
51 base::PlatformFileError file_error,
52 const base::PlatformFileInfo& file_info,
53 const FilePath& platform_path,
54 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref);
55
56 scoped_refptr<base::MessageLoopProxy> file_thread_proxy_;
57 scoped_refptr<FileSystemContext> file_system_context_;
58 const GURL url_;
59 const int64 initial_offset_;
60 scoped_ptr<webkit_blob::LocalFileReader> local_file_reader_;
61 scoped_refptr<webkit_blob::ShareableFileReference> snapshot_ref_;
62 bool has_pending_create_snapshot_;
63 base::WeakPtrFactory<FileSystemFileReader> weak_factory_;
64
65 DISALLOW_COPY_AND_ASSIGN(FileSystemFileReader);
66 };
67
68 } // namespace fileapi
69
70 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_FILE_READER_H_
OLDNEW
« no previous file with comments | « webkit/blob/local_file_reader.cc ('k') | webkit/fileapi/file_system_file_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698