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

Side by Side Diff: webkit/blob/local_file_stream_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/local_file_reader_unittest.cc ('k') | webkit/blob/local_file_stream_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
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_BLOB_LOCAL_FILE_READER_H_ 5 #ifndef WEBKIT_BLOB_LOCAL_FILE_STREAM_READER_H_
6 #define WEBKIT_BLOB_LOCAL_FILE_READER_H_ 6 #define WEBKIT_BLOB_LOCAL_FILE_STREAM_READER_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/file_path.h" 11 #include "base/file_path.h"
12 #include "base/platform_file.h" 12 #include "base/platform_file.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/time.h" 14 #include "base/time.h"
15 #include "webkit/blob/blob_export.h" 15 #include "webkit/blob/blob_export.h"
16 #include "webkit/blob/file_reader.h" 16 #include "webkit/blob/file_stream_reader.h"
17 17
18 namespace base { 18 namespace base {
19 class TaskRunner; 19 class TaskRunner;
20 } 20 }
21 21
22 namespace net {
23 class FileStream;
24 }
25
22 namespace webkit_blob { 26 namespace webkit_blob {
23 27
24 // A thin wrapper of net::FileStream with range support for sliced file 28 // A thin wrapper of net::FileStream with range support for sliced file
25 // handling. 29 // handling.
26 class BLOB_EXPORT LocalFileReader : public FileReader { 30 class BLOB_EXPORT LocalFileStreamReader : public FileStreamReader {
27 public: 31 public:
28 // A convenient method to translate platform file error to net error code. 32 // A convenient method to translate platform file error to net error code.
29 static int PlatformFileErrorToNetError(base::PlatformFileError file_error); 33 static int PlatformFileErrorToNetError(base::PlatformFileError file_error);
30 34
31 // Creates a new FileReader for a local file |file_path|. 35 // Creates a new FileReader for a local file |file_path|.
32 // |initial_offset| specifies the offset in the file where the first read 36 // |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 37 // 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. 38 // read operation may error out with net::ERR_REQUEST_RANGE_NOT_SATISFIABLE.
35 // 39 //
36 // |expected_modification_time| specifies the expected last modification 40 // |expected_modification_time| specifies the expected last modification
37 // If the value is non-null, the reader will check the underlying file's 41 // 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 42 // actual modification time to see if the file has been modified, and if
39 // it does any succeeding read operations should fail with 43 // it does any succeeding read operations should fail with
40 // ERR_UPLOAD_FILE_CHANGED error. 44 // ERR_UPLOAD_FILE_CHANGED error.
41 LocalFileReader(base::TaskRunner* task_runner, 45 LocalFileStreamReader(base::TaskRunner* task_runner,
42 const FilePath& file_path, 46 const FilePath& file_path,
43 int64 initial_offset, 47 int64 initial_offset,
44 const base::Time& expected_modification_time); 48 const base::Time& expected_modification_time);
45 virtual ~LocalFileReader(); 49 virtual ~LocalFileStreamReader();
46 50
47 // FileReader overrides. 51 // FileStreamReader overrides.
48 virtual int Read(net::IOBuffer* buf, int buf_len, 52 virtual int Read(net::IOBuffer* buf, int buf_len,
49 const net::CompletionCallback& callback) OVERRIDE; 53 const net::CompletionCallback& callback) OVERRIDE;
50 54
51 // Returns the length of the file if it could successfully retrieve the 55 // Returns the length of the file if it could successfully retrieve the
52 // file info *and* its last modification time equals to 56 // file info *and* its last modification time equals to
53 // expected_modification_time_ (rv >= 0 cases). 57 // expected_modification_time_ (rv >= 0 cases).
54 // Otherwise, a negative error code is returned (rv < 0 cases). 58 // Otherwise, a negative error code is returned (rv < 0 cases).
55 // If the stream is deleted while it has an in-flight GetLength operation 59 // If the stream is deleted while it has an in-flight GetLength operation
56 // |callback| will not be called. 60 // |callback| will not be called.
57 int GetLength(const net::Int64CompletionCallback& callback); 61 int GetLength(const net::Int64CompletionCallback& callback);
(...skipping 16 matching lines...) Expand all
74 void DidGetFileInfoForGetLength(const net::Int64CompletionCallback& callback, 78 void DidGetFileInfoForGetLength(const net::Int64CompletionCallback& callback,
75 base::PlatformFileError error, 79 base::PlatformFileError error,
76 const base::PlatformFileInfo& file_info); 80 const base::PlatformFileInfo& file_info);
77 81
78 scoped_refptr<base::TaskRunner> task_runner_; 82 scoped_refptr<base::TaskRunner> task_runner_;
79 scoped_ptr<net::FileStream> stream_impl_; 83 scoped_ptr<net::FileStream> stream_impl_;
80 const FilePath file_path_; 84 const FilePath file_path_;
81 const int64 initial_offset_; 85 const int64 initial_offset_;
82 const base::Time expected_modification_time_; 86 const base::Time expected_modification_time_;
83 bool has_pending_open_; 87 bool has_pending_open_;
84 base::WeakPtrFactory<LocalFileReader> weak_factory_; 88 base::WeakPtrFactory<LocalFileStreamReader> weak_factory_;
85 }; 89 };
86 90
87 } // namespace webkit_blob 91 } // namespace webkit_blob
88 92
89 #endif // WEBKIT_BLOB_LOCAL_FILE_READER_H_ 93 #endif // WEBKIT_BLOB_LOCAL_FILE_STREAM_READER_H_
OLDNEW
« no previous file with comments | « webkit/blob/local_file_reader_unittest.cc ('k') | webkit/blob/local_file_stream_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698