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

Side by Side Diff: webkit/fileapi/file_system_file_stream_reader.cc

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
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 #include "webkit/fileapi/file_system_file_reader.h" 5 #include "webkit/fileapi/file_system_file_stream_reader.h"
6 6
7 #include "base/file_util_proxy.h" 7 #include "base/file_util_proxy.h"
8 #include "base/platform_file.h" 8 #include "base/platform_file.h"
9 #include "base/sequenced_task_runner.h" 9 #include "base/sequenced_task_runner.h"
10 #include "net/base/file_stream.h" 10 #include "net/base/file_stream.h"
11 #include "net/base/io_buffer.h" 11 #include "net/base/io_buffer.h"
12 #include "net/base/net_errors.h" 12 #include "net/base/net_errors.h"
13 #include "webkit/blob/local_file_reader.h" 13 #include "webkit/blob/local_file_stream_reader.h"
14 #include "webkit/fileapi/file_system_context.h" 14 #include "webkit/fileapi/file_system_context.h"
15 #include "webkit/fileapi/file_system_operation_interface.h" 15 #include "webkit/fileapi/file_system_operation_interface.h"
16 16
17 using webkit_blob::LocalFileReader; 17 using webkit_blob::LocalFileStreamReader;
18 18
19 namespace fileapi { 19 namespace fileapi {
20 20
21 namespace { 21 namespace {
22 22
23 void ReadAdapter(base::WeakPtr<FileSystemFileReader> reader, 23 void ReadAdapter(base::WeakPtr<FileSystemFileStreamReader> reader,
24 net::IOBuffer* buf, int buf_len, 24 net::IOBuffer* buf, int buf_len,
25 const net::CompletionCallback& callback) { 25 const net::CompletionCallback& callback) {
26 if (!reader.get()) 26 if (!reader.get())
27 return; 27 return;
28 int rv = reader->Read(buf, buf_len, callback); 28 int rv = reader->Read(buf, buf_len, callback);
29 if (rv != net::ERR_IO_PENDING) 29 if (rv != net::ERR_IO_PENDING)
30 callback.Run(rv); 30 callback.Run(rv);
31 } 31 }
32 32
33 } 33 }
34 34
35 FileSystemFileReader::FileSystemFileReader( 35 FileSystemFileStreamReader::FileSystemFileStreamReader(
36 FileSystemContext* file_system_context, 36 FileSystemContext* file_system_context,
37 const GURL& url, 37 const GURL& url,
38 int64 initial_offset) 38 int64 initial_offset)
39 : file_system_context_(file_system_context), 39 : file_system_context_(file_system_context),
40 url_(url), 40 url_(url),
41 initial_offset_(initial_offset), 41 initial_offset_(initial_offset),
42 has_pending_create_snapshot_(false), 42 has_pending_create_snapshot_(false),
43 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { 43 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
44 } 44 }
45 45
46 FileSystemFileReader::~FileSystemFileReader() { 46 FileSystemFileStreamReader::~FileSystemFileStreamReader() {
47 } 47 }
48 48
49 int FileSystemFileReader::Read( 49 int FileSystemFileStreamReader::Read(
50 net::IOBuffer* buf, int buf_len, 50 net::IOBuffer* buf, int buf_len,
51 const net::CompletionCallback& callback) { 51 const net::CompletionCallback& callback) {
52 if (local_file_reader_.get()) 52 if (local_file_reader_.get())
53 return local_file_reader_->Read(buf, buf_len, callback); 53 return local_file_reader_->Read(buf, buf_len, callback);
54 DCHECK(!has_pending_create_snapshot_); 54 DCHECK(!has_pending_create_snapshot_);
55 FileSystemOperationInterface* operation = 55 FileSystemOperationInterface* operation =
56 file_system_context_->CreateFileSystemOperation(url_); 56 file_system_context_->CreateFileSystemOperation(url_);
57 if (!operation) 57 if (!operation)
58 return net::ERR_INVALID_URL; 58 return net::ERR_INVALID_URL;
59 has_pending_create_snapshot_ = true; 59 has_pending_create_snapshot_ = true;
60 operation->CreateSnapshotFile( 60 operation->CreateSnapshotFile(
61 url_, 61 url_,
62 base::Bind(&FileSystemFileReader::DidCreateSnapshot, 62 base::Bind(&FileSystemFileStreamReader::DidCreateSnapshot,
63 weak_factory_.GetWeakPtr(), 63 weak_factory_.GetWeakPtr(),
64 base::Bind(&ReadAdapter, weak_factory_.GetWeakPtr(), 64 base::Bind(&ReadAdapter, weak_factory_.GetWeakPtr(),
65 make_scoped_refptr(buf), buf_len, callback), 65 make_scoped_refptr(buf), buf_len, callback),
66 callback)); 66 callback));
67 return net::ERR_IO_PENDING; 67 return net::ERR_IO_PENDING;
68 } 68 }
69 69
70 void FileSystemFileReader::DidCreateSnapshot( 70 void FileSystemFileStreamReader::DidCreateSnapshot(
71 const base::Closure& read_closure, 71 const base::Closure& read_closure,
72 const net::CompletionCallback& callback, 72 const net::CompletionCallback& callback,
73 base::PlatformFileError file_error, 73 base::PlatformFileError file_error,
74 const base::PlatformFileInfo& file_info, 74 const base::PlatformFileInfo& file_info,
75 const FilePath& platform_path, 75 const FilePath& platform_path,
76 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref) { 76 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref) {
77 DCHECK(has_pending_create_snapshot_); 77 DCHECK(has_pending_create_snapshot_);
78 DCHECK(!local_file_reader_.get()); 78 DCHECK(!local_file_reader_.get());
79 has_pending_create_snapshot_ = false; 79 has_pending_create_snapshot_ = false;
80 80
81 if (file_error != base::PLATFORM_FILE_OK) { 81 if (file_error != base::PLATFORM_FILE_OK) {
82 callback.Run(LocalFileReader::PlatformFileErrorToNetError(file_error)); 82 callback.Run(
83 LocalFileStreamReader::PlatformFileErrorToNetError(file_error));
83 return; 84 return;
84 } 85 }
85 86
86 // Keep the reference (if it's non-null) so that the file won't go away. 87 // Keep the reference (if it's non-null) so that the file won't go away.
87 snapshot_ref_ = file_ref; 88 snapshot_ref_ = file_ref;
88 89
89 local_file_reader_.reset( 90 local_file_reader_.reset(
90 new LocalFileReader(file_system_context_->file_task_runner(), 91 new LocalFileStreamReader(file_system_context_->file_task_runner(),
91 platform_path, 92 platform_path,
92 initial_offset_, 93 initial_offset_,
93 base::Time())); 94 base::Time()));
94 95
95 read_closure.Run(); 96 read_closure.Run();
96 } 97 }
97 98
98 } // namespace fileapi 99 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/file_system_file_stream_reader.h ('k') | webkit/fileapi/file_system_mount_point_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698