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/drive/fileapi/file_system_backend_delegate.h" | 5 #include "chrome/browser/chromeos/drive/fileapi/file_system_backend_delegate.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/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "chrome/browser/chromeos/drive/file_system_interface.h" | 10 #include "chrome/browser/chromeos/drive/file_system_interface.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 | 72 |
73 FileSystemBackendDelegate::FileSystemBackendDelegate() | 73 FileSystemBackendDelegate::FileSystemBackendDelegate() |
74 : async_file_util_(new internal::AsyncFileUtil) { | 74 : async_file_util_(new internal::AsyncFileUtil) { |
75 } | 75 } |
76 | 76 |
77 FileSystemBackendDelegate::~FileSystemBackendDelegate() { | 77 FileSystemBackendDelegate::~FileSystemBackendDelegate() { |
78 } | 78 } |
79 | 79 |
80 storage::AsyncFileUtil* FileSystemBackendDelegate::GetAsyncFileUtil( | 80 storage::AsyncFileUtil* FileSystemBackendDelegate::GetAsyncFileUtil( |
81 storage::FileSystemType type) { | 81 storage::FileSystemType type) { |
82 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 82 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
83 DCHECK_EQ(storage::kFileSystemTypeDrive, type); | 83 DCHECK_EQ(storage::kFileSystemTypeDrive, type); |
84 return async_file_util_.get(); | 84 return async_file_util_.get(); |
85 } | 85 } |
86 | 86 |
87 scoped_ptr<storage::FileStreamReader> | 87 scoped_ptr<storage::FileStreamReader> |
88 FileSystemBackendDelegate::CreateFileStreamReader( | 88 FileSystemBackendDelegate::CreateFileStreamReader( |
89 const storage::FileSystemURL& url, | 89 const storage::FileSystemURL& url, |
90 int64 offset, | 90 int64 offset, |
91 int64 max_bytes_to_read, | 91 int64 max_bytes_to_read, |
92 const base::Time& expected_modification_time, | 92 const base::Time& expected_modification_time, |
93 storage::FileSystemContext* context) { | 93 storage::FileSystemContext* context) { |
94 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 94 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
95 DCHECK_EQ(storage::kFileSystemTypeDrive, url.type()); | 95 DCHECK_EQ(storage::kFileSystemTypeDrive, url.type()); |
96 | 96 |
97 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url); | 97 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url); |
98 if (file_path.empty()) | 98 if (file_path.empty()) |
99 return scoped_ptr<storage::FileStreamReader>(); | 99 return scoped_ptr<storage::FileStreamReader>(); |
100 | 100 |
101 return scoped_ptr<storage::FileStreamReader>( | 101 return scoped_ptr<storage::FileStreamReader>( |
102 new internal::WebkitFileStreamReaderImpl( | 102 new internal::WebkitFileStreamReaderImpl( |
103 base::Bind(&fileapi_internal::GetFileSystemFromUrl, url), | 103 base::Bind(&fileapi_internal::GetFileSystemFromUrl, url), |
104 context->default_file_task_runner(), | 104 context->default_file_task_runner(), |
105 file_path, | 105 file_path, |
106 offset, | 106 offset, |
107 expected_modification_time)); | 107 expected_modification_time)); |
108 } | 108 } |
109 | 109 |
110 scoped_ptr<storage::FileStreamWriter> | 110 scoped_ptr<storage::FileStreamWriter> |
111 FileSystemBackendDelegate::CreateFileStreamWriter( | 111 FileSystemBackendDelegate::CreateFileStreamWriter( |
112 const storage::FileSystemURL& url, | 112 const storage::FileSystemURL& url, |
113 int64 offset, | 113 int64 offset, |
114 storage::FileSystemContext* context) { | 114 storage::FileSystemContext* context) { |
115 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 115 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
116 DCHECK_EQ(storage::kFileSystemTypeDrive, url.type()); | 116 DCHECK_EQ(storage::kFileSystemTypeDrive, url.type()); |
117 | 117 |
118 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url); | 118 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url); |
119 // Hosted documents don't support stream writer. | 119 // Hosted documents don't support stream writer. |
120 if (file_path.empty() || util::HasHostedDocumentExtension(file_path)) | 120 if (file_path.empty() || util::HasHostedDocumentExtension(file_path)) |
121 return scoped_ptr<storage::FileStreamWriter>(); | 121 return scoped_ptr<storage::FileStreamWriter>(); |
122 | 122 |
123 return scoped_ptr<storage::FileStreamWriter>( | 123 return scoped_ptr<storage::FileStreamWriter>( |
124 new internal::WebkitFileStreamWriterImpl( | 124 new internal::WebkitFileStreamWriterImpl( |
125 base::Bind(&fileapi_internal::GetFileSystemFromUrl, url), | 125 base::Bind(&fileapi_internal::GetFileSystemFromUrl, url), |
(...skipping 12 matching lines...) Expand all Loading... |
138 const storage::FileSystemURL& url, | 138 const storage::FileSystemURL& url, |
139 const storage::URLCallback& callback) { | 139 const storage::URLCallback& callback) { |
140 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 140 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
141 BrowserThread::PostTask( | 141 BrowserThread::PostTask( |
142 BrowserThread::UI, | 142 BrowserThread::UI, |
143 FROM_HERE, | 143 FROM_HERE, |
144 base::Bind(&GetRedirectURLForContentsOnUIThread, url, callback)); | 144 base::Bind(&GetRedirectURLForContentsOnUIThread, url, callback)); |
145 } | 145 } |
146 | 146 |
147 } // namespace drive | 147 } // namespace drive |
OLD | NEW |