| OLD | NEW |
| 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 "chrome/browser/chromeos/file_system_provider/fileapi/backend_delegate.
h" | 5 #include "chrome/browser/chromeos/file_system_provider/fileapi/backend_delegate.
h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "chrome/browser/chromeos/file_system_provider/fileapi/buffering_file_st
ream_reader.h" | 8 #include "chrome/browser/chromeos/file_system_provider/fileapi/buffering_file_st
ream_reader.h" |
| 9 #include "chrome/browser/chromeos/file_system_provider/fileapi/buffering_file_st
ream_writer.h" |
| 9 #include "chrome/browser/chromeos/file_system_provider/fileapi/file_stream_reade
r.h" | 10 #include "chrome/browser/chromeos/file_system_provider/fileapi/file_stream_reade
r.h" |
| 10 #include "chrome/browser/chromeos/file_system_provider/fileapi/file_stream_write
r.h" | 11 #include "chrome/browser/chromeos/file_system_provider/fileapi/file_stream_write
r.h" |
| 11 #include "chrome/browser/chromeos/file_system_provider/fileapi/provider_async_fi
le_util.h" | 12 #include "chrome/browser/chromeos/file_system_provider/fileapi/provider_async_fi
le_util.h" |
| 12 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 13 #include "webkit/browser/blob/file_stream_reader.h" | 14 #include "webkit/browser/blob/file_stream_reader.h" |
| 14 #include "webkit/browser/fileapi/file_stream_writer.h" | 15 #include "webkit/browser/fileapi/file_stream_writer.h" |
| 15 #include "webkit/browser/fileapi/file_system_url.h" | 16 #include "webkit/browser/fileapi/file_system_url.h" |
| 16 | 17 |
| 17 using content::BrowserThread; | 18 using content::BrowserThread; |
| 18 | 19 |
| 19 namespace chromeos { | 20 namespace chromeos { |
| 20 namespace file_system_provider { | 21 namespace file_system_provider { |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 // Size of the stream reader internal buffer. At most this number of bytes will | 24 // Size of the stream reader internal buffer. At most this number of bytes will |
| 24 // be read ahead of the requested data. | 25 // be read ahead of the requested data. |
| 25 const int kReaderBufferSize = 512 * 1024; // 512KB. | 26 const int kReaderBufferSize = 512 * 1024; // 512KB. |
| 26 | 27 |
| 28 // Size of the stream writer internal buffer. At most this number of bytes will |
| 29 // be postponed for writing. |
| 30 const int kWriterBufferSize = 512 * 1024; // 512KB. |
| 31 |
| 27 } // namespace | 32 } // namespace |
| 28 | 33 |
| 29 BackendDelegate::BackendDelegate() | 34 BackendDelegate::BackendDelegate() |
| 30 : async_file_util_(new internal::ProviderAsyncFileUtil) {} | 35 : async_file_util_(new internal::ProviderAsyncFileUtil) {} |
| 31 | 36 |
| 32 BackendDelegate::~BackendDelegate() {} | 37 BackendDelegate::~BackendDelegate() {} |
| 33 | 38 |
| 34 storage::AsyncFileUtil* BackendDelegate::GetAsyncFileUtil( | 39 storage::AsyncFileUtil* BackendDelegate::GetAsyncFileUtil( |
| 35 storage::FileSystemType type) { | 40 storage::FileSystemType type) { |
| 36 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 41 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 52 kReaderBufferSize)); | 57 kReaderBufferSize)); |
| 53 } | 58 } |
| 54 | 59 |
| 55 scoped_ptr<storage::FileStreamWriter> BackendDelegate::CreateFileStreamWriter( | 60 scoped_ptr<storage::FileStreamWriter> BackendDelegate::CreateFileStreamWriter( |
| 56 const storage::FileSystemURL& url, | 61 const storage::FileSystemURL& url, |
| 57 int64 offset, | 62 int64 offset, |
| 58 storage::FileSystemContext* context) { | 63 storage::FileSystemContext* context) { |
| 59 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 64 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 60 DCHECK_EQ(storage::kFileSystemTypeProvided, url.type()); | 65 DCHECK_EQ(storage::kFileSystemTypeProvided, url.type()); |
| 61 | 66 |
| 62 return scoped_ptr<storage::FileStreamWriter>( | 67 return scoped_ptr<storage::FileStreamWriter>(new BufferingFileStreamWriter( |
| 63 new FileStreamWriter(url, offset)); | 68 scoped_ptr<storage::FileStreamWriter>(new FileStreamWriter(url, offset)), |
| 69 kWriterBufferSize)); |
| 64 } | 70 } |
| 65 | 71 |
| 66 } // namespace file_system_provider | 72 } // namespace file_system_provider |
| 67 } // namespace chromeos | 73 } // namespace chromeos |
| OLD | NEW |