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

Side by Side Diff: content/browser/fileapi/upload_file_system_file_element_reader.cc

Issue 470323003: [fsp] Improve performance for reading small chunks of data. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleaned up. Created 6 years, 3 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/browser/fileapi/upload_file_system_file_element_reader.h" 5 #include "content/browser/fileapi/upload_file_system_file_element_reader.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 23 matching lines...) Expand all
34 } 34 }
35 35
36 int UploadFileSystemFileElementReader::Init( 36 int UploadFileSystemFileElementReader::Init(
37 const net::CompletionCallback& callback) { 37 const net::CompletionCallback& callback) {
38 // Reset states. 38 // Reset states.
39 weak_ptr_factory_.InvalidateWeakPtrs(); 39 weak_ptr_factory_.InvalidateWeakPtrs();
40 stream_length_ = 0; 40 stream_length_ = 0;
41 position_ = 0; 41 position_ = 0;
42 42
43 // Initialize the stream reader and the length. 43 // Initialize the stream reader and the length.
44 stream_reader_ = 44 stream_reader_ = file_system_context_->CreateFileStreamReader(
45 file_system_context_->CreateFileStreamReader( 45 file_system_context_->CrackURL(url_),
46 file_system_context_->CrackURL(url_), 46 range_offset_,
47 range_offset_, 47 range_length_,
hashimoto 2014/09/04 11:21:25 Please add a check here.
mtomasz 2014/09/05 01:04:40 Done.
48 expected_modification_time_); 48 expected_modification_time_);
49 DCHECK(stream_reader_); 49 DCHECK(stream_reader_);
50 50
51 const int64 result = stream_reader_->GetLength( 51 const int64 result = stream_reader_->GetLength(
52 base::Bind(&UploadFileSystemFileElementReader::OnGetLength, 52 base::Bind(&UploadFileSystemFileElementReader::OnGetLength,
53 weak_ptr_factory_.GetWeakPtr(), 53 weak_ptr_factory_.GetWeakPtr(),
54 callback)); 54 callback));
55 if (result >= 0) { 55 if (result >= 0) {
56 stream_length_ = result; 56 stream_length_ = result;
57 return net::OK; 57 return net::OK;
58 } 58 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 int result) { 108 int result) {
109 if (result > 0) { 109 if (result > 0) {
110 position_ += result; 110 position_ += result;
111 DCHECK_LE(position_, GetContentLength()); 111 DCHECK_LE(position_, GetContentLength());
112 } 112 }
113 if (!callback.is_null()) 113 if (!callback.is_null())
114 callback.Run(result); 114 callback.Run(result);
115 } 115 }
116 116
117 } // namespace content 117 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698