mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
- Update to Chromium revision 69409.
- Add cefclient tests for GPU acceleration. git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@152 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@ -6,58 +6,79 @@
|
||||
#include "browser_file_writer.h"
|
||||
|
||||
#include "base/file_path.h"
|
||||
#include "base/message_loop.h"
|
||||
#include "base/message_loop_proxy.h"
|
||||
#include "base/scoped_callback_factory.h"
|
||||
#include "base/time.h"
|
||||
#include "base/utf_string_conversions.h"
|
||||
#include "googleurl/src/gurl.h"
|
||||
#include "third_party/WebKit/WebKit/chromium/public/WebFileInfo.h"
|
||||
#include "third_party/WebKit/WebKit/chromium/public/WebFileSystemCallbacks.h"
|
||||
#include "third_party/WebKit/WebKit/chromium/public/WebFileSystemEntry.h"
|
||||
#include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
|
||||
#include "third_party/WebKit/WebKit/chromium/public/WebSecurityOrigin.h"
|
||||
#include "third_party/WebKit/WebKit/chromium/public/WebVector.h"
|
||||
#include "webkit/fileapi/file_system_callback_dispatcher.h"
|
||||
#include "webkit/fileapi/file_system_path_manager.h"
|
||||
#include "webkit/fileapi/file_system_types.h"
|
||||
#include "webkit/fileapi/sandboxed_file_system_context.h"
|
||||
#include "webkit/fileapi/sandboxed_file_system_operation.h"
|
||||
#include "webkit/glue/webkit_glue.h"
|
||||
|
||||
using base::WeakPtr;
|
||||
|
||||
using WebKit::WebFileInfo;
|
||||
using WebKit::WebFileSystem;
|
||||
using WebKit::WebFileSystemCallbacks;
|
||||
using WebKit::WebFileSystemEntry;
|
||||
using WebKit::WebFileWriter;
|
||||
using WebKit::WebFileWriterClient;
|
||||
using WebKit::WebFrame;
|
||||
using WebKit::WebSecurityOrigin;
|
||||
using WebKit::WebString;
|
||||
using WebKit::WebVector;
|
||||
|
||||
using fileapi::FileSystemCallbackDispatcher;
|
||||
using fileapi::SandboxedFileSystemContext;
|
||||
using fileapi::SandboxedFileSystemOperation;
|
||||
|
||||
namespace {
|
||||
|
||||
class BrowserFileSystemCallbackDispatcher
|
||||
: public fileapi::FileSystemCallbackDispatcher {
|
||||
: public FileSystemCallbackDispatcher {
|
||||
public:
|
||||
BrowserFileSystemCallbackDispatcher(
|
||||
BrowserFileSystem* file_system,
|
||||
const WeakPtr<BrowserFileSystem>& file_system,
|
||||
WebFileSystemCallbacks* callbacks)
|
||||
: file_system_(file_system),
|
||||
callbacks_(callbacks),
|
||||
request_id_(-1) {
|
||||
callbacks_(callbacks) {
|
||||
}
|
||||
|
||||
void set_request_id(int request_id) { request_id_ = request_id; }
|
||||
~BrowserFileSystemCallbackDispatcher() {
|
||||
}
|
||||
|
||||
virtual void DidSucceed() {
|
||||
DCHECK(file_system_);
|
||||
callbacks_->didSucceed();
|
||||
file_system_->RemoveCompletedOperation(request_id_);
|
||||
}
|
||||
|
||||
virtual void DidReadMetadata(const base::PlatformFileInfo& info) {
|
||||
DCHECK(file_system_);
|
||||
WebFileInfo web_file_info;
|
||||
web_file_info.length = info.size;
|
||||
web_file_info.modificationTime = info.last_modified.ToDoubleT();
|
||||
web_file_info.type = info.is_directory ?
|
||||
WebFileInfo::TypeDirectory : WebFileInfo::TypeFile;
|
||||
callbacks_->didReadMetadata(web_file_info);
|
||||
file_system_->RemoveCompletedOperation(request_id_);
|
||||
}
|
||||
|
||||
virtual void DidReadDirectory(
|
||||
const std::vector<base::FileUtilProxy::Entry>& entries,
|
||||
bool has_more) {
|
||||
DCHECK(file_system_);
|
||||
std::vector<WebFileSystemEntry> web_entries_vector;
|
||||
for (std::vector<base::FileUtilProxy::Entry>::const_iterator it =
|
||||
entries.begin(); it != entries.end(); ++it) {
|
||||
entries.begin(); it != entries.end(); ++it) {
|
||||
WebFileSystemEntry entry;
|
||||
entry.name = webkit_glue::FilePathStringToWebString(it->name);
|
||||
entry.isDirectory = it->is_directory;
|
||||
@ -66,17 +87,22 @@ class BrowserFileSystemCallbackDispatcher
|
||||
WebVector<WebKit::WebFileSystemEntry> web_entries =
|
||||
web_entries_vector;
|
||||
callbacks_->didReadDirectory(web_entries, has_more);
|
||||
file_system_->RemoveCompletedOperation(request_id_);
|
||||
}
|
||||
|
||||
virtual void DidOpenFileSystem(const std::string&, const FilePath&) {
|
||||
NOTREACHED();
|
||||
virtual void DidOpenFileSystem(
|
||||
const std::string& name, const FilePath& path) {
|
||||
DCHECK(file_system_);
|
||||
if (path.empty())
|
||||
callbacks_->didFail(WebKit::WebFileErrorSecurity);
|
||||
else
|
||||
callbacks_->didOpenFileSystem(
|
||||
UTF8ToUTF16(name), webkit_glue::FilePathToWebString(path));
|
||||
}
|
||||
|
||||
virtual void DidFail(base::PlatformFileError error_code) {
|
||||
DCHECK(file_system_);
|
||||
callbacks_->didFail(
|
||||
webkit_glue::PlatformFileErrorToWebFileError(error_code));
|
||||
file_system_->RemoveCompletedOperation(request_id_);
|
||||
}
|
||||
|
||||
virtual void DidWrite(int64, bool) {
|
||||
@ -84,18 +110,53 @@ class BrowserFileSystemCallbackDispatcher
|
||||
}
|
||||
|
||||
private:
|
||||
BrowserFileSystem* file_system_;
|
||||
WeakPtr<BrowserFileSystem> file_system_;
|
||||
WebFileSystemCallbacks* callbacks_;
|
||||
int request_id_;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
BrowserFileSystem::BrowserFileSystem() {
|
||||
if (file_system_dir_.CreateUniqueTempDir()) {
|
||||
sandboxed_context_ = new SandboxedFileSystemContext(
|
||||
base::MessageLoopProxy::CreateForCurrentThread(),
|
||||
base::MessageLoopProxy::CreateForCurrentThread(),
|
||||
file_system_dir_.path(),
|
||||
false /* incognito */,
|
||||
true /* allow_file_access */,
|
||||
false /* unlimited_quota */);
|
||||
} else {
|
||||
LOG(WARNING) << "Failed to create a temp dir for the filesystem."
|
||||
"FileSystem feature will be disabled.";
|
||||
}
|
||||
}
|
||||
|
||||
BrowserFileSystem::~BrowserFileSystem() {
|
||||
// Drop all the operations.
|
||||
for (OperationsMap::const_iterator iter(&operations_);
|
||||
!iter.IsAtEnd(); iter.Advance())
|
||||
operations_.Remove(iter.GetCurrentKey());
|
||||
}
|
||||
|
||||
void BrowserFileSystem::OpenFileSystem(
|
||||
WebFrame* frame, WebFileSystem::Type web_filesystem_type,
|
||||
long long, bool create,
|
||||
WebFileSystemCallbacks* callbacks) {
|
||||
if (!frame || !sandboxed_context_.get()) {
|
||||
// The FileSystem temp directory was not initialized successfully.
|
||||
callbacks->didFail(WebKit::WebFileErrorSecurity);
|
||||
return;
|
||||
}
|
||||
|
||||
fileapi::FileSystemType type;
|
||||
if (web_filesystem_type == WebFileSystem::TypeTemporary)
|
||||
type = fileapi::kFileSystemTypeTemporary;
|
||||
else if (web_filesystem_type == WebFileSystem::TypePersistent)
|
||||
type = fileapi::kFileSystemTypePersistent;
|
||||
else {
|
||||
// Unknown type filesystem is requested.
|
||||
callbacks->didFail(WebKit::WebFileErrorSecurity);
|
||||
return;
|
||||
}
|
||||
|
||||
GURL origin_url(frame->securityOrigin().toString());
|
||||
GetNewOperation(callbacks)->OpenFileSystem(origin_url, type, create);
|
||||
}
|
||||
|
||||
void BrowserFileSystem::move(
|
||||
@ -177,18 +238,12 @@ WebFileWriter* BrowserFileSystem::createFileWriter(
|
||||
return new BrowserFileWriter(path, client);
|
||||
}
|
||||
|
||||
fileapi::FileSystemOperation* BrowserFileSystem::GetNewOperation(
|
||||
SandboxedFileSystemOperation* BrowserFileSystem::GetNewOperation(
|
||||
WebFileSystemCallbacks* callbacks) {
|
||||
// This pointer will be owned by |operation|.
|
||||
BrowserFileSystemCallbackDispatcher* dispatcher =
|
||||
new BrowserFileSystemCallbackDispatcher(this, callbacks);
|
||||
fileapi::FileSystemOperation* operation = new fileapi::FileSystemOperation(
|
||||
dispatcher, base::MessageLoopProxy::CreateForCurrentThread());
|
||||
int32 request_id = operations_.Add(operation);
|
||||
dispatcher->set_request_id(request_id);
|
||||
new BrowserFileSystemCallbackDispatcher(AsWeakPtr(), callbacks);
|
||||
SandboxedFileSystemOperation* operation = new SandboxedFileSystemOperation(
|
||||
dispatcher, base::MessageLoopProxy::CreateForCurrentThread(),
|
||||
sandboxed_context_.get());
|
||||
return operation;
|
||||
}
|
||||
|
||||
void BrowserFileSystem::RemoveCompletedOperation(int request_id) {
|
||||
operations_.Remove(request_id);
|
||||
}
|
||||
|
Reference in New Issue
Block a user