OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/upload_file_system_file_element_reader.h" | 5 #include "webkit/fileapi/upload_file_system_file_element_reader.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "net/base/net_errors.h" | 8 #include "net/base/net_errors.h" |
9 #include "webkit/blob/file_stream_reader.h" | 9 #include "webkit/blob/file_stream_reader.h" |
10 #include "webkit/fileapi/file_system_context.h" | 10 #include "webkit/fileapi/file_system_context.h" |
11 #include "webkit/fileapi/file_system_url.h" | 11 #include "webkit/fileapi/file_system_url.h" |
12 | 12 |
13 namespace fileapi { | 13 namespace fileapi { |
14 | 14 |
15 UploadFileSystemFileElementReader::UploadFileSystemFileElementReader( | 15 UploadFileSystemFileElementReader::UploadFileSystemFileElementReader( |
16 FileSystemContext* file_system_context, | 16 FileSystemContext* file_system_context, |
17 const GURL& url, | 17 const GURL& url, |
18 uint64 range_offset, | 18 uint64 range_offset, |
19 uint64 range_length, | 19 uint64 range_length, |
20 const base::Time& expected_modification_time) | 20 const base::Time& expected_modification_time) |
21 : file_system_context_(file_system_context), | 21 : file_system_context_(file_system_context), |
22 url_(url), | 22 url_(url), |
23 range_offset_(range_offset), | 23 range_offset_(range_offset), |
24 range_length_(range_length), | 24 range_length_(range_length), |
25 expected_modification_time_(expected_modification_time), | 25 expected_modification_time_(expected_modification_time), |
26 stream_length_(0), | 26 stream_length_(0), |
27 position_(0), | 27 position_(0), |
28 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 28 weak_ptr_factory_(this) { |
29 } | 29 } |
30 | 30 |
31 UploadFileSystemFileElementReader::~UploadFileSystemFileElementReader() { | 31 UploadFileSystemFileElementReader::~UploadFileSystemFileElementReader() { |
32 } | 32 } |
33 | 33 |
34 int UploadFileSystemFileElementReader::Init( | 34 int UploadFileSystemFileElementReader::Init( |
35 const net::CompletionCallback& callback) { | 35 const net::CompletionCallback& callback) { |
36 // Reset states. | 36 // Reset states. |
37 weak_ptr_factory_.InvalidateWeakPtrs(); | 37 weak_ptr_factory_.InvalidateWeakPtrs(); |
38 stream_length_ = 0; | 38 stream_length_ = 0; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 int result) { | 106 int result) { |
107 if (result > 0) { | 107 if (result > 0) { |
108 position_ += result; | 108 position_ += result; |
109 DCHECK_LE(position_, GetContentLength()); | 109 DCHECK_LE(position_, GetContentLength()); |
110 } | 110 } |
111 if (!callback.is_null()) | 111 if (!callback.is_null()) |
112 callback.Run(result); | 112 callback.Run(result); |
113 } | 113 } |
114 | 114 |
115 } // namespace fileapi | 115 } // namespace fileapi |
OLD | NEW |