Skip to content

Commit

Permalink
Revert 223635 "SyncFS: Support resolveLocalFileSystemURL on Sync..."
Browse files Browse the repository at this point in the history
> SyncFS: Support resolveLocalFileSystemURL on SyncFileSystem
> 
> window.resolveLocalFileSystemURL is originally defined only for FileSystem API,
> but it'd be nice if it works on SyncFileSystem in a similar way. For that this
> change adds new IPC messages and interfaces.
> 
> Blink side change depends on this:
> https://codereview.chromium.org/23537011/
> 
> 
> BUG=177137
> TEST=manual (Get FileSystemURL for a file on SyncFS, and then resolve it)
> TEST=unit_tests
> TEST=run_webkit_tests.sh http/tests/inspector/filesystem/\* 
> TEST=run_webkit_tests.sh http/tests/inspector/filesystem/\*
> 
> Review URL: https://chromiumcodereview.appspot.com/23856002

BUG=294502
TBR=nhiroki@chromium.org

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@224038 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
nhiroki@chromium.org committed Sep 19, 2013
1 parent fbc10be commit 3626042
Show file tree
Hide file tree
Showing 17 changed files with 52 additions and 302 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,8 @@ void LocalFileSyncContext::InitializeFileSystemContextOnIOThread(
SyncFileSystemBackend::GetBackend(file_system_context);
DCHECK(backend);
if (!backend->change_tracker()) {
// First registers the service name.
RegisterSyncableFileSystem();
// Create and initialize LocalFileChangeTracker and call back this method
// later again.
std::set<GURL>* origins_with_changes = new std::set<GURL>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ SyncFileSystemBackend::SyncFileSystemBackend(Profile* profile)
DCHECK(CalledOnUIThread());
if (profile)
profile_holder_.reset(new ProfileHolder(profile));

// Register the service name here to enable to crack an URL on SyncFileSystem
// even if SyncFileSystemService has not started yet.
RegisterSyncableFileSystem();
}

SyncFileSystemBackend::~SyncFileSystemBackend() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ SyncFileSystemServiceFactory::BuildServiceInstanceFor(
remote_file_service = mock_remote_file_service_.Pass();
} else if (CommandLine::ForCurrentProcess()->HasSwitch(
kEnableSyncFileSystemV2)) {
RegisterSyncableFileSystem();

GURL base_drive_url(
google_apis::DriveApiUrlGenerator::kBaseUrlForProduction);
GURL base_download_url(
Expand Down Expand Up @@ -113,6 +115,9 @@ SyncFileSystemServiceFactory::BuildServiceInstanceFor(
sync_engine->Initialize();
remote_file_service = sync_engine.PassAs<RemoteFileSyncService>();
} else {
// FileSystem needs to be registered before DriveFileSyncService runs
// its initialization code.
RegisterSyncableFileSystem();
remote_file_service =
DriveFileSyncService::Create(profile).PassAs<RemoteFileSyncService>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,43 @@ TEST(SyncableFileSystemUtilTest,
RevokeSyncableFileSystem();
}

TEST(SyncableFileSystemUtilTest, SerializeBeforeOpenFileSystem) {
ScopedEnableSyncFSDirectoryOperation enable_directory_operation_;
const std::string serialized = kSyncableFileSystemRootURI +
CreateNormalizedFilePath(kPath).AsUTF8Unsafe();
FileSystemURL deserialized;
base::MessageLoop message_loop;

// Setting up a full syncable filesystem environment.
CannedSyncableFileSystem file_system(GURL(kOrigin),
base::MessageLoopProxy::current().get(),
base::MessageLoopProxy::current().get());
file_system.SetUp();
scoped_refptr<LocalFileSyncContext> sync_context =
new LocalFileSyncContext(base::MessageLoopProxy::current().get(),
base::MessageLoopProxy::current().get());

// Before calling initialization we would not be able to get a valid
// deserialized URL.
EXPECT_FALSE(DeserializeSyncableFileSystemURL(serialized, &deserialized));
EXPECT_FALSE(deserialized.is_valid());

ASSERT_EQ(sync_file_system::SYNC_STATUS_OK,
file_system.MaybeInitializeFileSystemContext(sync_context.get()));

// After initialization this should be ok (even before opening the file
// system).
EXPECT_TRUE(DeserializeSyncableFileSystemURL(serialized, &deserialized));
EXPECT_TRUE(deserialized.is_valid());

// Shutting down.
file_system.TearDown();
RevokeSyncableFileSystem();
sync_context->ShutdownOnUIThread();
sync_context = NULL;
base::MessageLoop::current()->RunUntilIdle();
}

TEST(SyncableFileSystemUtilTest, SyncableFileSystemURL_IsParent) {
RegisterSyncableFileSystem();

Expand Down
40 changes: 2 additions & 38 deletions content/browser/fileapi/fileapi_message_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#include "webkit/common/blob/blob_data.h"
#include "webkit/common/blob/shareable_file_reference.h"
#include "webkit/common/fileapi/directory_entry.h"
#include "webkit/common/fileapi/file_system_info.h"
#include "webkit/common/fileapi/file_system_types.h"
#include "webkit/common/fileapi/file_system_util.h"

Expand Down Expand Up @@ -169,7 +168,6 @@ bool FileAPIMessageFilter::OnMessageReceived(
bool handled = true;
IPC_BEGIN_MESSAGE_MAP_EX(FileAPIMessageFilter, message, *message_was_ok)
IPC_MESSAGE_HANDLER(FileSystemHostMsg_Open, OnOpen)
IPC_MESSAGE_HANDLER(FileSystemHostMsg_ResolveURL, OnResolveURL)
IPC_MESSAGE_HANDLER(FileSystemHostMsg_DeleteFileSystem, OnDeleteFileSystem)
IPC_MESSAGE_HANDLER(FileSystemHostMsg_Move, OnMove)
IPC_MESSAGE_HANDLER(FileSystemHostMsg_Copy, OnCopy)
Expand Down Expand Up @@ -252,23 +250,6 @@ void FileAPIMessageFilter::OnOpen(
&FileAPIMessageFilter::DidOpenFileSystem, this, request_id));
}

void FileAPIMessageFilter::OnResolveURL(
int request_id,
const GURL& filesystem_url) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
FileSystemURL url(context_->CrackURL(filesystem_url));
if (!ValidateFileSystemURL(request_id, url))
return;
if (!security_policy_->CanReadFileSystemFile(process_id_, url)) {
Send(new FileSystemMsg_DidFail(request_id,
base::PLATFORM_FILE_ERROR_SECURITY));
return;
}

context_->ResolveURL(url, base::Bind(
&FileAPIMessageFilter::DidResolveURL, this, request_id));
}

void FileAPIMessageFilter::OnDeleteFileSystem(
int request_id,
const GURL& origin_url,
Expand Down Expand Up @@ -892,35 +873,18 @@ void FileAPIMessageFilter::DidWrite(int request_id,

void FileAPIMessageFilter::DidOpenFileSystem(int request_id,
base::PlatformFileError result,
const std::string& filesystem_name,
const std::string& name,
const GURL& root) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
if (result == base::PLATFORM_FILE_OK) {
DCHECK(root.is_valid());
Send(new FileSystemMsg_DidOpenFileSystem(
request_id, filesystem_name, root));
Send(new FileSystemMsg_DidOpenFileSystem(request_id, name, root));
} else {
Send(new FileSystemMsg_DidFail(request_id, result));
}
// For OpenFileSystem we do not create a new operation, so no unregister here.
}

void FileAPIMessageFilter::DidResolveURL(int request_id,
base::PlatformFileError result,
const fileapi::FileSystemInfo& info,
const base::FilePath& file_path,
bool is_directory) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
if (result == base::PLATFORM_FILE_OK) {
DCHECK(info.root_url.is_valid());
Send(new FileSystemMsg_DidResolveURL(
request_id, info, file_path, is_directory));
} else {
Send(new FileSystemMsg_DidFail(request_id, result));
}
// For ResolveURL we do not create a new operation, so no unregister here.
}

void FileAPIMessageFilter::DidDeleteFileSystem(
int request_id,
base::PlatformFileError result) {
Expand Down
10 changes: 1 addition & 9 deletions content/browser/fileapi/fileapi_message_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class FileSystemURL;
class FileSystemContext;
class FileSystemOperationRunner;
struct DirectoryEntry;
struct FileSystemInfo;
}

namespace net {
Expand Down Expand Up @@ -94,8 +93,6 @@ class CONTENT_EXPORT FileAPIMessageFilter : public BrowserMessageFilter {
fileapi::FileSystemType type,
int64 requested_size,
bool create);
void OnResolveURL(int request_id,
const GURL& filesystem_url);
void OnDeleteFileSystem(int request_id,
const GURL& origin_url,
fileapi::FileSystemType type);
Expand Down Expand Up @@ -204,13 +201,8 @@ class CONTENT_EXPORT FileAPIMessageFilter : public BrowserMessageFilter {
bool complete);
void DidOpenFileSystem(int request_id,
base::PlatformFileError result,
const std::string& filesystem_name,
const std::string& name,
const GURL& root);
void DidResolveURL(int request_id,
base::PlatformFileError result,
const fileapi::FileSystemInfo& info,
const base::FilePath& file_path,
bool is_directory);
void DidDeleteFileSystem(int request_id,
base::PlatformFileError result);
void DidCreateSnapshot(
Expand Down
38 changes: 0 additions & 38 deletions content/child/fileapi/file_system_dispatcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "base/process/process.h"
#include "content/child/child_thread.h"
#include "content/common/fileapi/file_system_messages.h"
#include "webkit/common/fileapi/file_system_info.h"

namespace content {

Expand All @@ -21,7 +20,6 @@ class FileSystemDispatcher::CallbackDispatcher {
typedef FileSystemDispatcher::MetadataCallback MetadataCallback;
typedef FileSystemDispatcher::ReadDirectoryCallback ReadDirectoryCallback;
typedef FileSystemDispatcher::OpenFileSystemCallback OpenFileSystemCallback;
typedef FileSystemDispatcher::ResolveURLCallback ResolveURLCallback;
typedef FileSystemDispatcher::WriteCallback WriteCallback;
typedef FileSystemDispatcher::OpenFileCallback OpenFileCallback;

Expand Down Expand Up @@ -59,13 +57,6 @@ class FileSystemDispatcher::CallbackDispatcher {
dispatcher->error_callback_ = error_callback;
return dispatcher;
}
static CallbackDispatcher* Create(const ResolveURLCallback& callback,
const StatusCallback& error_callback) {
CallbackDispatcher* dispatcher = new CallbackDispatcher;
dispatcher->resolve_callback_ = callback;
dispatcher->error_callback_ = error_callback;
return dispatcher;
}
static CallbackDispatcher* Create(const WriteCallback& callback,
const StatusCallback& error_callback) {
CallbackDispatcher* dispatcher = new CallbackDispatcher;
Expand Down Expand Up @@ -114,12 +105,6 @@ class FileSystemDispatcher::CallbackDispatcher {
filesystem_callback_.Run(name, root);
}

void DidResolveURL(const fileapi::FileSystemInfo& info,
const base::FilePath& file_path,
bool is_directory) {
resolve_callback_.Run(info, file_path, is_directory);
}

void DidWrite(int64 bytes, bool complete) {
write_callback_.Run(bytes, complete);
}
Expand All @@ -138,7 +123,6 @@ class FileSystemDispatcher::CallbackDispatcher {
CreateSnapshotFileCallback snapshot_callback_;
ReadDirectoryCallback directory_callback_;
OpenFileSystemCallback filesystem_callback_;
ResolveURLCallback resolve_callback_;
WriteCallback write_callback_;
OpenFileCallback open_callback_;

Expand Down Expand Up @@ -166,7 +150,6 @@ bool FileSystemDispatcher::OnMessageReceived(const IPC::Message& msg) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(FileSystemDispatcher, msg)
IPC_MESSAGE_HANDLER(FileSystemMsg_DidOpenFileSystem, OnDidOpenFileSystem)
IPC_MESSAGE_HANDLER(FileSystemMsg_DidResolveURL, OnDidResolveURL)
IPC_MESSAGE_HANDLER(FileSystemMsg_DidSucceed, OnDidSucceed)
IPC_MESSAGE_HANDLER(FileSystemMsg_DidReadDirectory, OnDidReadDirectory)
IPC_MESSAGE_HANDLER(FileSystemMsg_DidReadMetadata, OnDidReadMetadata)
Expand All @@ -191,16 +174,6 @@ void FileSystemDispatcher::OpenFileSystem(
request_id, origin_url, type, size, create));
}

void FileSystemDispatcher::ResolveURL(
const GURL& filesystem_url,
const ResolveURLCallback& success_callback,
const StatusCallback& error_callback) {
int request_id = dispatchers_.Add(
CallbackDispatcher::Create(success_callback, error_callback));
ChildThread::current()->Send(new FileSystemHostMsg_ResolveURL(
request_id, filesystem_url));
}

void FileSystemDispatcher::DeleteFileSystem(
const GURL& origin_url,
fileapi::FileSystemType type,
Expand Down Expand Up @@ -389,17 +362,6 @@ void FileSystemDispatcher::OnDidOpenFileSystem(int request_id,
dispatchers_.Remove(request_id);
}

void FileSystemDispatcher::OnDidResolveURL(int request_id,
const fileapi::FileSystemInfo& info,
const base::FilePath& file_path,
bool is_directory) {
DCHECK(info.root_url.is_valid());
CallbackDispatcher* dispatcher = dispatchers_.Lookup(request_id);
DCHECK(dispatcher);
dispatcher->DidResolveURL(info, file_path, is_directory);
dispatchers_.Remove(request_id);
}

void FileSystemDispatcher::OnDidSucceed(int request_id) {
CallbackDispatcher* dispatcher = dispatchers_.Lookup(request_id);
DCHECK(dispatcher);
Expand Down
12 changes: 0 additions & 12 deletions content/child/fileapi/file_system_dispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ struct PlatformFileInfo;

namespace fileapi {
struct DirectoryEntry;
struct FileSystemInfo;
}

class GURL;
Expand All @@ -49,10 +48,6 @@ class FileSystemDispatcher : public IPC::Listener {
typedef base::Callback<void(
const std::string& name,
const GURL& root)> OpenFileSystemCallback;
typedef base::Callback<void(
const fileapi::FileSystemInfo& info,
const base::FilePath& file_path,
bool is_directory)> ResolveURLCallback;
typedef base::Callback<void(
int64 bytes,
bool complete)> WriteCallback;
Expand All @@ -73,9 +68,6 @@ class FileSystemDispatcher : public IPC::Listener {
bool create,
const OpenFileSystemCallback& success_callback,
const StatusCallback& error_callback);
void ResolveURL(const GURL& filesystem_url,
const ResolveURLCallback& success_callback,
const StatusCallback& error_callback);
void DeleteFileSystem(const GURL& origin_url,
fileapi::FileSystemType type,
const StatusCallback& callback);
Expand Down Expand Up @@ -152,10 +144,6 @@ class FileSystemDispatcher : public IPC::Listener {
void OnDidOpenFileSystem(int request_id,
const std::string& name,
const GURL& root);
void OnDidResolveURL(int request_id,
const fileapi::FileSystemInfo& info,
const base::FilePath& file_path,
bool is_directory);
void OnDidSucceed(int request_id);
void OnDidReadMetadata(int request_id,
const base::PlatformFileInfo& file_info);
Expand Down
34 changes: 1 addition & 33 deletions content/child/fileapi/webfilesystem_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -154,19 +154,6 @@ void OpenFileSystemCallbackAdapter(
MakeTuple(UTF8ToUTF16(name), root));
}

void ResolveURLCallbackAdapter(
int thread_id, int callbacks_id,
WaitableCallbackResults* waitable_results,
const fileapi::FileSystemInfo& info,
const base::FilePath& file_path, bool is_directory) {
CallbackFileSystemCallbacks(
thread_id, callbacks_id, waitable_results,
&WebFileSystemCallbacks::didResolveURL,
MakeTuple(UTF8ToUTF16(info.name), info.root_url,
static_cast<WebKit::WebFileSystemType>(info.mount_type),
file_path.AsUTF16Unsafe(), is_directory));
}

void StatusCallbackAdapter(int thread_id, int callbacks_id,
WaitableCallbackResults* waitable_results,
base::PlatformFileError error) {
Expand Down Expand Up @@ -345,25 +332,6 @@ void WebFileSystemImpl::openFileSystem(
make_scoped_ptr(waitable_results));
}

void WebFileSystemImpl::resolveURL(
const WebKit::WebURL& filesystem_url,
WebFileSystemCallbacks callbacks) {
int callbacks_id = RegisterCallbacks(callbacks);
WaitableCallbackResults* waitable_results =
WaitableCallbackResults::MaybeCreate(callbacks);
CallDispatcherOnMainThread(
main_thread_loop_.get(),
&FileSystemDispatcher::ResolveURL,
MakeTuple(GURL(filesystem_url),
base::Bind(&ResolveURLCallbackAdapter,
CurrentWorkerId(), callbacks_id,
base::Unretained(waitable_results)),
base::Bind(&StatusCallbackAdapter,
CurrentWorkerId(), callbacks_id,
base::Unretained(waitable_results))),
make_scoped_ptr(waitable_results));
}

void WebFileSystemImpl::deleteFileSystem(
const WebKit::WebURL& storage_partition,
WebKit::WebFileSystemType type,
Expand Down Expand Up @@ -513,7 +481,7 @@ void WebFileSystemImpl::fileExists(
MakeTuple(GURL(path), false /* directory */,
base::Bind(&StatusCallbackAdapter,
CurrentWorkerId(), callbacks_id,
base::Unretained(waitable_results))),
base::Unretained(waitable_results))),
make_scoped_ptr(waitable_results));
}

Expand Down
3 changes: 0 additions & 3 deletions content/child/fileapi/webfilesystem_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ class WebFileSystemImpl
const WebKit::WebFileSystemType type,
bool create,
WebKit::WebFileSystemCallbacks);
virtual void resolveURL(
const WebKit::WebURL& filesystem_url,
WebKit::WebFileSystemCallbacks) OVERRIDE;
virtual void deleteFileSystem(
const WebKit::WebURL& storage_partition,
const WebKit::WebFileSystemType type,
Expand Down
Loading

0 comments on commit 3626042

Please sign in to comment.