| 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/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" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/sequenced_task_runner.h" | 12 #include "base/sequenced_task_runner.h" |
| 13 #include "chrome/browser/chromeos/drive/drive.pb.h" | 13 #include "chrome/browser/chromeos/drive/drive.pb.h" |
| 14 #include "chrome/browser/chromeos/drive/file_system_interface.h" | 14 #include "chrome/browser/chromeos/drive/file_system_interface.h" |
| 15 #include "chrome/browser/chromeos/drive/local_file_reader.h" | 15 #include "chrome/browser/chromeos/drive/local_file_reader.h" |
| 16 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
| 17 #include "google_apis/drive/task_util.h" | 17 #include "google_apis/drive/task_util.h" |
| 18 #include "net/base/io_buffer.h" | 18 #include "net/base/io_buffer.h" |
| 19 #include "net/base/net_errors.h" | 19 #include "net/base/net_errors.h" |
| 20 #include "net/http/http_byte_range.h" | 20 #include "net/http/http_byte_range.h" |
| 21 | 21 |
| 22 using content::BrowserThread; | 22 using content::BrowserThread; |
| 23 | 23 |
| 24 namespace drive { | 24 namespace drive { |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 // Converts FileError code to net::Error code. | 27 // Converts FileError code to net::Error code. |
| 28 int FileErrorToNetError(FileError error) { | 28 int FileErrorToNetError(FileError error) { |
| 29 return net::PlatformFileErrorToNetError(FileErrorToPlatformError(error)); | 29 return net::FileErrorToNetError(FileErrorToBaseFileError(error)); |
| 30 } | 30 } |
| 31 | 31 |
| 32 // Runs task on UI thread. | 32 // Runs task on UI thread. |
| 33 void RunTaskOnUIThread(const base::Closure& task) { | 33 void RunTaskOnUIThread(const base::Closure& task) { |
| 34 google_apis::RunTaskOnThread( | 34 google_apis::RunTaskOnThread( |
| 35 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), task); | 35 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), task); |
| 36 } | 36 } |
| 37 | 37 |
| 38 // Computes the concrete |start| offset and the |length| of |range| in a file | 38 // Computes the concrete |start| offset and the |length| of |range| in a file |
| 39 // of |total| size. | 39 // of |total| size. |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 // Note: due to the same reason, LocalReaderProxy::OnCompleted may | 463 // 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 | 464 // or may not be called. This is timing issue, and it is difficult to avoid |
| 465 // unfortunately. | 465 // unfortunately. |
| 466 if (error != FILE_ERROR_OK) { | 466 if (error != FILE_ERROR_OK) { |
| 467 callback.Run(FileErrorToNetError(error), scoped_ptr<ResourceEntry>()); | 467 callback.Run(FileErrorToNetError(error), scoped_ptr<ResourceEntry>()); |
| 468 } | 468 } |
| 469 } | 469 } |
| 470 } | 470 } |
| 471 | 471 |
| 472 } // namespace drive | 472 } // namespace drive |
| OLD | NEW |