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

Side by Side Diff: webkit/blob/local_file_reader.h

Issue 10447083: Rename webkit_blob::FileReader to FileStreamReader. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge master branch. Created 8 years, 6 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/file_stream_reader.h ('k') | webkit/blob/local_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_BLOB_LOCAL_FILE_READER_H_
6 #define WEBKIT_BLOB_LOCAL_FILE_READER_H_
7 #pragma once
8
9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h"
11 #include "base/file_path.h"
12 #include "base/platform_file.h"
13 #include "base/memory/weak_ptr.h"
14 #include "base/time.h"
15 #include "webkit/blob/blob_export.h"
16 #include "webkit/blob/file_reader.h"
17
18 namespace base {
19 class TaskRunner;
20 }
21
22 namespace webkit_blob {
23
24 // A thin wrapper of net::FileStream with range support for sliced file
25 // handling.
26 class BLOB_EXPORT LocalFileReader : public FileReader {
27 public:
28 // A convenient method to translate platform file error to net error code.
29 static int PlatformFileErrorToNetError(base::PlatformFileError file_error);
30
31 // Creates a new FileReader for a local file |file_path|.
32 // |initial_offset| specifies the offset in the file where the first read
33 // should start. If the given offset is out of the file range any
34 // read operation may error out with net::ERR_REQUEST_RANGE_NOT_SATISFIABLE.
35 //
36 // |expected_modification_time| specifies the expected last modification
37 // If the value is non-null, the reader will check the underlying file's
38 // actual modification time to see if the file has been modified, and if
39 // it does any succeeding read operations should fail with
40 // ERR_UPLOAD_FILE_CHANGED error.
41 LocalFileReader(base::TaskRunner* task_runner,
42 const FilePath& file_path,
43 int64 initial_offset,
44 const base::Time& expected_modification_time);
45 virtual ~LocalFileReader();
46
47 // FileReader overrides.
48 virtual int Read(net::IOBuffer* buf, int buf_len,
49 const net::CompletionCallback& callback) OVERRIDE;
50
51 // Returns the length of the file if it could successfully retrieve the
52 // file info *and* its last modification time equals to
53 // expected_modification_time_ (rv >= 0 cases).
54 // Otherwise, a negative error code is returned (rv < 0 cases).
55 // If the stream is deleted while it has an in-flight GetLength operation
56 // |callback| will not be called.
57 int GetLength(const net::Int64CompletionCallback& callback);
58
59 private:
60 int Open(const net::CompletionCallback& callback);
61
62 // Callbacks that are chained from Open for Read.
63 void DidVerifyForOpen(const net::CompletionCallback& callback,
64 int64 get_length_result);
65 void DidOpenFileStream(const net::CompletionCallback& callback,
66 int result);
67 void DidSeekFileStream(const net::CompletionCallback& callback,
68 int64 seek_result);
69 void DidOpenForRead(net::IOBuffer* buf,
70 int buf_len,
71 const net::CompletionCallback& callback,
72 int open_result);
73
74 void DidGetFileInfoForGetLength(const net::Int64CompletionCallback& callback,
75 base::PlatformFileError error,
76 const base::PlatformFileInfo& file_info);
77
78 scoped_refptr<base::TaskRunner> task_runner_;
79 scoped_ptr<net::FileStream> stream_impl_;
80 const FilePath file_path_;
81 const int64 initial_offset_;
82 const base::Time expected_modification_time_;
83 bool has_pending_open_;
84 base::WeakPtrFactory<LocalFileReader> weak_factory_;
85 };
86
87 } // namespace webkit_blob
88
89 #endif // WEBKIT_BLOB_LOCAL_FILE_READER_H_
OLDNEW
« no previous file with comments | « webkit/blob/file_stream_reader.h ('k') | webkit/blob/local_file_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698