Commit eab6105d authored by noamsml@chromium.org's avatar noamsml@chromium.org

Stub for Privet file system

This contains a stub Privet file system, behind a flag.

BUG=332182

Review URL: https://codereview.chromium.org/120533006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@245612 0039d316-1c4b-4281-b951-d872f2087c98
parent c03b8147
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
#include "chrome/browser/guestview/guestview.h" #include "chrome/browser/guestview/guestview.h"
#include "chrome/browser/guestview/guestview_constants.h" #include "chrome/browser/guestview/guestview_constants.h"
#include "chrome/browser/guestview/webview/webview_guest.h" #include "chrome/browser/guestview/webview/webview_guest.h"
#include "chrome/browser/local_discovery/storage/privet_filesystem_backend.h"
#include "chrome/browser/media/media_capture_devices_dispatcher.h" #include "chrome/browser/media/media_capture_devices_dispatcher.h"
#include "chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.h" #include "chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.h"
#include "chrome/browser/nacl_host/nacl_browser_delegate_impl.h" #include "chrome/browser/nacl_host/nacl_browser_delegate_impl.h"
...@@ -2531,6 +2532,13 @@ void ChromeContentBrowserClient::GetAdditionalFileSystemBackends( ...@@ -2531,6 +2532,13 @@ void ChromeContentBrowserClient::GetAdditionalFileSystemBackends(
additional_backends->push_back( additional_backends->push_back(
new sync_file_system::SyncFileSystemBackend( new sync_file_system::SyncFileSystemBackend(
Profile::FromBrowserContext(browser_context))); Profile::FromBrowserContext(browser_context)));
if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnablePrivetStorage)) {
additional_backends->push_back(
new local_discovery::PrivetFileSystemBackend(
fileapi::ExternalMountPoints::GetSystemInstance()));
}
} }
#if defined(OS_POSIX) && !defined(OS_MACOSX) #if defined(OS_POSIX) && !defined(OS_MACOSX)
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h" #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h"
#include <string>
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "chrome/browser/chromeos/drive/drive.pb.h" #include "chrome/browser/chromeos/drive/drive.pb.h"
...@@ -87,7 +89,7 @@ void GetSelectedFileInfoInternal(Profile* profile, ...@@ -87,7 +89,7 @@ void GetSelectedFileInfoInternal(Profile* profile,
base::Passed(&params))); base::Passed(&params)));
return; // Remaining work is done in ContinueGetSelectedFileInfo. return; // Remaining work is done in ContinueGetSelectedFileInfo.
} }
} }
} }
params->callback.Run(params->selected_files); params->callback.Run(params->selected_files);
} }
...@@ -159,6 +161,10 @@ void VolumeInfoToVolumeMetadata( ...@@ -159,6 +161,10 @@ void VolumeInfoToVolumeMetadata(
case VOLUME_TYPE_MOUNTED_ARCHIVE_FILE: case VOLUME_TYPE_MOUNTED_ARCHIVE_FILE:
volume_metadata->volume_type = file_browser_private::VOLUME_TYPE_ARCHIVE; volume_metadata->volume_type = file_browser_private::VOLUME_TYPE_ARCHIVE;
break; break;
case VOLUME_TYPE_CLOUD_DEVICE:
volume_metadata->volume_type =
file_browser_private::VOLUME_TYPE_CLOUD_DEVICE;
break;
} }
// Fill device_type iff the volume is removable partition. // Fill device_type iff the volume is removable partition.
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/callback.h" #include "base/callback.h"
#include "base/command_line.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/singleton.h" #include "base/memory/singleton.h"
...@@ -19,7 +20,9 @@ ...@@ -19,7 +20,9 @@
#include "chrome/browser/chromeos/file_manager/path_util.h" #include "chrome/browser/chromeos/file_manager/path_util.h"
#include "chrome/browser/chromeos/file_manager/volume_manager_factory.h" #include "chrome/browser/chromeos/file_manager/volume_manager_factory.h"
#include "chrome/browser/chromeos/file_manager/volume_manager_observer.h" #include "chrome/browser/chromeos/file_manager/volume_manager_observer.h"
#include "chrome/browser/local_discovery/storage/privet_filesystem_constants.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "chromeos/dbus/cros_disks_client.h" #include "chromeos/dbus/cros_disks_client.h"
#include "chromeos/disks/disk_mount_manager.h" #include "chromeos/disks/disk_mount_manager.h"
...@@ -63,6 +66,8 @@ std::string VolumeTypeToString(VolumeType type) { ...@@ -63,6 +66,8 @@ std::string VolumeTypeToString(VolumeType type) {
return "removable"; return "removable";
case VOLUME_TYPE_MOUNTED_ARCHIVE_FILE: case VOLUME_TYPE_MOUNTED_ARCHIVE_FILE:
return "archive"; return "archive";
case VOLUME_TYPE_CLOUD_DEVICE:
return "cloud_device";
} }
NOTREACHED(); NOTREACHED();
return ""; return "";
...@@ -131,6 +136,17 @@ VolumeInfo CreateVolumeInfoFromMountPointInfo( ...@@ -131,6 +136,17 @@ VolumeInfo CreateVolumeInfoFromMountPointInfo(
return volume_info; return volume_info;
} }
VolumeInfo CreatePrivetVolumeInfo() {
VolumeInfo volume_info;
volume_info.type = VOLUME_TYPE_CLOUD_DEVICE;
volume_info.mount_path = base::FilePath(local_discovery::kPrivetFilePath);
volume_info.mount_condition = chromeos::disks::MOUNT_CONDITION_NONE;
volume_info.is_parent = true;
volume_info.is_read_only = true;
volume_info.volume_id = GenerateVolumeId(volume_info);
return volume_info;
}
} // namespace } // namespace
VolumeInfo::VolumeInfo() { VolumeInfo::VolumeInfo() {
...@@ -256,6 +272,11 @@ std::vector<VolumeInfo> VolumeManager::GetVolumeInfoList() const { ...@@ -256,6 +272,11 @@ std::vector<VolumeInfo> VolumeManager::GetVolumeInfoList() const {
disk_mount_manager_->FindDiskBySourcePath(it->second.source_path))); disk_mount_manager_->FindDiskBySourcePath(it->second.source_path)));
} }
if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnablePrivetStorage)) {
result.push_back(CreatePrivetVolumeInfo());
}
return result; return result;
} }
......
...@@ -5,14 +5,17 @@ ...@@ -5,14 +5,17 @@
#ifndef CHROME_BROWSER_CHROMEOS_FILE_MANAGER_VOLUME_MANAGER_H_ #ifndef CHROME_BROWSER_CHROMEOS_FILE_MANAGER_VOLUME_MANAGER_H_
#define CHROME_BROWSER_CHROMEOS_FILE_MANAGER_VOLUME_MANAGER_H_ #define CHROME_BROWSER_CHROMEOS_FILE_MANAGER_VOLUME_MANAGER_H_
#include <string>
#include <vector>
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/observer_list.h" #include "base/observer_list.h"
#include "base/prefs/pref_change_registrar.h" #include "base/prefs/pref_change_registrar.h"
#include "chrome/browser/chromeos/drive/drive_integration_service.h" #include "chrome/browser/chromeos/drive/drive_integration_service.h"
#include "chromeos/disks/disk_mount_manager.h"
#include "chromeos/dbus/cros_disks_client.h" #include "chromeos/dbus/cros_disks_client.h"
#include "chromeos/disks/disk_mount_manager.h"
#include "components/browser_context_keyed_service/browser_context_keyed_service.h" #include "components/browser_context_keyed_service/browser_context_keyed_service.h"
class Profile; class Profile;
...@@ -41,6 +44,7 @@ enum VolumeType { ...@@ -41,6 +44,7 @@ enum VolumeType {
VOLUME_TYPE_DOWNLOADS_DIRECTORY, VOLUME_TYPE_DOWNLOADS_DIRECTORY,
VOLUME_TYPE_REMOVABLE_DISK_PARTITION, VOLUME_TYPE_REMOVABLE_DISK_PARTITION,
VOLUME_TYPE_MOUNTED_ARCHIVE_FILE, VOLUME_TYPE_MOUNTED_ARCHIVE_FILE,
VOLUME_TYPE_CLOUD_DEVICE
}; };
struct VolumeInfo { struct VolumeInfo {
......
// 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_async_util.h"
#include "base/platform_file.h"
#include "webkit/browser/fileapi/file_system_url.h"
#include "webkit/common/blob/shareable_file_reference.h"
namespace local_discovery {
void PrivetFileSystemAsyncUtil::CreateOrOpen(
scoped_ptr<fileapi::FileSystemOperationContext> context,
const fileapi::FileSystemURL& url,
int file_flags,
const CreateOrOpenCallback& callback) {
NOTIMPLEMENTED();
callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION,
base::PassPlatformFile(NULL),
base::Closure());
}
void PrivetFileSystemAsyncUtil::EnsureFileExists(
scoped_ptr<fileapi::FileSystemOperationContext> context,
const fileapi::FileSystemURL& url,
const EnsureFileExistsCallback& callback) {
NOTIMPLEMENTED();
callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION,
false);
}
void PrivetFileSystemAsyncUtil::CreateDirectory(
scoped_ptr<fileapi::FileSystemOperationContext> context,
const fileapi::FileSystemURL& url,
bool exclusive,
bool recursive,
const StatusCallback& callback) {
NOTIMPLEMENTED();
callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION);
}
void PrivetFileSystemAsyncUtil::GetFileInfo(
scoped_ptr<fileapi::FileSystemOperationContext> context,
const fileapi::FileSystemURL& url,
const GetFileInfoCallback& callback) {
base::PlatformFileInfo file_info;
if (url.path() == base::FilePath(FILE_PATH_LITERAL("/privet"))) {
file_info.size = 20;
file_info.is_directory = true;
file_info.is_symbolic_link = false;
} else {
file_info.size = 3000;
file_info.is_directory = false;
file_info.is_symbolic_link = false;
}
callback.Run(base::PLATFORM_FILE_OK,
file_info);
}
void PrivetFileSystemAsyncUtil::ReadDirectory(
scoped_ptr<fileapi::FileSystemOperationContext> context,
const fileapi::FileSystemURL& url,
const ReadDirectoryCallback& callback) {
EntryList entry_list;
fileapi::DirectoryEntry entry("Random file",
fileapi::DirectoryEntry::FILE,
3000,
base::Time());
entry_list.push_back(entry);
callback.Run(base::PLATFORM_FILE_OK, entry_list, false);
}
void PrivetFileSystemAsyncUtil::Touch(
scoped_ptr<fileapi::FileSystemOperationContext> context,
const fileapi::FileSystemURL& url,
const base::Time& last_access_time,
const base::Time& last_modified_time,
const StatusCallback& callback) {
NOTIMPLEMENTED();
callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION);
}
void PrivetFileSystemAsyncUtil::Truncate(
scoped_ptr<fileapi::FileSystemOperationContext> context,
const fileapi::FileSystemURL& url,
int64 length,
const StatusCallback& callback) {
NOTIMPLEMENTED();
callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION);
}
void PrivetFileSystemAsyncUtil::CopyFileLocal(
scoped_ptr<fileapi::FileSystemOperationContext> context,
const fileapi::FileSystemURL& src_url,
const fileapi::FileSystemURL& dest_url,
CopyOrMoveOption option,
const CopyFileProgressCallback& progress_callback,
const StatusCallback& callback) {
NOTIMPLEMENTED();
callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION);
}
void PrivetFileSystemAsyncUtil::MoveFileLocal(
scoped_ptr<fileapi::FileSystemOperationContext> context,
const fileapi::FileSystemURL& src_url,
const fileapi::FileSystemURL& dest_url,
CopyOrMoveOption option,
const StatusCallback& callback) {
NOTIMPLEMENTED();
callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION);
}
void PrivetFileSystemAsyncUtil::CopyInForeignFile(
scoped_ptr<fileapi::FileSystemOperationContext> context,
const base::FilePath& src_file_path,
const fileapi::FileSystemURL& dest_url,
const StatusCallback& callback) {
NOTIMPLEMENTED();
callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION);
}
void PrivetFileSystemAsyncUtil::DeleteFile(
scoped_ptr<fileapi::FileSystemOperationContext> context,
const fileapi::FileSystemURL& url,
const StatusCallback& callback) {
NOTIMPLEMENTED();
callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION);
}
void PrivetFileSystemAsyncUtil::DeleteDirectory(
scoped_ptr<fileapi::FileSystemOperationContext> context,
const fileapi::FileSystemURL& url,
const StatusCallback& callback) {
NOTIMPLEMENTED();
callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION);
}
void PrivetFileSystemAsyncUtil::DeleteRecursively(
scoped_ptr<fileapi::FileSystemOperationContext> context,
const fileapi::FileSystemURL& url,
const StatusCallback& callback) {
NOTIMPLEMENTED();
callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION);
}
void PrivetFileSystemAsyncUtil::CreateSnapshotFile(
scoped_ptr<fileapi::FileSystemOperationContext> context,
const fileapi::FileSystemURL& url,
const CreateSnapshotFileCallback& callback) {
NOTIMPLEMENTED();
callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION,
base::PlatformFileInfo(),
base::FilePath(),
scoped_refptr<webkit_blob::ShareableFileReference>());
}
} // namespace local_discovery
// 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.
#ifndef CHROME_BROWSER_LOCAL_DISCOVERY_STORAGE_PRIVET_FILESYSTEM_ASYNC_UTIL_H_
#define CHROME_BROWSER_LOCAL_DISCOVERY_STORAGE_PRIVET_FILESYSTEM_ASYNC_UTIL_H_
#include "webkit/browser/fileapi/async_file_util.h"
namespace local_discovery {
class PrivetFileSystemAsyncUtil : public fileapi::AsyncFileUtil {
public:
virtual void CreateOrOpen(
scoped_ptr<fileapi::FileSystemOperationContext> context,
const fileapi::FileSystemURL& url,
int file_flags,
const CreateOrOpenCallback& callback) OVERRIDE;
virtual void EnsureFileExists(
scoped_ptr<fileapi::FileSystemOperationContext> context,
const fileapi::FileSystemURL& url,
const EnsureFileExistsCallback& callback) OVERRIDE;
virtual void CreateDirectory(
scoped_ptr<fileapi::FileSystemOperationContext> context,
const fileapi::FileSystemURL& url,
bool exclusive,
bool recursive,
const StatusCallback& callback) OVERRIDE;
virtual void GetFileInfo(
scoped_ptr<fileapi::FileSystemOperationContext> context,
const fileapi::FileSystemURL& url,
const GetFileInfoCallback& callback) OVERRIDE;
virtual void ReadDirectory(
scoped_ptr<fileapi::FileSystemOperationContext> context,
const fileapi::FileSystemURL& url,
const ReadDirectoryCallback& callback) OVERRIDE;
virtual void Touch(
scoped_ptr<fileapi::FileSystemOperationContext> context,
const fileapi::FileSystemURL& url,
const base::Time& last_access_time,
const base::Time& last_modified_time,
const StatusCallback& callback) OVERRIDE;
virtual void Truncate(
scoped_ptr<fileapi::FileSystemOperationContext> context,
const fileapi::FileSystemURL& url,
int64 length,
const StatusCallback& callback) OVERRIDE;
virtual void CopyFileLocal(
scoped_ptr<fileapi::FileSystemOperationContext> context,
const fileapi::FileSystemURL& src_url,
const fileapi::FileSystemURL& dest_url,
CopyOrMoveOption option,
const CopyFileProgressCallback& progress_callback,
const StatusCallback& callback) OVERRIDE;
virtual void MoveFileLocal(
scoped_ptr<fileapi::FileSystemOperationContext> context,
const fileapi::FileSystemURL& src_url,
const fileapi::FileSystemURL& dest_url,
CopyOrMoveOption option,
const StatusCallback& callback) OVERRIDE;
virtual void CopyInForeignFile(
scoped_ptr<fileapi::FileSystemOperationContext> context,
const base::FilePath& src_file_path,
const fileapi::FileSystemURL& dest_url,
const StatusCallback& callback) OVERRIDE;
virtual void DeleteFile(
scoped_ptr<fileapi::FileSystemOperationContext> context,
const fileapi::FileSystemURL& url,
const StatusCallback& callback) OVERRIDE;
virtual void DeleteDirectory(
scoped_ptr<fileapi::FileSystemOperationContext> context,
const fileapi::FileSystemURL& url,
const StatusCallback& callback) OVERRIDE;
virtual void DeleteRecursively(
scoped_ptr<fileapi::FileSystemOperationContext> context,
const fileapi::FileSystemURL& url,
const StatusCallback& callback) OVERRIDE;
virtual void CreateSnapshotFile(
scoped_ptr<fileapi::FileSystemOperationContext> context,
const fileapi::FileSystemURL& url,
const CreateSnapshotFileCallback& callback) OVERRIDE;
};
} // namespace local_discovery
#endif // CHROME_BROWSER_LOCAL_DISCOVERY_STORAGE_PRIVET_FILESYSTEM_ASYNC_UTIL_H_
// 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::kFileSystemTypeCloudDevice);
}
void PrivetFileSystemBackend::Initialize(fileapi::FileSystemContext* context) {
mount_points_->RegisterFileSystem(
"privet",
fileapi::kFileSystemTypeCloudDevice,
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;
}
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>();
}
} // namespace local_discovery
// 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.
#ifndef CHROME_BROWSER_LOCAL_DISCOVERY_STORAGE_PRIVET_FILESYSTEM_BACKEND_H_
#define CHROME_BROWSER_LOCAL_DISCOVERY_STORAGE_PRIVET_FILESYSTEM_BACKEND_H_
#include <string>
#include <vector>
#include "base/memory/ref_counted.h"
#include "webkit/browser/blob/file_stream_reader.h"
#include "webkit/browser/fileapi/external_mount_points.h"
#include "webkit/browser/fileapi/file_stream_writer.h"
#include "webkit/browser/fileapi/file_system_backend.h"
namespace local_discovery {
class PrivetFileSystemAsyncUtil;
class PrivetFileSystemBackend : public fileapi::FileSystemBackend {
public:
explicit PrivetFileSystemBackend(fileapi::ExternalMountPoints* mount_points);
virtual ~PrivetFileSystemBackend();
// FileSystemBackend implementation.
virtual bool CanHandleType(fileapi::FileSystemType type) const OVERRIDE;
virtual void Initialize(fileapi::FileSystemContext* context) OVERRIDE;
virtual void OpenFileSystem(
const GURL& origin_url,
fileapi::FileSystemType type,
fileapi::OpenFileSystemMode mode,
const OpenFileSystemCallback& callback) OVERRIDE;
virtual fileapi::AsyncFileUtil* GetAsyncFileUtil(
fileapi::FileSystemType type) OVERRIDE;
virtual fileapi::CopyOrMoveFileValidatorFactory*
GetCopyOrMoveFileValidatorFactory(
fileapi::FileSystemType type,
base::PlatformFileError* error_code) OVERRIDE;
virtual fileapi::FileSystemOperation* CreateFileSystemOperation(
const fileapi::FileSystemURL& url,
fileapi::FileSystemContext* context,
base::PlatformFileError* error_code) const OVERRIDE;
virtual scoped_ptr<webkit_blob::FileStreamReader> CreateFileStreamReader(
const fileapi::FileSystemURL& url,
int64 offset,
const base::Time& expected_modification_time,
fileapi::FileSystemContext* context) const OVERRIDE;
virtual scoped_ptr<fileapi::FileStreamWriter> CreateFileStreamWriter(
const fileapi::FileSystemURL& url,
int64 offset,
fileapi::FileSystemContext* context) const OVERRIDE;
virtual fileapi::FileSystemQuotaUtil* GetQuotaUtil() OVERRIDE;
private:
// User mount points.
scoped_refptr<fileapi::ExternalMountPoints> mount_points_;
scoped_ptr<PrivetFileSystemAsyncUtil> async_util_;
};
} // namespace local_discovery
#endif // CHROME_BROWSER_LOCAL_DISCOVERY_STORAGE_PRIVET_FILESYSTEM_BACKEND_H_
// 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_constants.h"
namespace local_discovery {
const base::FilePath::CharType kPrivetFilePath[] = FILE_PATH_LITERAL("/privet");
} // namespace local_discovery
// 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.
#ifndef CHROME_BROWSER_LOCAL_DISCOVERY_STORAGE_PRIVET_FILESYSTEM_CONSTANTS_H_
#define CHROME_BROWSER_LOCAL_DISCOVERY_STORAGE_PRIVET_FILESYSTEM_CONSTANTS_H_
#include "base/files/file_path.h"
namespace local_discovery {
extern const base::FilePath::CharType kPrivetFilePath[];
} // namespace local_discovery
#endif // CHROME_BROWSER_LOCAL_DISCOVERY_STORAGE_PRIVET_FILESYSTEM_CONSTANTS_H_
...@@ -266,7 +266,11 @@ volumeManagerUtil.createVolumeInfo = function(volumeMetadata, callback) { ...@@ -266,7 +266,11 @@ volumeManagerUtil.createVolumeInfo = function(volumeMetadata, callback) {
* @private * @private
*/ */
volumeManagerUtil.volumeListOrder_ = [ volumeManagerUtil.volumeListOrder_ = [
RootType.DRIVE, RootType.DOWNLOADS, RootType.ARCHIVE, RootType.REMOVABLE RootType.DRIVE,
RootType.DOWNLOADS,
RootType.ARCHIVE,
RootType.REMOVABLE,
RootType.CLOUD_DEVICE
]; ];
/** /**
...@@ -764,6 +768,9 @@ VolumeManager.prototype.getLocationInfo = function(entry) { ...@@ -764,6 +768,9 @@ VolumeManager.prototype.getLocationInfo = function(entry) {
case util.VolumeType.ARCHIVE: case util.VolumeType.ARCHIVE:
rootType = RootType.ARCHIVE; rootType = RootType.ARCHIVE;
break; break;
case util.VolumeType.CLOUD_DEVICE:
rootType = RootType.CLOUD_DEVICE;
break;
default: default:
throw new Error('Invalid volume type: ' + volumeInfo.volumeType); throw new Error('Invalid volume type: ' + volumeInfo.volumeType);
} }
......
...@@ -22,6 +22,9 @@ var RootType = Object.freeze({ ...@@ -22,6 +22,9 @@ var RootType = Object.freeze({
// Root of drive directory. // Root of drive directory.
DRIVE: 'drive', DRIVE: 'drive',
// Root for privet storage volume.
CLOUD_DEVICE: 'cloud_device',
// Root for entries that is not located under RootType.DRIVE. e.g. shared // Root for entries that is not located under RootType.DRIVE. e.g. shared
// files. // files.
DRIVE_OTHER: 'drive_other', DRIVE_OTHER: 'drive_other',
...@@ -47,6 +50,7 @@ var RootDirectory = Object.freeze({ ...@@ -47,6 +50,7 @@ var RootDirectory = Object.freeze({
ARCHIVE: '/archive', ARCHIVE: '/archive',
REMOVABLE: '/removable', REMOVABLE: '/removable',
DRIVE: '/drive', DRIVE: '/drive',
CLOUD_DEVICE: '/privet',
DRIVE_OFFLINE: '/drive_offline', // A fake root. Not the actual filesystem. DRIVE_OFFLINE: '/drive_offline', // A fake root. Not the actual filesystem.
DRIVE_SHARED_WITH_ME: '/drive_shared_with_me', // A fake root. DRIVE_SHARED_WITH_ME: '/drive_shared_with_me', // A fake root.
DRIVE_RECENT: '/drive_recent' // A fake root. DRIVE_RECENT: '/drive_recent' // A fake root.
...@@ -401,4 +405,3 @@ PathUtil.splitExtension = function(path) { ...@@ -401,4 +405,3 @@ PathUtil.splitExtension = function(path) {
var extension = dotPosition != -1 ? path.substr(dotPosition) : ''; var extension = dotPosition != -1 ? path.substr(dotPosition) : '';
return [filename, extension]; return [filename, extension];
}; };
...@@ -1261,5 +1261,6 @@ util.VolumeType = Object.freeze({ ...@@ -1261,5 +1261,6 @@ util.VolumeType = Object.freeze({
DRIVE: 'drive', DRIVE: 'drive',
DOWNLOADS: 'downloads', DOWNLOADS: 'downloads',
REMOVABLE: 'removable', REMOVABLE: 'removable',
ARCHIVE: 'archive' ARCHIVE: 'archive',
CLOUD_DEVICE: 'cloud_device'
}); });
...@@ -996,6 +996,12 @@ ...@@ -996,6 +996,12 @@
'browser/local_discovery/service_discovery_device_lister.h', 'browser/local_discovery/service_discovery_device_lister.h',
'browser/local_discovery/service_discovery_shared_client.cc', 'browser/local_discovery/service_discovery_shared_client.cc',
'browser/local_discovery/service_discovery_shared_client.h', 'browser/local_discovery/service_discovery_shared_client.h',
'browser/local_discovery/storage/privet_filesystem_async_util.cc',
'browser/local_discovery/storage/privet_filesystem_async_util.h',
'browser/local_discovery/storage/privet_filesystem_backend.cc',
'browser/local_discovery/storage/privet_filesystem_backend.h',
'browser/local_discovery/storage/privet_filesystem_constants.cc',
'browser/local_discovery/storage/privet_filesystem_constants.h',
'browser/mac/dock.h', 'browser/mac/dock.h',
'browser/mac/dock.mm', 'browser/mac/dock.mm',
'browser/mac/install_from_dmg.h', 'browser/mac/install_from_dmg.h',
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
implemented_in="chrome/browser/chromeos/extensions/file_manager/file_browser_private_api_functions.h"] implemented_in="chrome/browser/chromeos/extensions/file_manager/file_browser_private_api_functions.h"]
namespace fileBrowserPrivate { namespace fileBrowserPrivate {
// Type of the mounted volume. // Type of the mounted volume.
enum VolumeType { drive, downloads, removable, archive }; enum VolumeType { drive, downloads, removable, archive, cloud_device };
// Device type. Available if this is removable volume. // Device type. Available if this is removable volume.
enum DeviceType { usb, sd, optical, mobile, unknown }; enum DeviceType { usb, sd, optical, mobile, unknown };
......
...@@ -69,6 +69,7 @@ int FileSystemContext::GetPermissionPolicy(FileSystemType type) { ...@@ -69,6 +69,7 @@ int FileSystemContext::GetPermissionPolicy(FileSystemType type) {
case kFileSystemTypeDrive: case kFileSystemTypeDrive:
case kFileSystemTypeNativeForPlatformApp: case kFileSystemTypeNativeForPlatformApp:
case kFileSystemTypeNativeLocal: case kFileSystemTypeNativeLocal:
case kFileSystemTypeCloudDevice:
return FILE_PERMISSION_USE_FILE_PERMISSION; return FILE_PERMISSION_USE_FILE_PERMISSION;
case kFileSystemTypeRestrictedNativeLocal: case kFileSystemTypeRestrictedNativeLocal:
......
...@@ -116,6 +116,9 @@ enum FileSystemType { ...@@ -116,6 +116,9 @@ enum FileSystemType {
// given identifier in each origin. // given identifier in each origin.
kFileSystemTypePluginPrivate, kFileSystemTypePluginPrivate,
// A filesystem that is mounted via the Privet storage protocol.
kFileSystemTypeCloudDevice,
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// Marks the end of internal type enum. (This is not the actual fs type) // Marks the end of internal type enum. (This is not the actual fs type)
// New internal filesystem types must be added above this line. // New internal filesystem types must be added above this line.
......
...@@ -255,6 +255,8 @@ std::string GetFileSystemTypeString(FileSystemType type) { ...@@ -255,6 +255,8 @@ std::string GetFileSystemTypeString(FileSystemType type) {
return "TransientFile"; return "TransientFile";
case kFileSystemTypePluginPrivate: case kFileSystemTypePluginPrivate:
return "PluginPrivate"; return "PluginPrivate";
case kFileSystemTypeCloudDevice:
return "CloudDevice";
case kFileSystemInternalTypeEnumStart: case kFileSystemInternalTypeEnumStart:
case kFileSystemInternalTypeEnumEnd: case kFileSystemInternalTypeEnumEnd:
NOTREACHED(); NOTREACHED();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment