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