| Index: chrome/browser/local_discovery/storage/privet_filesystem_backend.cc
|
| diff --git a/chrome/browser/local_discovery/storage/privet_filesystem_backend.cc b/chrome/browser/local_discovery/storage/privet_filesystem_backend.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..06518e01cc7ac27716fc59a596eda93fbf3cfde8
|
| --- /dev/null
|
| +++ b/chrome/browser/local_discovery/storage/privet_filesystem_backend.cc
|
| @@ -0,0 +1,136 @@
|
| +// Copyright 2014 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/local_discovery/storage/privet_filesystem_backend.h"
|
| +
|
| +#include <string>
|
| +
|
| +#include "chrome/browser/local_discovery/storage/privet_filesystem_async_util.h"
|
| +#include "chrome/browser/local_discovery/storage/privet_filesystem_constants.h"
|
| +#include "webkit/browser/fileapi/file_system_operation.h"
|
| +
|
| +namespace local_discovery {
|
| +
|
| +PrivetFileSystemBackend::PrivetFileSystemBackend(
|
| + fileapi::ExternalMountPoints* mount_points)
|
| + : mount_points_(mount_points),
|
| + async_util_(new PrivetFileSystemAsyncUtil()) {
|
| +}
|
| +
|
| +PrivetFileSystemBackend::~PrivetFileSystemBackend() {
|
| +}
|
| +
|
| +bool PrivetFileSystemBackend::CanHandleType(
|
| + fileapi::FileSystemType type) const {
|
| + return (type == fileapi::kFileSystemTypePrivet);
|
| +}
|
| +
|
| +void PrivetFileSystemBackend::Initialize(fileapi::FileSystemContext* context) {
|
| + mount_points_->RegisterFileSystem(
|
| + "privet",
|
| + fileapi::kFileSystemTypePrivet,
|
| + fileapi::FileSystemMountOption(),
|
| + base::FilePath(kPrivetFilePath));
|
| +}
|
| +
|
| +void PrivetFileSystemBackend::OpenFileSystem(
|
| + const GURL& origin_url,
|
| + fileapi::FileSystemType type,
|
| + fileapi::OpenFileSystemMode mode,
|
| + const OpenFileSystemCallback& callback) {
|
| + // Copied from src/chrome/browser/chromeos/fileapi/file_system_backend.cc
|
| + // This is deprecated for non-sandboxed filesystems.
|
| + NOTREACHED();
|
| + callback.Run(GURL(), std::string(), base::PLATFORM_FILE_ERROR_SECURITY);
|
| +}
|
| +
|
| +fileapi::FileSystemQuotaUtil* PrivetFileSystemBackend::GetQuotaUtil() {
|
| + // No quota support.
|
| + return NULL;
|
| +}
|
| +
|
| +// TODO(noamsml): Any access controls
|
| +
|
| +bool PrivetFileSystemBackend::IsAccessAllowed(
|
| + const fileapi::FileSystemURL& url) const {
|
| + // TODO(noamsml): Implement (http://crbug.com/332182)
|
| + return true;
|
| +}
|
| +
|
| +void PrivetFileSystemBackend::GrantFullAccessToExtension(
|
| + const std::string& extension_id) {
|
| + // TODO(noamsml): Implement (http://crbug.com/332182)
|
| +}
|
| +
|
| +void PrivetFileSystemBackend::GrantFileAccessToExtension(
|
| + const std::string& extension_id, const base::FilePath& virtual_path) {
|
| + // TODO(noamsml): Implement (http://crbug.com/332182)
|
| +}
|
| +
|
| +void PrivetFileSystemBackend::RevokeAccessForExtension(
|
| + const std::string& extension_id) {
|
| + // TODO(noamsml): Implement (http://crbug.com/332182)
|
| +}
|
| +
|
| +// Copied from file_system_backend.cc:193
|
| +std::vector<base::FilePath>
|
| +PrivetFileSystemBackend::GetRootDirectories() const {
|
| + std::vector<fileapi::MountPoints::MountPointInfo> mount_points;
|
| + mount_points_->AddMountPointInfosTo(&mount_points);
|
| + // System mount pints
|
| +
|
| + std::vector<base::FilePath> root_dirs;
|
| + for (size_t i = 0; i < mount_points.size(); ++i)
|
| + root_dirs.push_back(mount_points[i].path);
|
| + return root_dirs;
|
| +}
|
| +
|
| +fileapi::AsyncFileUtil* PrivetFileSystemBackend::GetAsyncFileUtil(
|
| + fileapi::FileSystemType type) {
|
| + return async_util_.get();
|
| +}
|
| +
|
| +fileapi::CopyOrMoveFileValidatorFactory*
|
| +PrivetFileSystemBackend::GetCopyOrMoveFileValidatorFactory(
|
| + fileapi::FileSystemType type, base::PlatformFileError* error_code) {
|
| + DCHECK(error_code);
|
| + *error_code = base::PLATFORM_FILE_OK;
|
| + return NULL;
|
| +}
|
| +
|
| +fileapi::FileSystemOperation*
|
| +PrivetFileSystemBackend::CreateFileSystemOperation(
|
| + const fileapi::FileSystemURL& url,
|
| + fileapi::FileSystemContext* context,
|
| + base::PlatformFileError* error_code) const {
|
| + return fileapi::FileSystemOperation::Create(
|
| + url, context,
|
| + make_scoped_ptr(new fileapi::FileSystemOperationContext(context)));
|
| +}
|
| +
|
| +scoped_ptr<webkit_blob::FileStreamReader>
|
| +PrivetFileSystemBackend::CreateFileStreamReader(
|
| + const fileapi::FileSystemURL& url,
|
| + int64 offset,
|
| + const base::Time& expected_modification_time,
|
| + fileapi::FileSystemContext* context) const {
|
| + return scoped_ptr<webkit_blob::FileStreamReader>();
|
| +}
|
| +
|
| +
|
| +scoped_ptr<fileapi::FileStreamWriter>
|
| +PrivetFileSystemBackend::CreateFileStreamWriter(
|
| + const fileapi::FileSystemURL& url,
|
| + int64 offset,
|
| + fileapi::FileSystemContext* context) const {
|
| + return scoped_ptr<fileapi::FileStreamWriter>();
|
| +}
|
| +
|
| +bool PrivetFileSystemBackend::GetVirtualPath(
|
| + const base::FilePath& filesystem_path,
|
| + base::FilePath* virtual_path) {
|
| + return mount_points_->GetVirtualPath(filesystem_path, virtual_path);
|
| +}
|
| +
|
| +} // namespace local_discovery
|
|
|