mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Update to Chromium revision 129376.
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@579 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@ -13,6 +13,7 @@
|
||||
#include "base/time.h"
|
||||
#include "base/utf_string_conversions.h"
|
||||
#include "googleurl/src/gurl.h"
|
||||
#include "net/base/mime_util.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFileInfo.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemCallbacks.h"
|
||||
@ -21,9 +22,9 @@
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h"
|
||||
#include "webkit/blob/blob_storage_controller.h"
|
||||
#include "webkit/fileapi/mock_file_system_options.h"
|
||||
#include "webkit/glue/webkit_glue.h"
|
||||
#include "webkit/tools/test_shell/simple_file_writer.h"
|
||||
|
||||
using base::WeakPtr;
|
||||
|
||||
@ -39,19 +40,41 @@ using WebKit::WebString;
|
||||
using WebKit::WebURL;
|
||||
using WebKit::WebVector;
|
||||
|
||||
using webkit_blob::BlobData;
|
||||
using webkit_blob::BlobStorageController;
|
||||
using fileapi::FileSystemContext;
|
||||
using fileapi::FileSystemOperationInterface;
|
||||
|
||||
BrowserFileSystem::BrowserFileSystem() {
|
||||
namespace {
|
||||
MessageLoop* g_io_thread;
|
||||
webkit_blob::BlobStorageController* g_blob_storage_controller;
|
||||
|
||||
void RegisterBlob(const GURL& blob_url, const FilePath& file_path) {
|
||||
DCHECK(g_blob_storage_controller);
|
||||
|
||||
FilePath::StringType extension = file_path.Extension();
|
||||
if (!extension.empty())
|
||||
extension = extension.substr(1); // Strip leading ".".
|
||||
|
||||
// This may fail, but then we'll be just setting the empty mime type.
|
||||
std::string mime_type;
|
||||
net::GetWellKnownMimeTypeFromExtension(extension, &mime_type);
|
||||
|
||||
BlobData::Item item;
|
||||
item.SetToFile(file_path, 0, -1, base::Time());
|
||||
g_blob_storage_controller->StartBuildingBlob(blob_url);
|
||||
g_blob_storage_controller->AppendBlobDataItem(blob_url, item);
|
||||
g_blob_storage_controller->FinishBuildingBlob(blob_url, mime_type);
|
||||
}
|
||||
|
||||
BrowserFileSystem::~BrowserFileSystem() {
|
||||
} // namespace
|
||||
|
||||
BrowserFileSystem::BrowserFileSystem() {
|
||||
}
|
||||
|
||||
void BrowserFileSystem::CreateContext() {
|
||||
if (file_system_context_.get())
|
||||
return;
|
||||
|
||||
if (file_system_dir_.CreateUniqueTempDir()) {
|
||||
std::vector<std::string> additional_allowed_schemes;
|
||||
additional_allowed_schemes.push_back("file");
|
||||
@ -71,6 +94,9 @@ void BrowserFileSystem::CreateContext() {
|
||||
}
|
||||
}
|
||||
|
||||
BrowserFileSystem::~BrowserFileSystem() {
|
||||
}
|
||||
|
||||
void BrowserFileSystem::OpenFileSystem(
|
||||
WebFrame* frame, WebFileSystem::Type web_filesystem_type,
|
||||
long long, bool create, // NOLINT(runtime/int)
|
||||
@ -161,6 +187,27 @@ WebFileWriter* BrowserFileSystem::createFileWriter(
|
||||
return new BrowserFileWriter(path, client, file_system_context_.get());
|
||||
}
|
||||
|
||||
void BrowserFileSystem::createSnapshotFileAndReadMetadata(
|
||||
const WebURL& blobURL,
|
||||
const WebURL& path,
|
||||
WebFileSystemCallbacks* callbacks) {
|
||||
GetNewOperation(path)->CreateSnapshotFile(
|
||||
path, SnapshotFileHandler(blobURL, callbacks));
|
||||
}
|
||||
|
||||
// static
|
||||
void BrowserFileSystem::InitializeOnIOThread(
|
||||
webkit_blob::BlobStorageController* blob_storage_controller) {
|
||||
g_io_thread = MessageLoop::current();
|
||||
g_blob_storage_controller = blob_storage_controller;
|
||||
}
|
||||
|
||||
// static
|
||||
void BrowserFileSystem::CleanupOnIOThread() {
|
||||
g_io_thread = NULL;
|
||||
g_blob_storage_controller = NULL;
|
||||
}
|
||||
|
||||
FileSystemOperationInterface* BrowserFileSystem::GetNewOperation(
|
||||
const WebURL& url) {
|
||||
return file_system_context_->CreateFileSystemOperation(
|
||||
@ -192,6 +239,13 @@ BrowserFileSystem::OpenFileSystemHandler(WebFileSystemCallbacks* callbacks) {
|
||||
AsWeakPtr(), base::Unretained(callbacks));
|
||||
}
|
||||
|
||||
FileSystemOperationInterface::SnapshotFileCallback
|
||||
BrowserFileSystem::SnapshotFileHandler(const GURL& blob_url,
|
||||
WebFileSystemCallbacks* callbacks) {
|
||||
return base::Bind(&BrowserFileSystem::DidCreateSnapshotFile,
|
||||
AsWeakPtr(), blob_url, base::Unretained(callbacks));
|
||||
}
|
||||
|
||||
void BrowserFileSystem::DidFinish(WebFileSystemCallbacks* callbacks,
|
||||
base::PlatformFileError result) {
|
||||
if (result == base::PLATFORM_FILE_OK)
|
||||
@ -252,3 +306,19 @@ void BrowserFileSystem::DidOpenFileSystem(
|
||||
callbacks->didFail(webkit_glue::PlatformFileErrorToWebFileError(result));
|
||||
}
|
||||
}
|
||||
|
||||
void BrowserFileSystem::DidCreateSnapshotFile(
|
||||
const GURL& blob_url,
|
||||
WebFileSystemCallbacks* callbacks,
|
||||
base::PlatformFileError result,
|
||||
const base::PlatformFileInfo& info,
|
||||
const FilePath& platform_path,
|
||||
const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref) {
|
||||
DCHECK(g_io_thread);
|
||||
if (result == base::PLATFORM_FILE_OK) {
|
||||
g_io_thread->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&RegisterBlob, blob_url, platform_path));
|
||||
}
|
||||
DidGetMetadata(callbacks, result, info, platform_path);
|
||||
}
|
||||
|
Reference in New Issue
Block a user