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

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

Issue 1148383003: Only support seeking file streams from the beginning of the file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Win DBG build by Pass()-ing file out of CreateForAsyncHandle. Created 5 years, 6 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
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/local_file_reader.h" 5 #include "chrome/browser/chromeos/drive/local_file_reader.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/sequenced_task_runner.h" 9 #include "base/sequenced_task_runner.h"
10 #include "net/base/completion_callback.h" 10 #include "net/base/completion_callback.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 int rv = file_stream_.Read(in_buffer, buffer_length, callback); 45 int rv = file_stream_.Read(in_buffer, buffer_length, callback);
46 DCHECK_EQ(rv, net::ERR_IO_PENDING); 46 DCHECK_EQ(rv, net::ERR_IO_PENDING);
47 } 47 }
48 48
49 void LocalFileReader::DidOpen(const net::CompletionCallback& callback, 49 void LocalFileReader::DidOpen(const net::CompletionCallback& callback,
50 int64 offset, 50 int64 offset,
51 int error) { 51 int error) {
52 if (error != net::OK) 52 if (error != net::OK)
53 return callback.Run(error); 53 return callback.Run(error);
54 54
55 int rv = file_stream_.Seek(base::File::FROM_BEGIN, offset, 55 int rv = file_stream_.Seek(
56 Bind(&LocalFileReader::DidSeek, 56 offset, Bind(&LocalFileReader::DidSeek, weak_ptr_factory_.GetWeakPtr(),
57 weak_ptr_factory_.GetWeakPtr(), 57 callback, offset));
58 callback, offset));
59 DCHECK_EQ(rv, net::ERR_IO_PENDING); 58 DCHECK_EQ(rv, net::ERR_IO_PENDING);
60 } 59 }
61 60
62 void LocalFileReader::DidSeek(const net::CompletionCallback& callback, 61 void LocalFileReader::DidSeek(const net::CompletionCallback& callback,
63 int64 offset, 62 int64 offset,
64 int64 error) { 63 int64 error) {
65 callback.Run(error == offset ? net::OK : net::ERR_FAILED); 64 callback.Run(error == offset ? net::OK : net::ERR_FAILED);
66 } 65 }
67 66
68 } // namespace util 67 } // namespace util
69 } // namespace drive 68 } // namespace drive
OLDNEW
« no previous file with comments | « base/files/file.cc ('k') | chrome/browser/extensions/api/messaging/native_message_process_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698