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

Side by Side Diff: chrome/browser/chromeos/drive/drive_file_stream_reader.cc

Issue 211483004: Remove some PlatformFile instances from ChromeOS Drive. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Change FileStream destruction logic Created 6 years, 9 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/drive/file_system/truncate_operation.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/chromeos/drive/drive_file_stream_reader.h" 5 #include "chrome/browser/chromeos/drive/drive_file_stream_reader.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstring> 8 #include <cstring>
9 9
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 int LocalReaderProxy::Read(net::IOBuffer* buffer, int buffer_length, 112 int LocalReaderProxy::Read(net::IOBuffer* buffer, int buffer_length,
113 const net::CompletionCallback& callback) { 113 const net::CompletionCallback& callback) {
114 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 114 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
115 DCHECK(file_reader_); 115 DCHECK(file_reader_);
116 116
117 if (buffer_length > remaining_length_) { 117 if (buffer_length > remaining_length_) {
118 // Here, narrowing is safe. 118 // Here, narrowing is safe.
119 buffer_length = static_cast<int>(remaining_length_); 119 buffer_length = static_cast<int>(remaining_length_);
120 } 120 }
121 121
122 if (!buffer_length)
123 return 0;
124
122 file_reader_->Read(buffer, buffer_length, 125 file_reader_->Read(buffer, buffer_length,
123 base::Bind(&LocalReaderProxy::OnReadCompleted, 126 base::Bind(&LocalReaderProxy::OnReadCompleted,
124 weak_ptr_factory_.GetWeakPtr(), callback)); 127 weak_ptr_factory_.GetWeakPtr(), callback));
125 return net::ERR_IO_PENDING; 128 return net::ERR_IO_PENDING;
126 } 129 }
127 130
128 void LocalReaderProxy::OnGetContent(scoped_ptr<std::string> data) { 131 void LocalReaderProxy::OnGetContent(scoped_ptr<std::string> data) {
129 // This method should never be called, because no data should be received 132 // This method should never be called, because no data should be received
130 // from the network during the reading of local-cache file. 133 // from the network during the reading of local-cache file.
131 NOTREACHED(); 134 NOTREACHED();
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 // Note: due to the same reason, LocalReaderProxy::OnCompleted may 466 // Note: due to the same reason, LocalReaderProxy::OnCompleted may
464 // or may not be called. This is timing issue, and it is difficult to avoid 467 // or may not be called. This is timing issue, and it is difficult to avoid
465 // unfortunately. 468 // unfortunately.
466 if (error != FILE_ERROR_OK) { 469 if (error != FILE_ERROR_OK) {
467 callback.Run(FileErrorToNetError(error), scoped_ptr<ResourceEntry>()); 470 callback.Run(FileErrorToNetError(error), scoped_ptr<ResourceEntry>());
468 } 471 }
469 } 472 }
470 } 473 }
471 474
472 } // namespace drive 475 } // namespace drive
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/drive/file_system/truncate_operation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698