| OLD | NEW |
| 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 <errno.h> | 7 #include <errno.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 // First of all, open the file. | 35 // First of all, open the file. |
| 36 const int open_flags = base::PLATFORM_FILE_OPEN | | 36 const int open_flags = base::PLATFORM_FILE_OPEN | |
| 37 base::PLATFORM_FILE_READ | | 37 base::PLATFORM_FILE_READ | |
| 38 base::PLATFORM_FILE_ASYNC; | 38 base::PLATFORM_FILE_ASYNC; |
| 39 base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED; | 39 base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED; |
| 40 base::PlatformFile file = | 40 base::PlatformFile file = |
| 41 base::CreatePlatformFile(file_path, open_flags, NULL, &error); | 41 base::CreatePlatformFile(file_path, open_flags, NULL, &error); |
| 42 if (file == base::kInvalidPlatformFileValue) { | 42 if (file == base::kInvalidPlatformFileValue) { |
| 43 DCHECK_NE(base::PLATFORM_FILE_OK, error); | 43 DCHECK_NE(base::PLATFORM_FILE_OK, error); |
| 44 return net::PlatformFileErrorToNetError(error); | 44 return net::FileErrorToNetError(static_cast<base::File::Error>(error)); |
| 45 } | 45 } |
| 46 | 46 |
| 47 // If succeeded, seek to the |offset| from begin. | 47 // If succeeded, seek to the |offset| from begin. |
| 48 int64 position = base::SeekPlatformFile( | 48 int64 position = base::SeekPlatformFile( |
| 49 file, base::PLATFORM_FILE_FROM_BEGIN, offset); | 49 file, base::PLATFORM_FILE_FROM_BEGIN, offset); |
| 50 if (position < 0) { | 50 if (position < 0) { |
| 51 // If failed, close the file and return an error. | 51 // If failed, close the file and return an error. |
| 52 base::ClosePlatformFile(file); | 52 base::ClosePlatformFile(file); |
| 53 return net::ERR_FAILED; | 53 return net::ERR_FAILED; |
| 54 } | 54 } |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 if (open_result == net::OK) { | 168 if (open_result == net::OK) { |
| 169 DCHECK_NE(base::kInvalidPlatformFileValue, *platform_file->ptr()); | 169 DCHECK_NE(base::kInvalidPlatformFileValue, *platform_file->ptr()); |
| 170 platform_file_ = platform_file->release(); | 170 platform_file_ = platform_file->release(); |
| 171 } | 171 } |
| 172 | 172 |
| 173 callback.Run(open_result); | 173 callback.Run(open_result); |
| 174 } | 174 } |
| 175 | 175 |
| 176 } // namespace util | 176 } // namespace util |
| 177 } // namespace drive | 177 } // namespace drive |
| OLD | NEW |