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

Unified Diff: webkit/blob/local_file_reader.cc

Issue 10038019: Add FileReader interface and implement FileSystemFileReader (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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 side-by-side diff with in-line comments
Download patch
Index: webkit/blob/local_file_reader.cc
diff --git a/webkit/blob/local_file_reader.cc b/webkit/blob/local_file_reader.cc
index e21e82db67f8bb107cb20dc64720b5ca0888f81d..64ab242f1164fb032d6c9daca96daa6992efec7d 100644
--- a/webkit/blob/local_file_reader.cc
+++ b/webkit/blob/local_file_reader.cc
@@ -21,19 +21,6 @@ const int kOpenFlagsForRead = base::PLATFORM_FILE_OPEN |
base::PLATFORM_FILE_READ |
base::PLATFORM_FILE_ASYNC;
-int PlatformFileErrorToNetError(base::PlatformFileError file_error) {
- switch (file_error) {
- case base::PLATFORM_FILE_OK:
- return net::OK;
- case base::PLATFORM_FILE_ERROR_NOT_FOUND:
- return net::ERR_FILE_NOT_FOUND;
- case base::PLATFORM_FILE_ERROR_ACCESS_DENIED:
- return net::ERR_ACCESS_DENIED;
- default:
- return net::ERR_FAILED;
- }
-}
-
// Verify if the underlying file has not been modified.
bool VerifySnapshotTime(const base::Time& expected_modification_time,
const base::PlatformFileInfo& file_info) {
@@ -42,9 +29,8 @@ bool VerifySnapshotTime(const base::Time& expected_modification_time,
file_info.last_modified.ToTimeT();
}
-void DidGetFileInfoForGetLength(const net::CompletionCallback& callback,
+void DidGetFileInfoForGetLength(const net::Int64CompletionCallback& callback,
const base::Time& expected_modification_time,
- int64 initial_offset,
base::PlatformFileError error,
const base::PlatformFileInfo& file_info) {
if (file_info.is_directory) {
@@ -52,14 +38,14 @@ void DidGetFileInfoForGetLength(const net::CompletionCallback& callback,
return;
}
if (error != base::PLATFORM_FILE_OK) {
- callback.Run(PlatformFileErrorToNetError(error));
+ callback.Run(LocalFileReader::PlatformFileErrorToNetError(error));
return;
}
if (!VerifySnapshotTime(expected_modification_time, file_info)) {
callback.Run(net::ERR_UPLOAD_FILE_CHANGED);
return;
}
- callback.Run(file_info.size - initial_offset);
+ callback.Run(file_info.size);
}
void DidSeekFile(const LocalFileReader::OpenFileStreamCallback& callback,
@@ -78,6 +64,21 @@ void EmptyCompletionCallback(int) {}
} // namespace
+// static
+int LocalFileReader::PlatformFileErrorToNetError(
+ base::PlatformFileError file_error) {
+ switch (file_error) {
+ case base::PLATFORM_FILE_OK:
+ return net::OK;
+ case base::PLATFORM_FILE_ERROR_NOT_FOUND:
+ return net::ERR_FILE_NOT_FOUND;
+ case base::PLATFORM_FILE_ERROR_ACCESS_DENIED:
+ return net::ERR_ACCESS_DENIED;
+ default:
+ return net::ERR_FAILED;
+ }
+}
+
// A helper class to open, verify and seek a file stream for a given path.
class LocalFileReader::OpenFileStreamHelper {
public:
@@ -169,11 +170,11 @@ int LocalFileReader::Read(net::IOBuffer* buf, int buf_len,
make_scoped_refptr(buf), buf_len, callback));
}
-int LocalFileReader::GetLength(const net::CompletionCallback& callback) {
+int LocalFileReader::GetLength(const net::Int64CompletionCallback& callback) {
const bool posted = base::FileUtilProxy::GetFileInfo(
file_thread_proxy_, file_path_,
base::Bind(&DidGetFileInfoForGetLength, callback,
- expected_modification_time_, initial_offset_));
+ expected_modification_time_));
DCHECK(posted);
return net::ERR_IO_PENDING;
}
@@ -202,6 +203,7 @@ void LocalFileReader::DidOpen(net::IOBuffer* buf,
DCHECK(has_pending_open_);
DCHECK(!stream_impl_.get());
has_pending_open_ = false;
+ weak_factory_.InvalidateWeakPtrs();
michaeln 2012/04/13 20:24:51 why this new call to InvalidateWeakPtrs, just curi
kinuko 2012/04/16 10:24:21 Felt it may make things a bit clearer, but since w
if (open_error != net::OK) {
callback.Run(open_error);
return;

Powered by Google App Engine
This is Rietveld 408576698