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

Side by Side Diff: storage/browser/blob/blob_reader.cc

Issue 2516713002: [BlobStorage] Implementing disk. (Closed)
Patch Set: windows debugging & victor comments Created 4 years 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 unified diff | Download patch
OLDNEW
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
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
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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 371
367 *output_length = item_length; 372 *output_length = item_length;
368 return true; 373 return true;
369 } 374 }
370 375
371 void BlobReader::DidGetFileItemLength(size_t index, int64_t result) { 376 void BlobReader::DidGetFileItemLength(size_t index, int64_t result) {
372 // Do nothing if we have encountered an error. 377 // Do nothing if we have encountered an error.
373 if (net_error_) 378 if (net_error_)
374 return; 379 return;
375 380
381 if (result < 0)
382 LOG(ERROR) << "Got file error " << result;
383
376 if (result == net::ERR_UPLOAD_FILE_CHANGED) 384 if (result == net::ERR_UPLOAD_FILE_CHANGED)
377 result = net::ERR_FILE_NOT_FOUND; 385 result = net::ERR_FILE_NOT_FOUND;
378 if (result < 0) { 386 if (result < 0) {
379 InvalidateCallbacksAndDone(result, size_callback_); 387 InvalidateCallbacksAndDone(result, size_callback_);
380 return; 388 return;
381 } 389 }
382 390
383 const auto& items = blob_data_->items(); 391 const auto& items = blob_data_->items();
384 DCHECK_LT(index, items.size()); 392 DCHECK_LT(index, items.size());
385 const BlobDataItem& item = *items.at(index); 393 const BlobDataItem& item = *items.at(index);
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 void BlobReader::SetFileReaderAtIndex( 672 void BlobReader::SetFileReaderAtIndex(
665 size_t index, 673 size_t index,
666 std::unique_ptr<FileStreamReader> reader) { 674 std::unique_ptr<FileStreamReader> reader) {
667 if (reader) 675 if (reader)
668 index_to_reader_[index] = std::move(reader); 676 index_to_reader_[index] = std::move(reader);
669 else 677 else
670 index_to_reader_.erase(index); 678 index_to_reader_.erase(index);
671 } 679 }
672 680
673 } // namespace storage 681 } // namespace storage
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698