2012-02-17 15:51:20 +01:00
|
|
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
2010-10-15 20:37:25 +02:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
2010-10-03 22:35:06 +02:00
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
#ifndef CEF_LIBCEF_BROWSER_FILE_SYSTEM_H_
|
|
|
|
#define CEF_LIBCEF_BROWSER_FILE_SYSTEM_H_
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <vector>
|
2010-10-03 22:35:06 +02:00
|
|
|
|
|
|
|
#include "base/file_util_proxy.h"
|
|
|
|
#include "base/id_map.h"
|
2011-04-05 18:17:33 +02:00
|
|
|
#include "base/memory/weak_ptr.h"
|
2011-07-03 02:03:30 +02:00
|
|
|
#include "base/scoped_temp_dir.h"
|
2011-12-16 15:51:10 +01:00
|
|
|
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFileSystem.h"
|
2012-02-18 01:19:52 +01:00
|
|
|
#include "webkit/fileapi/file_system_context.h"
|
|
|
|
#include "webkit/fileapi/file_system_operation_interface.h"
|
2010-12-16 22:54:42 +01:00
|
|
|
#include "webkit/fileapi/file_system_types.h"
|
2010-10-03 22:35:06 +02:00
|
|
|
|
2010-12-16 22:54:42 +01:00
|
|
|
namespace WebKit {
|
|
|
|
class WebFileSystemCallbacks;
|
|
|
|
class WebFrame;
|
2011-07-03 02:03:30 +02:00
|
|
|
class WebURL;
|
2010-12-16 22:54:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace fileapi {
|
2011-02-15 19:07:24 +01:00
|
|
|
class FileSystemContext;
|
2010-12-16 22:54:42 +01:00
|
|
|
}
|
|
|
|
|
2012-04-05 00:32:24 +02:00
|
|
|
namespace webkit_blob {
|
|
|
|
class BlobStorageController;
|
|
|
|
}
|
|
|
|
|
2010-12-16 22:54:42 +01:00
|
|
|
class BrowserFileSystem
|
|
|
|
: public WebKit::WebFileSystem,
|
|
|
|
public base::SupportsWeakPtr<BrowserFileSystem> {
|
2010-10-03 22:35:06 +02:00
|
|
|
public:
|
2010-12-16 22:54:42 +01:00
|
|
|
BrowserFileSystem();
|
2010-10-03 22:35:06 +02:00
|
|
|
virtual ~BrowserFileSystem();
|
|
|
|
|
2011-12-06 11:16:51 +01:00
|
|
|
void CreateContext();
|
|
|
|
|
2010-12-16 22:54:42 +01:00
|
|
|
void OpenFileSystem(WebKit::WebFrame* frame,
|
|
|
|
WebKit::WebFileSystem::Type type,
|
2012-01-10 00:46:23 +01:00
|
|
|
long long size, // NOLINT(runtime/int)
|
2010-12-16 22:54:42 +01:00
|
|
|
bool create,
|
|
|
|
WebKit::WebFileSystemCallbacks* callbacks);
|
2010-10-03 22:35:06 +02:00
|
|
|
|
2011-04-05 18:17:33 +02:00
|
|
|
fileapi::FileSystemContext* file_system_context() {
|
|
|
|
return file_system_context_.get();
|
|
|
|
}
|
|
|
|
|
2011-09-10 21:40:03 +02:00
|
|
|
// WebKit::WebFileSystem implementation.
|
2011-07-03 02:03:30 +02:00
|
|
|
virtual void move(
|
|
|
|
const WebKit::WebURL& src_path,
|
|
|
|
const WebKit::WebURL& dest_path,
|
2011-09-10 21:40:03 +02:00
|
|
|
WebKit::WebFileSystemCallbacks*) OVERRIDE;
|
2011-07-03 02:03:30 +02:00
|
|
|
virtual void copy(
|
|
|
|
const WebKit::WebURL& src_path,
|
|
|
|
const WebKit::WebURL& dest_path,
|
2011-09-10 21:40:03 +02:00
|
|
|
WebKit::WebFileSystemCallbacks*) OVERRIDE;
|
2011-07-03 02:03:30 +02:00
|
|
|
virtual void remove(
|
|
|
|
const WebKit::WebURL& path,
|
2011-09-10 21:40:03 +02:00
|
|
|
WebKit::WebFileSystemCallbacks*) OVERRIDE;
|
2011-07-03 02:03:30 +02:00
|
|
|
virtual void removeRecursively(
|
|
|
|
const WebKit::WebURL& path,
|
2011-09-10 21:40:03 +02:00
|
|
|
WebKit::WebFileSystemCallbacks*) OVERRIDE;
|
2011-07-03 02:03:30 +02:00
|
|
|
virtual void readMetadata(
|
|
|
|
const WebKit::WebURL& path,
|
2011-09-10 21:40:03 +02:00
|
|
|
WebKit::WebFileSystemCallbacks*) OVERRIDE;
|
2011-07-03 02:03:30 +02:00
|
|
|
virtual void createFile(
|
|
|
|
const WebKit::WebURL& path,
|
|
|
|
bool exclusive,
|
2011-09-10 21:40:03 +02:00
|
|
|
WebKit::WebFileSystemCallbacks*) OVERRIDE;
|
2011-07-03 02:03:30 +02:00
|
|
|
virtual void createDirectory(
|
|
|
|
const WebKit::WebURL& path,
|
|
|
|
bool exclusive,
|
2011-09-10 21:40:03 +02:00
|
|
|
WebKit::WebFileSystemCallbacks*) OVERRIDE;
|
2011-07-03 02:03:30 +02:00
|
|
|
virtual void fileExists(
|
|
|
|
const WebKit::WebURL& path,
|
2011-09-10 21:40:03 +02:00
|
|
|
WebKit::WebFileSystemCallbacks*) OVERRIDE;
|
2011-07-03 02:03:30 +02:00
|
|
|
virtual void directoryExists(
|
|
|
|
const WebKit::WebURL& path,
|
2011-09-10 21:40:03 +02:00
|
|
|
WebKit::WebFileSystemCallbacks*) OVERRIDE;
|
2011-07-03 02:03:30 +02:00
|
|
|
virtual void readDirectory(
|
|
|
|
const WebKit::WebURL& path,
|
2011-09-10 21:40:03 +02:00
|
|
|
WebKit::WebFileSystemCallbacks*) OVERRIDE;
|
2010-10-15 20:37:25 +02:00
|
|
|
virtual WebKit::WebFileWriter* createFileWriter(
|
2011-09-10 21:40:03 +02:00
|
|
|
const WebKit::WebURL& path, WebKit::WebFileWriterClient*) OVERRIDE;
|
2012-04-05 00:32:24 +02:00
|
|
|
virtual void createSnapshotFileAndReadMetadata(
|
|
|
|
const WebKit::WebURL& blobURL,
|
|
|
|
const WebKit::WebURL& path,
|
|
|
|
WebKit::WebFileSystemCallbacks* callbacks) OVERRIDE;
|
|
|
|
|
|
|
|
static void InitializeOnIOThread(
|
|
|
|
webkit_blob::BlobStorageController* blob_storage_controller);
|
|
|
|
static void CleanupOnIOThread();
|
2010-10-03 22:35:06 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Helpers.
|
2012-02-17 15:51:20 +01:00
|
|
|
fileapi::FileSystemOperationInterface* GetNewOperation(
|
2012-02-18 01:19:52 +01:00
|
|
|
const WebKit::WebURL& path);
|
|
|
|
|
|
|
|
// Callback Handlers
|
|
|
|
fileapi::FileSystemOperationInterface::StatusCallback FinishHandler(
|
|
|
|
WebKit::WebFileSystemCallbacks* callbacks);
|
|
|
|
fileapi::FileSystemOperationInterface::GetMetadataCallback GetMetadataHandler(
|
|
|
|
WebKit::WebFileSystemCallbacks* callbacks);
|
|
|
|
fileapi::FileSystemOperationInterface::ReadDirectoryCallback
|
|
|
|
ReadDirectoryHandler(WebKit::WebFileSystemCallbacks* callbacks);
|
|
|
|
fileapi::FileSystemContext::OpenFileSystemCallback OpenFileSystemHandler(
|
|
|
|
WebKit::WebFileSystemCallbacks* callbacks);
|
2012-04-05 00:32:24 +02:00
|
|
|
fileapi::FileSystemOperationInterface::SnapshotFileCallback
|
|
|
|
SnapshotFileHandler(const GURL& blob_url,
|
|
|
|
WebKit::WebFileSystemCallbacks* callbacks);
|
2012-02-18 01:19:52 +01:00
|
|
|
void DidFinish(WebKit::WebFileSystemCallbacks* callbacks,
|
|
|
|
base::PlatformFileError result);
|
|
|
|
void DidGetMetadata(WebKit::WebFileSystemCallbacks* callbacks,
|
|
|
|
base::PlatformFileError result,
|
|
|
|
const base::PlatformFileInfo& info,
|
|
|
|
const FilePath& platform_path);
|
|
|
|
void DidReadDirectory(
|
|
|
|
WebKit::WebFileSystemCallbacks* callbacks,
|
|
|
|
base::PlatformFileError result,
|
|
|
|
const std::vector<base::FileUtilProxy::Entry>& entries,
|
|
|
|
bool has_more);
|
|
|
|
void DidOpenFileSystem(WebKit::WebFileSystemCallbacks* callbacks,
|
|
|
|
base::PlatformFileError result,
|
|
|
|
const std::string& name, const GURL& root);
|
2012-04-05 00:32:24 +02:00
|
|
|
void DidCreateSnapshotFile(
|
|
|
|
const GURL& blob_url,
|
|
|
|
WebKit::WebFileSystemCallbacks* callbacks,
|
|
|
|
base::PlatformFileError result,
|
|
|
|
const base::PlatformFileInfo& info,
|
|
|
|
const FilePath& platform_path,
|
|
|
|
const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref);
|
2010-10-03 22:35:06 +02:00
|
|
|
|
2010-12-16 22:54:42 +01:00
|
|
|
// A temporary directory for FileSystem API.
|
|
|
|
ScopedTempDir file_system_dir_;
|
|
|
|
|
2011-02-15 19:07:24 +01:00
|
|
|
scoped_refptr<fileapi::FileSystemContext> file_system_context_;
|
2010-10-03 22:35:06 +02:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(BrowserFileSystem);
|
|
|
|
};
|
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
#endif // CEF_LIBCEF_BROWSER_FILE_SYSTEM_H_
|