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
3 // found in the LICENSE file.
5 #include "chrome/browser/local_discovery/storage/privet_filesystem_backend.h"
9 #include "chrome/browser/local_discovery/storage/privet_filesystem_async_util.h"
10 #include "chrome/browser/local_discovery/storage/privet_filesystem_constants.h"
11 #include "webkit/browser/fileapi/file_system_operation.h"
12 #include "webkit/browser/fileapi/file_system_url.h"
14 namespace local_discovery
{
16 PrivetFileSystemBackend::PrivetFileSystemBackend(
17 storage::ExternalMountPoints
* mount_points
,
18 content::BrowserContext
* browser_context
)
19 : mount_points_(mount_points
),
20 async_util_(new PrivetFileSystemAsyncUtil(browser_context
)) {
23 PrivetFileSystemBackend::~PrivetFileSystemBackend() {
26 bool PrivetFileSystemBackend::CanHandleType(
27 storage::FileSystemType type
) const {
28 return (type
== storage::kFileSystemTypeCloudDevice
);
31 void PrivetFileSystemBackend::Initialize(storage::FileSystemContext
* context
) {
32 mount_points_
->RegisterFileSystem("privet",
33 storage::kFileSystemTypeCloudDevice
,
34 storage::FileSystemMountOption(),
35 base::FilePath(kPrivetFilePath
));
38 void PrivetFileSystemBackend::ResolveURL(
39 const storage::FileSystemURL
& url
,
40 storage::OpenFileSystemMode mode
,
41 const OpenFileSystemCallback
& callback
) {
42 // TODO(noamsml): Provide a proper root url and a proper name.
44 storage::GetExternalFileSystemRootURIString(url
.origin(), std::string()));
45 callback
.Run(root_url
, std::string(), base::File::FILE_OK
);
48 storage::FileSystemQuotaUtil
* PrivetFileSystemBackend::GetQuotaUtil() {
53 storage::AsyncFileUtil
* PrivetFileSystemBackend::GetAsyncFileUtil(
54 storage::FileSystemType type
) {
55 return async_util_
.get();
58 storage::CopyOrMoveFileValidatorFactory
*
59 PrivetFileSystemBackend::GetCopyOrMoveFileValidatorFactory(
60 storage::FileSystemType type
,
61 base::File::Error
* error_code
) {
63 *error_code
= base::File::FILE_OK
;
67 storage::FileSystemOperation
*
68 PrivetFileSystemBackend::CreateFileSystemOperation(
69 const storage::FileSystemURL
& url
,
70 storage::FileSystemContext
* context
,
71 base::File::Error
* error_code
) const {
72 return storage::FileSystemOperation::Create(
75 make_scoped_ptr(new storage::FileSystemOperationContext(context
)));
78 bool PrivetFileSystemBackend::SupportsStreaming(
79 const storage::FileSystemURL
& url
) const {
83 bool PrivetFileSystemBackend::HasInplaceCopyImplementation(
84 storage::FileSystemType type
) const {
88 scoped_ptr
<storage::FileStreamReader
>
89 PrivetFileSystemBackend::CreateFileStreamReader(
90 const storage::FileSystemURL
& url
,
92 const base::Time
& expected_modification_time
,
93 storage::FileSystemContext
* context
) const {
94 return scoped_ptr
<storage::FileStreamReader
>();
97 scoped_ptr
<storage::FileStreamWriter
>
98 PrivetFileSystemBackend::CreateFileStreamWriter(
99 const storage::FileSystemURL
& url
,
101 storage::FileSystemContext
* context
) const {
102 return scoped_ptr
<storage::FileStreamWriter
>();
105 } // namespace local_discovery