OLD | NEW |
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 "net/base/upload_file_element_reader.h" | 5 #include "net/base/upload_file_element_reader.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/task_runner_util.h" | 10 #include "base/task_runner_util.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 return this; | 46 return this; |
47 } | 47 } |
48 | 48 |
49 int UploadFileElementReader::Init(const CompletionCallback& callback) { | 49 int UploadFileElementReader::Init(const CompletionCallback& callback) { |
50 DCHECK(!callback.is_null()); | 50 DCHECK(!callback.is_null()); |
51 Reset(); | 51 Reset(); |
52 | 52 |
53 file_stream_.reset(new FileStream(NULL, task_runner_.get())); | 53 file_stream_.reset(new FileStream(NULL, task_runner_.get())); |
54 int result = file_stream_->Open( | 54 int result = file_stream_->Open( |
55 path_, | 55 path_, |
56 base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ | | 56 base::File::FLAG_OPEN | base::File::FLAG_READ | |
57 base::PLATFORM_FILE_ASYNC, | 57 base::File::FLAG_ASYNC, |
58 base::Bind(&UploadFileElementReader::OnOpenCompleted, | 58 base::Bind(&UploadFileElementReader::OnOpenCompleted, |
59 weak_ptr_factory_.GetWeakPtr(), | 59 weak_ptr_factory_.GetWeakPtr(), |
60 callback)); | 60 callback)); |
61 DCHECK_GT(0, result); | 61 DCHECK_GT(0, result); |
62 return result; | 62 return result; |
63 } | 63 } |
64 | 64 |
65 uint64 UploadFileElementReader::GetContentLength() const { | 65 uint64 UploadFileElementReader::GetContentLength() const { |
66 if (overriding_content_length) | 66 if (overriding_content_length) |
67 return overriding_content_length; | 67 return overriding_content_length; |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 ScopedOverridingContentLengthForTests(uint64 value) { | 205 ScopedOverridingContentLengthForTests(uint64 value) { |
206 overriding_content_length = value; | 206 overriding_content_length = value; |
207 } | 207 } |
208 | 208 |
209 UploadFileElementReader::ScopedOverridingContentLengthForTests:: | 209 UploadFileElementReader::ScopedOverridingContentLengthForTests:: |
210 ~ScopedOverridingContentLengthForTests() { | 210 ~ScopedOverridingContentLengthForTests() { |
211 overriding_content_length = 0; | 211 overriding_content_length = 0; |
212 } | 212 } |
213 | 213 |
214 } // namespace net | 214 } // namespace net |
OLD | NEW |