OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "storage/browser/blob/blob_reader.h" | 5 #include "storage/browser/blob/blob_reader.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
11 #include <limits> | 11 #include <limits> |
12 #include <memory> | 12 #include <memory> |
13 #include <utility> | 13 #include <utility> |
14 | 14 |
15 #include "base/bind.h" | 15 #include "base/bind.h" |
16 #include "base/callback_helpers.h" | 16 #include "base/callback_helpers.h" |
17 #include "base/debug/stack_trace.h" | |
17 #include "base/sequenced_task_runner.h" | 18 #include "base/sequenced_task_runner.h" |
18 #include "base/time/time.h" | 19 #include "base/time/time.h" |
19 #include "base/trace_event/trace_event.h" | 20 #include "base/trace_event/trace_event.h" |
20 #include "net/base/io_buffer.h" | 21 #include "net/base/io_buffer.h" |
21 #include "net/base/net_errors.h" | 22 #include "net/base/net_errors.h" |
22 #include "net/disk_cache/disk_cache.h" | 23 #include "net/disk_cache/disk_cache.h" |
23 #include "storage/browser/blob/blob_data_handle.h" | 24 #include "storage/browser/blob/blob_data_handle.h" |
24 #include "storage/browser/blob/blob_data_snapshot.h" | 25 #include "storage/browser/blob/blob_data_snapshot.h" |
25 #include "storage/browser/fileapi/file_stream_reader.h" | 26 #include "storage/browser/fileapi/file_stream_reader.h" |
26 #include "storage/browser/fileapi/file_system_context.h" | 27 #include "storage/browser/fileapi/file_system_context.h" |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
238 for (const auto& item : blob_data_->items()) { | 239 for (const auto& item : blob_data_->items()) { |
239 if (item->type() != DataElement::TYPE_BYTES) { | 240 if (item->type() != DataElement::TYPE_BYTES) { |
240 return false; | 241 return false; |
241 } | 242 } |
242 } | 243 } |
243 return true; | 244 return true; |
244 } | 245 } |
245 | 246 |
246 void BlobReader::InvalidateCallbacksAndDone(int net_error, | 247 void BlobReader::InvalidateCallbacksAndDone(int net_error, |
247 net::CompletionCallback done) { | 248 net::CompletionCallback done) { |
249 LOG(ERROR) << "Async error: " << net_error | |
michaeln
2016/12/02 20:41:07
is this needed in release builds or would DLOG or
dmurph
2016/12/02 21:53:07
Removed, this was for figuring out the browsertest
| |
250 << " with stack: " << base::debug::StackTrace().ToString(); | |
248 net_error_ = net_error; | 251 net_error_ = net_error; |
249 weak_factory_.InvalidateWeakPtrs(); | 252 weak_factory_.InvalidateWeakPtrs(); |
250 size_callback_.Reset(); | 253 size_callback_.Reset(); |
251 read_callback_.Reset(); | 254 read_callback_.Reset(); |
252 read_buf_ = nullptr; | 255 read_buf_ = nullptr; |
253 done.Run(net_error); | 256 done.Run(net_error); |
254 } | 257 } |
255 | 258 |
256 BlobReader::Status BlobReader::ReportError(int net_error) { | 259 BlobReader::Status BlobReader::ReportError(int net_error) { |
260 LOG(ERROR) << "Error: " << net_error | |
261 << " with stack: " << base::debug::StackTrace().ToString(); | |
257 net_error_ = net_error; | 262 net_error_ = net_error; |
258 return Status::NET_ERROR; | 263 return Status::NET_ERROR; |
259 } | 264 } |
260 | 265 |
261 void BlobReader::AsyncCalculateSize(const net::CompletionCallback& done, | 266 void BlobReader::AsyncCalculateSize(const net::CompletionCallback& done, |
262 BlobStatus status) { | 267 BlobStatus status) { |
263 if (BlobStatusIsError(status)) { | 268 if (BlobStatusIsError(status)) { |
264 InvalidateCallbacksAndDone(ConvertBlobErrorToNetError(status), done); | 269 InvalidateCallbacksAndDone(ConvertBlobErrorToNetError(status), done); |
265 return; | 270 return; |
266 } | 271 } |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
664 void BlobReader::SetFileReaderAtIndex( | 669 void BlobReader::SetFileReaderAtIndex( |
665 size_t index, | 670 size_t index, |
666 std::unique_ptr<FileStreamReader> reader) { | 671 std::unique_ptr<FileStreamReader> reader) { |
667 if (reader) | 672 if (reader) |
668 index_to_reader_[index] = std::move(reader); | 673 index_to_reader_[index] = std::move(reader); |
669 else | 674 else |
670 index_to_reader_.erase(index); | 675 index_to_reader_.erase(index); |
671 } | 676 } |
672 | 677 |
673 } // namespace storage | 678 } // namespace storage |
OLD | NEW |