summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbashi@chromium.org <bashi@chromium.org>2014-10-01 04:57:40 +0000
committerbashi@chromium.org <bashi@chromium.org>2014-10-01 04:57:40 +0000
commitcf303ae5d080ad16b9a1b5fdac759e759c9cf43e (patch)
tree2497c5e14ff0c231489d8f78364cd90829ac9530
parentcdfc55743f1c02953d6bfe95fea8198b6ceb6a72 (diff)
downloadchromium_src-cf303ae5d080ad16b9a1b5fdac759e759c9cf43e.zip
chromium_src-cf303ae5d080ad16b9a1b5fdac759e759c9cf43e.tar.gz
chromium_src-cf303ae5d080ad16b9a1b5fdac759e759c9cf43e.tar.bz2
Filesystem: Replace FileSystemFlags with an IDL dictionary
To remove raw Dictionary use in filesystem. Tests under http/tests/filesystem cover this change. BUG=403150 Review URL: https://codereview.chromium.org/616243003 git-svn-id: svn://svn.chromium.org/blink/trunk@183029 bbb929c8-8fbe-4397-9dbb-9b2b20218538
-rw-r--r--third_party/WebKit/Source/modules/filesystem/DOMFileSystemBase.cpp8
-rw-r--r--third_party/WebKit/Source/modules/filesystem/DirectoryEntry.cpp11
-rw-r--r--third_party/WebKit/Source/modules/filesystem/DirectoryEntry.h6
-rw-r--r--third_party/WebKit/Source/modules/filesystem/DirectoryEntry.idl4
-rw-r--r--third_party/WebKit/Source/modules/filesystem/DirectoryEntrySync.cpp11
-rw-r--r--third_party/WebKit/Source/modules/filesystem/DirectoryEntrySync.h6
-rw-r--r--third_party/WebKit/Source/modules/filesystem/DirectoryEntrySync.idl4
-rw-r--r--third_party/WebKit/Source/modules/filesystem/FileSystemFlags.h53
-rw-r--r--third_party/WebKit/Source/modules/filesystem/FileSystemFlags.idl16
-rw-r--r--third_party/WebKit/Source/modules/modules.gypi4
10 files changed, 43 insertions, 80 deletions
diff --git a/third_party/WebKit/Source/modules/filesystem/DOMFileSystemBase.cpp b/third_party/WebKit/Source/modules/filesystem/DOMFileSystemBase.cpp
index 77cfe56..398e073 100644
--- a/third_party/WebKit/Source/modules/filesystem/DOMFileSystemBase.cpp
+++ b/third_party/WebKit/Source/modules/filesystem/DOMFileSystemBase.cpp
@@ -356,8 +356,8 @@ void DOMFileSystemBase::getFile(const EntryBase* entry, const String& path, cons
OwnPtr<AsyncFileSystemCallbacks> callbacks(EntryCallbacks::create(successCallback, errorCallback, m_context, this, absolutePath, false));
callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous);
- if (flags.create)
- fileSystem()->createFile(createFileSystemURL(absolutePath), flags.exclusive, callbacks.release());
+ if (flags.createFlag())
+ fileSystem()->createFile(createFileSystemURL(absolutePath), flags.exclusive(), callbacks.release());
else
fileSystem()->fileExists(createFileSystemURL(absolutePath), callbacks.release());
}
@@ -378,8 +378,8 @@ void DOMFileSystemBase::getDirectory(const EntryBase* entry, const String& path,
OwnPtr<AsyncFileSystemCallbacks> callbacks(EntryCallbacks::create(successCallback, errorCallback, m_context, this, absolutePath, true));
callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous);
- if (flags.create)
- fileSystem()->createDirectory(createFileSystemURL(absolutePath), flags.exclusive, callbacks.release());
+ if (flags.createFlag())
+ fileSystem()->createDirectory(createFileSystemURL(absolutePath), flags.exclusive(), callbacks.release());
else
fileSystem()->directoryExists(createFileSystemURL(absolutePath), callbacks.release());
}
diff --git a/third_party/WebKit/Source/modules/filesystem/DirectoryEntry.cpp b/third_party/WebKit/Source/modules/filesystem/DirectoryEntry.cpp
index d001f50..039846a 100644
--- a/third_party/WebKit/Source/modules/filesystem/DirectoryEntry.cpp
+++ b/third_party/WebKit/Source/modules/filesystem/DirectoryEntry.cpp
@@ -36,6 +36,7 @@
#include "modules/filesystem/DirectoryReader.h"
#include "modules/filesystem/EntryCallback.h"
#include "modules/filesystem/ErrorCallback.h"
+#include "modules/filesystem/FileSystemFlags.h"
namespace blink {
@@ -49,16 +50,14 @@ DirectoryReader* DirectoryEntry::createReader()
return DirectoryReader::create(m_fileSystem, m_fullPath);
}
-void DirectoryEntry::getFile(const String& path, const Dictionary& options, EntryCallback* successCallback, ErrorCallback* errorCallback)
+void DirectoryEntry::getFile(const String& path, const FileSystemFlags& options, EntryCallback* successCallback, ErrorCallback* errorCallback)
{
- FileSystemFlags flags(options);
- m_fileSystem->getFile(this, path, flags, successCallback, errorCallback);
+ m_fileSystem->getFile(this, path, options, successCallback, errorCallback);
}
-void DirectoryEntry::getDirectory(const String& path, const Dictionary& options, EntryCallback* successCallback, ErrorCallback* errorCallback)
+void DirectoryEntry::getDirectory(const String& path, const FileSystemFlags& options, EntryCallback* successCallback, ErrorCallback* errorCallback)
{
- FileSystemFlags flags(options);
- m_fileSystem->getDirectory(this, path, flags, successCallback, errorCallback);
+ m_fileSystem->getDirectory(this, path, options, successCallback, errorCallback);
}
void DirectoryEntry::removeRecursively(VoidCallback* successCallback, ErrorCallback* errorCallback) const
diff --git a/third_party/WebKit/Source/modules/filesystem/DirectoryEntry.h b/third_party/WebKit/Source/modules/filesystem/DirectoryEntry.h
index e450704..630fca1 100644
--- a/third_party/WebKit/Source/modules/filesystem/DirectoryEntry.h
+++ b/third_party/WebKit/Source/modules/filesystem/DirectoryEntry.h
@@ -32,7 +32,6 @@
#define DirectoryEntry_h
#include "modules/filesystem/Entry.h"
-#include "modules/filesystem/FileSystemFlags.h"
#include "platform/heap/Handle.h"
#include "wtf/text/WTFString.h"
@@ -42,6 +41,7 @@ class DOMFileSystemBase;
class DirectoryReader;
class EntryCallback;
class ErrorCallback;
+class FileSystemFlags;
class VoidCallback;
class DirectoryEntry FINAL : public Entry {
@@ -54,8 +54,8 @@ public:
virtual bool isDirectory() const OVERRIDE { return true; }
DirectoryReader* createReader();
- void getFile(const String& path, const Dictionary&, EntryCallback* = nullptr, ErrorCallback* = nullptr);
- void getDirectory(const String& path, const Dictionary&, EntryCallback* = nullptr, ErrorCallback* = nullptr);
+ void getFile(const String& path, const FileSystemFlags&, EntryCallback* = nullptr, ErrorCallback* = nullptr);
+ void getDirectory(const String& path, const FileSystemFlags&, EntryCallback* = nullptr, ErrorCallback* = nullptr);
void removeRecursively(VoidCallback* successCallback = nullptr, ErrorCallback* = nullptr) const;
virtual void trace(Visitor*) OVERRIDE;
diff --git a/third_party/WebKit/Source/modules/filesystem/DirectoryEntry.idl b/third_party/WebKit/Source/modules/filesystem/DirectoryEntry.idl
index 2a0bc6c..854a088 100644
--- a/third_party/WebKit/Source/modules/filesystem/DirectoryEntry.idl
+++ b/third_party/WebKit/Source/modules/filesystem/DirectoryEntry.idl
@@ -32,7 +32,7 @@
NoInterfaceObject
] interface DirectoryEntry : Entry {
DirectoryReader createReader();
- void getFile([TreatUndefinedAs=NullString] DOMString? path, optional Dictionary options, optional EntryCallback successCallback, optional ErrorCallback errorCallback);
- void getDirectory([TreatUndefinedAs=NullString] DOMString? path, optional Dictionary options, optional EntryCallback successCallback, optional ErrorCallback errorCallback);
+ void getFile([TreatUndefinedAs=NullString] DOMString? path, optional FileSystemFlags options, optional EntryCallback successCallback, optional ErrorCallback errorCallback);
+ void getDirectory([TreatUndefinedAs=NullString] DOMString? path, optional FileSystemFlags options, optional EntryCallback successCallback, optional ErrorCallback errorCallback);
void removeRecursively(VoidCallback successCallback, optional ErrorCallback errorCallback);
};
diff --git a/third_party/WebKit/Source/modules/filesystem/DirectoryEntrySync.cpp b/third_party/WebKit/Source/modules/filesystem/DirectoryEntrySync.cpp
index f4ba044..f7a470ea 100644
--- a/third_party/WebKit/Source/modules/filesystem/DirectoryEntrySync.cpp
+++ b/third_party/WebKit/Source/modules/filesystem/DirectoryEntrySync.cpp
@@ -36,6 +36,7 @@
#include "core/dom/ExceptionCode.h"
#include "modules/filesystem/DirectoryReaderSync.h"
#include "modules/filesystem/FileEntrySync.h"
+#include "modules/filesystem/FileSystemFlags.h"
#include "modules/filesystem/SyncCallbackHelper.h"
namespace blink {
@@ -50,19 +51,17 @@ DirectoryReaderSync* DirectoryEntrySync::createReader()
return DirectoryReaderSync::create(m_fileSystem, m_fullPath);
}
-FileEntrySync* DirectoryEntrySync::getFile(const String& path, const Dictionary& options, ExceptionState& exceptionState)
+FileEntrySync* DirectoryEntrySync::getFile(const String& path, const FileSystemFlags& options, ExceptionState& exceptionState)
{
- FileSystemFlags flags(options);
EntrySyncCallbackHelper* helper = EntrySyncCallbackHelper::create();
- m_fileSystem->getFile(this, path, flags, helper->successCallback(), helper->errorCallback(), DOMFileSystemBase::Synchronous);
+ m_fileSystem->getFile(this, path, options, helper->successCallback(), helper->errorCallback(), DOMFileSystemBase::Synchronous);
return static_cast<FileEntrySync*>(helper->getResult(exceptionState));
}
-DirectoryEntrySync* DirectoryEntrySync::getDirectory(const String& path, const Dictionary& options, ExceptionState& exceptionState)
+DirectoryEntrySync* DirectoryEntrySync::getDirectory(const String& path, const FileSystemFlags& options, ExceptionState& exceptionState)
{
- FileSystemFlags flags(options);
EntrySyncCallbackHelper* helper = EntrySyncCallbackHelper::create();
- m_fileSystem->getDirectory(this, path, flags, helper->successCallback(), helper->errorCallback(), DOMFileSystemBase::Synchronous);
+ m_fileSystem->getDirectory(this, path, options, helper->successCallback(), helper->errorCallback(), DOMFileSystemBase::Synchronous);
return static_cast<DirectoryEntrySync*>(helper->getResult(exceptionState));
}
diff --git a/third_party/WebKit/Source/modules/filesystem/DirectoryEntrySync.h b/third_party/WebKit/Source/modules/filesystem/DirectoryEntrySync.h
index 274dcca..eb618cc 100644
--- a/third_party/WebKit/Source/modules/filesystem/DirectoryEntrySync.h
+++ b/third_party/WebKit/Source/modules/filesystem/DirectoryEntrySync.h
@@ -32,7 +32,6 @@
#define DirectoryEntrySync_h
#include "modules/filesystem/EntrySync.h"
-#include "modules/filesystem/FileSystemFlags.h"
#include "wtf/text/WTFString.h"
namespace blink {
@@ -40,6 +39,7 @@ namespace blink {
class DirectoryReaderSync;
class ExceptionState;
class FileEntrySync;
+class FileSystemFlags;
class DirectoryEntrySync FINAL : public EntrySync {
DEFINE_WRAPPERTYPEINFO();
@@ -51,8 +51,8 @@ public:
virtual bool isDirectory() const OVERRIDE { return true; }
DirectoryReaderSync* createReader();
- FileEntrySync* getFile(const String& path, const Dictionary&, ExceptionState&);
- DirectoryEntrySync* getDirectory(const String& path, const Dictionary&, ExceptionState&);
+ FileEntrySync* getFile(const String& path, const FileSystemFlags&, ExceptionState&);
+ DirectoryEntrySync* getDirectory(const String& path, const FileSystemFlags&, ExceptionState&);
void removeRecursively(ExceptionState&);
virtual void trace(Visitor*) OVERRIDE;
diff --git a/third_party/WebKit/Source/modules/filesystem/DirectoryEntrySync.idl b/third_party/WebKit/Source/modules/filesystem/DirectoryEntrySync.idl
index 871c306..07de469 100644
--- a/third_party/WebKit/Source/modules/filesystem/DirectoryEntrySync.idl
+++ b/third_party/WebKit/Source/modules/filesystem/DirectoryEntrySync.idl
@@ -32,7 +32,7 @@
NoInterfaceObject
] interface DirectoryEntrySync : EntrySync {
DirectoryReaderSync createReader();
- [RaisesException] FileEntrySync getFile([TreatUndefinedAs=NullString] DOMString? path, Dictionary flags);
- [RaisesException] DirectoryEntrySync getDirectory([TreatUndefinedAs=NullString] DOMString? path, Dictionary flags);
+ [RaisesException] FileEntrySync getFile([TreatUndefinedAs=NullString] DOMString? path, FileSystemFlags flags);
+ [RaisesException] DirectoryEntrySync getDirectory([TreatUndefinedAs=NullString] DOMString? path, FileSystemFlags flags);
[RaisesException] void removeRecursively();
};
diff --git a/third_party/WebKit/Source/modules/filesystem/FileSystemFlags.h b/third_party/WebKit/Source/modules/filesystem/FileSystemFlags.h
deleted file mode 100644
index 8bb95cb..0000000
--- a/third_party/WebKit/Source/modules/filesystem/FileSystemFlags.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2010 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef FileSystemFlags_h
-#define FileSystemFlags_h
-
-#include "bindings/core/v8/Dictionary.h"
-
-namespace blink {
-
-struct FileSystemFlags {
- explicit FileSystemFlags(const Dictionary& options)
- : create(false)
- , exclusive(false)
- {
- DictionaryHelper::get(options, "create", create);
- DictionaryHelper::get(options, "exclusive", exclusive);
- }
-
- bool create;
- bool exclusive;
-};
-
-}
-
-#endif // FileSystemFlags_h
diff --git a/third_party/WebKit/Source/modules/filesystem/FileSystemFlags.idl b/third_party/WebKit/Source/modules/filesystem/FileSystemFlags.idl
new file mode 100644
index 0000000..8e66941
--- /dev/null
+++ b/third_party/WebKit/Source/modules/filesystem/FileSystemFlags.idl
@@ -0,0 +1,16 @@
+// 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.
+
+// http://www.w3.org/TR/2012/WD-file-system-api-20120417/
+// In the spec, the flags don't have default values, but Blink assumes
+// that they are false when not specified.
+
+[
+ GarbageCollected
+] dictionary FileSystemFlags {
+ // [ImplementedAs] is used to workaround a name conflict; our IDL
+ // compiler generates create() static method which creates an impl instance.
+ [ImplementedAs=createFlag] boolean create = false;
+ boolean exclusive = false;
+};
diff --git a/third_party/WebKit/Source/modules/modules.gypi b/third_party/WebKit/Source/modules/modules.gypi
index 1e23adc..6a3bb5c 100644
--- a/third_party/WebKit/Source/modules/modules.gypi
+++ b/third_party/WebKit/Source/modules/modules.gypi
@@ -279,6 +279,7 @@
'modules_dictionary_idl_files': [
'encoding/TextDecodeOptions.idl',
'encoding/TextDecoderOptions.idl',
+ 'filesystem/FileSystemFlags.idl',
'indexeddb/IDBIndexParameters.idl',
'notifications/NotificationOptions.idl',
'serviceworkers/CacheQueryOptions.idl',
@@ -302,6 +303,8 @@
'<(blink_modules_output_dir)/encoding/TextDecodeOptions.h',
'<(blink_modules_output_dir)/encoding/TextDecoderOptions.cpp',
'<(blink_modules_output_dir)/encoding/TextDecoderOptions.h',
+ '<(blink_modules_output_dir)/filesystem/FileSystemFlags.cpp',
+ '<(blink_modules_output_dir)/filesystem/FileSystemFlags.h',
'<(blink_modules_output_dir)/indexeddb/IDBIndexParameters.cpp',
'<(blink_modules_output_dir)/indexeddb/IDBIndexParameters.h',
'<(blink_modules_output_dir)/notifications/NotificationOptions.cpp',
@@ -447,7 +450,6 @@
'filesystem/FileSystemCallbacks.cpp',
'filesystem/FileSystemCallbacks.h',
'filesystem/FileSystemClient.h',
- 'filesystem/FileSystemFlags.h',
'filesystem/FileWriter.cpp',
'filesystem/FileWriter.h',
'filesystem/FileWriterBase.cpp',