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