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/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/profiler/scoped_profile.h" |
10 #include "base/task_runner_util.h" | 11 #include "base/task_runner_util.h" |
11 #include "net/base/file_stream.h" | 12 #include "net/base/file_stream.h" |
12 #include "net/base/io_buffer.h" | 13 #include "net/base/io_buffer.h" |
13 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
14 | 15 |
15 namespace net { | 16 namespace net { |
16 | 17 |
17 namespace { | 18 namespace { |
18 | 19 |
19 // In tests, this value is used to override the return value of | 20 // In tests, this value is used to override the return value of |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 void UploadFileElementReader::Reset() { | 97 void UploadFileElementReader::Reset() { |
97 weak_ptr_factory_.InvalidateWeakPtrs(); | 98 weak_ptr_factory_.InvalidateWeakPtrs(); |
98 bytes_remaining_ = 0; | 99 bytes_remaining_ = 0; |
99 content_length_ = 0; | 100 content_length_ = 0; |
100 file_stream_.reset(); | 101 file_stream_.reset(); |
101 } | 102 } |
102 | 103 |
103 void UploadFileElementReader::OnOpenCompleted( | 104 void UploadFileElementReader::OnOpenCompleted( |
104 const CompletionCallback& callback, | 105 const CompletionCallback& callback, |
105 int result) { | 106 int result) { |
| 107 // TODO(vadimt): Remove ScopedProfile below once crbug.com/423948 is fixed. |
| 108 tracked_objects::ScopedProfile tracking_profile( |
| 109 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 110 "423948 UploadFileElementReader::OnOpenCompleted")); |
| 111 |
106 DCHECK(!callback.is_null()); | 112 DCHECK(!callback.is_null()); |
107 | 113 |
108 if (result < 0) { | 114 if (result < 0) { |
109 DLOG(WARNING) << "Failed to open \"" << path_.value() | 115 DLOG(WARNING) << "Failed to open \"" << path_.value() |
110 << "\" for reading: " << result; | 116 << "\" for reading: " << result; |
111 callback.Run(result); | 117 callback.Run(result); |
112 return; | 118 return; |
113 } | 119 } |
114 | 120 |
115 if (range_offset_) { | 121 if (range_offset_) { |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 ScopedOverridingContentLengthForTests(uint64 value) { | 209 ScopedOverridingContentLengthForTests(uint64 value) { |
204 overriding_content_length = value; | 210 overriding_content_length = value; |
205 } | 211 } |
206 | 212 |
207 UploadFileElementReader::ScopedOverridingContentLengthForTests:: | 213 UploadFileElementReader::ScopedOverridingContentLengthForTests:: |
208 ~ScopedOverridingContentLengthForTests() { | 214 ~ScopedOverridingContentLengthForTests() { |
209 overriding_content_length = 0; | 215 overriding_content_length = 0; |
210 } | 216 } |
211 | 217 |
212 } // namespace net | 218 } // namespace net |
OLD | NEW |