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

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

Issue 10197007: Change webkit/{fileapi,quota} code to use TaskRunner. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixesz Created 8 years, 7 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_FILE_READER_H_ 5 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_FILE_READER_H_
6 #define WEBKIT_FILEAPI_FILE_SYSTEM_FILE_READER_H_ 6 #define WEBKIT_FILEAPI_FILE_SYSTEM_FILE_READER_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/platform_file.h" 11 #include "base/platform_file.h"
12 #include "googleurl/src/gurl.h" 12 #include "googleurl/src/gurl.h"
13 #include "webkit/blob/file_reader.h" 13 #include "webkit/blob/file_reader.h"
14 14
15 class FilePath; 15 class FilePath;
16 16
17 namespace base { 17 namespace base {
18 class MessageLoopProxy; 18 class SequencedTaskRunner;
19 } 19 }
20 20
21 namespace webkit_blob { 21 namespace webkit_blob {
22 class LocalFileReader; 22 class LocalFileReader;
23 class ShareableFileReference; 23 class ShareableFileReference;
24 } 24 }
25 25
26 namespace fileapi { 26 namespace fileapi {
27 27
28 class FileSystemContext; 28 class FileSystemContext;
29 29
30 // TODO(kinaba,satorux): This generic implementation would work for any 30 // TODO(kinaba,satorux): This generic implementation would work for any
31 // filesystems but remote filesystem should implement its own reader 31 // filesystems but remote filesystem should implement its own reader
32 // rather than relying on FileSystemOperation::GetSnapshotFile() which 32 // rather than relying on FileSystemOperation::GetSnapshotFile() which
33 // may force downloading the entire contents for remote files. 33 // may force downloading the entire contents for remote files.
34 class FileSystemFileReader : public webkit_blob::FileReader { 34 class FileSystemFileReader : public webkit_blob::FileReader {
35 public: 35 public:
36 // Creates a new FileReader for a filesystem URL |url| form |initial_offset|. 36 // Creates a new FileReader for a filesystem URL |url| form |initial_offset|.
37 FileSystemFileReader(base::MessageLoopProxy* file_thread_proxy, 37 FileSystemFileReader(base::SequencedTaskRunner* task_runner,
38 FileSystemContext* file_system_context, 38 FileSystemContext* file_system_context,
39 const GURL& url, 39 const GURL& url,
40 int64 initial_offset); 40 int64 initial_offset);
41 virtual ~FileSystemFileReader(); 41 virtual ~FileSystemFileReader();
42 42
43 // FileReader override. 43 // FileReader override.
44 virtual int Read(net::IOBuffer* buf, int buf_len, 44 virtual int Read(net::IOBuffer* buf, int buf_len,
45 const net::CompletionCallback& callback) OVERRIDE; 45 const net::CompletionCallback& callback) OVERRIDE;
46 46
47 private: 47 private:
48 void DidCreateSnapshot( 48 void DidCreateSnapshot(
49 const base::Closure& read_closure, 49 const base::Closure& read_closure,
50 const net::CompletionCallback& callback, 50 const net::CompletionCallback& callback,
51 base::PlatformFileError file_error, 51 base::PlatformFileError file_error,
52 const base::PlatformFileInfo& file_info, 52 const base::PlatformFileInfo& file_info,
53 const FilePath& platform_path, 53 const FilePath& platform_path,
54 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref); 54 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref);
55 55
56 scoped_refptr<base::MessageLoopProxy> file_thread_proxy_; 56 scoped_refptr<base::SequencedTaskRunner> task_runner_;
57 scoped_refptr<FileSystemContext> file_system_context_; 57 scoped_refptr<FileSystemContext> file_system_context_;
58 const GURL url_; 58 const GURL url_;
59 const int64 initial_offset_; 59 const int64 initial_offset_;
60 scoped_ptr<webkit_blob::LocalFileReader> local_file_reader_; 60 scoped_ptr<webkit_blob::LocalFileReader> local_file_reader_;
61 scoped_refptr<webkit_blob::ShareableFileReference> snapshot_ref_; 61 scoped_refptr<webkit_blob::ShareableFileReference> snapshot_ref_;
62 bool has_pending_create_snapshot_; 62 bool has_pending_create_snapshot_;
63 base::WeakPtrFactory<FileSystemFileReader> weak_factory_; 63 base::WeakPtrFactory<FileSystemFileReader> weak_factory_;
64 64
65 DISALLOW_COPY_AND_ASSIGN(FileSystemFileReader); 65 DISALLOW_COPY_AND_ASSIGN(FileSystemFileReader);
66 }; 66 };
67 67
68 } // namespace fileapi 68 } // namespace fileapi
69 69
70 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_FILE_READER_H_ 70 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_FILE_READER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698