| 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 "storage/browser/blob/file_stream_reader.h" | 14 #include "storage/browser/blob/file_stream_reader.h" |
| 14 #include "storage/browser/fileapi/file_stream_writer.h" | 15 #include "storage/browser/fileapi/file_stream_writer.h" |
| 15 #include "storage/browser/fileapi/file_system_url.h" | 16 #include "storage/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 17 matching lines...) Expand all Loading... |
| 54 max_bytes_to_read)); | 59 max_bytes_to_read)); |
| 55 } | 60 } |
| 56 | 61 |
| 57 scoped_ptr<storage::FileStreamWriter> BackendDelegate::CreateFileStreamWriter( | 62 scoped_ptr<storage::FileStreamWriter> BackendDelegate::CreateFileStreamWriter( |
| 58 const storage::FileSystemURL& url, | 63 const storage::FileSystemURL& url, |
| 59 int64 offset, | 64 int64 offset, |
| 60 storage::FileSystemContext* context) { | 65 storage::FileSystemContext* context) { |
| 61 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 66 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 62 DCHECK_EQ(storage::kFileSystemTypeProvided, url.type()); | 67 DCHECK_EQ(storage::kFileSystemTypeProvided, url.type()); |
| 63 | 68 |
| 64 return scoped_ptr<storage::FileStreamWriter>( | 69 return scoped_ptr<storage::FileStreamWriter>(new BufferingFileStreamWriter( |
| 65 new FileStreamWriter(url, offset)); | 70 scoped_ptr<storage::FileStreamWriter>(new FileStreamWriter(url, offset)), |
| 71 kWriterBufferSize)); |
| 66 } | 72 } |
| 67 | 73 |
| 68 storage::WatcherManager* BackendDelegate::GetWatcherManager( | 74 storage::WatcherManager* BackendDelegate::GetWatcherManager( |
| 69 const storage::FileSystemURL& url) { | 75 const storage::FileSystemURL& url) { |
| 70 NOTIMPLEMENTED(); | 76 NOTIMPLEMENTED(); |
| 71 return NULL; | 77 return NULL; |
| 72 } | 78 } |
| 73 | 79 |
| 74 void BackendDelegate::GetRedirectURLForContents( | 80 void BackendDelegate::GetRedirectURLForContents( |
| 75 const storage::FileSystemURL& url, | 81 const storage::FileSystemURL& url, |
| 76 const storage::URLCallback& callback) { | 82 const storage::URLCallback& callback) { |
| 77 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 83 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 78 DCHECK_EQ(storage::kFileSystemTypeProvided, url.type()); | 84 DCHECK_EQ(storage::kFileSystemTypeProvided, url.type()); |
| 79 callback.Run(GURL()); | 85 callback.Run(GURL()); |
| 80 } | 86 } |
| 81 | 87 |
| 82 } // namespace file_system_provider | 88 } // namespace file_system_provider |
| 83 } // namespace chromeos | 89 } // namespace chromeos |
| OLD | NEW |