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/mount_point_provider_delegate.h" | 5 #include "chrome/browser/chromeos/drive/file_system_backend_delegate.h" |
6 | 6 |
7 #include "chrome/browser/chromeos/fileapi/remote_file_stream_writer.h" | 7 #include "chrome/browser/chromeos/fileapi/remote_file_stream_writer.h" |
8 #include "chrome/browser/chromeos/fileapi/remote_file_system_operation.h" | 8 #include "chrome/browser/chromeos/fileapi/remote_file_system_operation.h" |
9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
10 #include "webkit/browser/blob/file_stream_reader.h" | 10 #include "webkit/browser/blob/file_stream_reader.h" |
11 #include "webkit/browser/fileapi/external_mount_points.h" | 11 #include "webkit/browser/fileapi/external_mount_points.h" |
12 #include "webkit/browser/fileapi/file_system_task_runners.h" | 12 #include "webkit/browser/fileapi/file_system_task_runners.h" |
13 #include "webkit/browser/fileapi/remote_file_system_proxy.h" | 13 #include "webkit/browser/fileapi/remote_file_system_proxy.h" |
14 | 14 |
15 using content::BrowserThread; | 15 using content::BrowserThread; |
16 | 16 |
17 namespace drive { | 17 namespace drive { |
18 | 18 |
19 MountPointProviderDelegate::MountPointProviderDelegate( | 19 FileSystemBackendDelegate::FileSystemBackendDelegate( |
20 fileapi::ExternalMountPoints* mount_points) | 20 fileapi::ExternalMountPoints* mount_points) |
21 : mount_points_(mount_points) { | 21 : mount_points_(mount_points) { |
22 } | 22 } |
23 | 23 |
24 MountPointProviderDelegate::~MountPointProviderDelegate() { | 24 FileSystemBackendDelegate::~FileSystemBackendDelegate() { |
25 } | 25 } |
26 | 26 |
27 fileapi::AsyncFileUtil* MountPointProviderDelegate::GetAsyncFileUtil( | 27 fileapi::AsyncFileUtil* FileSystemBackendDelegate::GetAsyncFileUtil( |
28 fileapi::FileSystemType type) { | 28 fileapi::FileSystemType type) { |
29 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 29 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
30 DCHECK_EQ(fileapi::kFileSystemTypeDrive, type); | 30 DCHECK_EQ(fileapi::kFileSystemTypeDrive, type); |
31 | 31 |
32 // TODO(hidehiko): Support this method. | 32 // TODO(hidehiko): Support this method. |
33 NOTIMPLEMENTED(); | 33 NOTIMPLEMENTED(); |
34 return NULL; | 34 return NULL; |
35 } | 35 } |
36 | 36 |
37 scoped_ptr<webkit_blob::FileStreamReader> | 37 scoped_ptr<webkit_blob::FileStreamReader> |
38 MountPointProviderDelegate::CreateFileStreamReader( | 38 FileSystemBackendDelegate::CreateFileStreamReader( |
39 const fileapi::FileSystemURL& url, | 39 const fileapi::FileSystemURL& url, |
40 int64 offset, | 40 int64 offset, |
41 const base::Time& expected_modification_time, | 41 const base::Time& expected_modification_time, |
42 fileapi::FileSystemContext* context) { | 42 fileapi::FileSystemContext* context) { |
43 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 43 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
44 DCHECK_EQ(fileapi::kFileSystemTypeDrive, url.type()); | 44 DCHECK_EQ(fileapi::kFileSystemTypeDrive, url.type()); |
45 | 45 |
46 fileapi::RemoteFileSystemProxyInterface* proxy = | 46 fileapi::RemoteFileSystemProxyInterface* proxy = |
47 mount_points_->GetRemoteFileSystemProxy(url.filesystem_id()); | 47 mount_points_->GetRemoteFileSystemProxy(url.filesystem_id()); |
48 if (!proxy) | 48 if (!proxy) |
49 return scoped_ptr<webkit_blob::FileStreamReader>(); | 49 return scoped_ptr<webkit_blob::FileStreamReader>(); |
50 | 50 |
51 return proxy->CreateFileStreamReader( | 51 return proxy->CreateFileStreamReader( |
52 context->task_runners()->file_task_runner(), | 52 context->task_runners()->file_task_runner(), |
53 url, offset, expected_modification_time); | 53 url, offset, expected_modification_time); |
54 } | 54 } |
55 | 55 |
56 scoped_ptr<fileapi::FileStreamWriter> | 56 scoped_ptr<fileapi::FileStreamWriter> |
57 MountPointProviderDelegate::CreateFileStreamWriter( | 57 FileSystemBackendDelegate::CreateFileStreamWriter( |
58 const fileapi::FileSystemURL& url, | 58 const fileapi::FileSystemURL& url, |
59 int64 offset, | 59 int64 offset, |
60 fileapi::FileSystemContext* context) { | 60 fileapi::FileSystemContext* context) { |
61 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 61 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
62 DCHECK_EQ(fileapi::kFileSystemTypeDrive, url.type()); | 62 DCHECK_EQ(fileapi::kFileSystemTypeDrive, url.type()); |
63 | 63 |
64 fileapi::RemoteFileSystemProxyInterface* proxy = | 64 fileapi::RemoteFileSystemProxyInterface* proxy = |
65 mount_points_->GetRemoteFileSystemProxy(url.filesystem_id()); | 65 mount_points_->GetRemoteFileSystemProxy(url.filesystem_id()); |
66 if (!proxy) | 66 if (!proxy) |
67 return scoped_ptr<fileapi::FileStreamWriter>(); | 67 return scoped_ptr<fileapi::FileStreamWriter>(); |
68 | 68 |
69 return scoped_ptr<fileapi::FileStreamWriter>( | 69 return scoped_ptr<fileapi::FileStreamWriter>( |
70 new chromeos::RemoteFileStreamWriter( | 70 new chromeos::RemoteFileStreamWriter( |
71 proxy, url, offset, context->task_runners()->file_task_runner())); | 71 proxy, url, offset, context->task_runners()->file_task_runner())); |
72 } | 72 } |
73 | 73 |
74 fileapi::FileSystemOperation* | 74 fileapi::FileSystemOperation* |
75 MountPointProviderDelegate::CreateFileSystemOperation( | 75 FileSystemBackendDelegate::CreateFileSystemOperation( |
76 const fileapi::FileSystemURL& url, | 76 const fileapi::FileSystemURL& url, |
77 fileapi::FileSystemContext* context, | 77 fileapi::FileSystemContext* context, |
78 base::PlatformFileError* error_code) { | 78 base::PlatformFileError* error_code) { |
79 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 79 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
80 DCHECK_EQ(fileapi::kFileSystemTypeDrive, url.type()); | 80 DCHECK_EQ(fileapi::kFileSystemTypeDrive, url.type()); |
81 | 81 |
82 fileapi::RemoteFileSystemProxyInterface* proxy = | 82 fileapi::RemoteFileSystemProxyInterface* proxy = |
83 mount_points_->GetRemoteFileSystemProxy(url.filesystem_id()); | 83 mount_points_->GetRemoteFileSystemProxy(url.filesystem_id()); |
84 if (!proxy) { | 84 if (!proxy) { |
85 *error_code = base::PLATFORM_FILE_ERROR_NOT_FOUND; | 85 *error_code = base::PLATFORM_FILE_ERROR_NOT_FOUND; |
86 return NULL; | 86 return NULL; |
87 } | 87 } |
88 | 88 |
89 return new chromeos::RemoteFileSystemOperation(proxy); | 89 return new chromeos::RemoteFileSystemOperation(proxy); |
90 } | 90 } |
91 | 91 |
92 } // namespace drive | 92 } // namespace drive |
OLD | NEW |