| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions are | |
| 6 * met: | |
| 7 * | |
| 8 * * Redistributions of source code must retain the above copyright | |
| 9 * notice, this list of conditions and the following disclaimer. | |
| 10 * * Redistributions in binary form must reproduce the above | |
| 11 * copyright notice, this list of conditions and the following disclaimer | |
| 12 * in the documentation and/or other materials provided with the | |
| 13 * distribution. | |
| 14 * * Neither the name of Google Inc. nor the names of its | |
| 15 * contributors may be used to endorse or promote products derived from | |
| 16 * this software without specific prior written permission. | |
| 17 * | |
| 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 29 */ | |
| 30 | |
| 31 #ifndef DOMFileSystem_h | |
| 32 #define DOMFileSystem_h | |
| 33 | |
| 34 #include "bindings/core/v8/ActiveScriptWrappable.h" | |
| 35 #include "bindings/core/v8/ScriptWrappable.h" | |
| 36 #include "core/dom/ActiveDOMObject.h" | |
| 37 #include "core/dom/ExecutionContext.h" | |
| 38 #include "core/dom/ExecutionContextTask.h" | |
| 39 #include "modules/ModulesExport.h" | |
| 40 #include "modules/filesystem/DOMFileSystemBase.h" | |
| 41 #include "modules/filesystem/EntriesCallback.h" | |
| 42 #include "platform/heap/Handle.h" | |
| 43 #include "public/platform/WebTraceLocation.h" | |
| 44 #include "wtf/PtrUtil.h" | |
| 45 | |
| 46 namespace blink { | |
| 47 | |
| 48 class DirectoryEntry; | |
| 49 class BlobCallback; | |
| 50 class FileEntry; | |
| 51 class FileWriterCallback; | |
| 52 | |
| 53 class MODULES_EXPORT DOMFileSystem final : public DOMFileSystemBase, | |
| 54 public ScriptWrappable, | |
| 55 public ActiveScriptWrappable, | |
| 56 public ActiveDOMObject { | |
| 57 DEFINE_WRAPPERTYPEINFO(); | |
| 58 USING_GARBAGE_COLLECTED_MIXIN(DOMFileSystem); | |
| 59 | |
| 60 public: | |
| 61 static DOMFileSystem* create(ExecutionContext*, | |
| 62 const String& name, | |
| 63 FileSystemType, | |
| 64 const KURL& rootURL); | |
| 65 | |
| 66 // Creates a new isolated file system for the given filesystemId. | |
| 67 static DOMFileSystem* createIsolatedFileSystem(ExecutionContext*, | |
| 68 const String& filesystemId); | |
| 69 | |
| 70 DirectoryEntry* root() const; | |
| 71 | |
| 72 // DOMFileSystemBase overrides. | |
| 73 void addPendingCallbacks() override; | |
| 74 void removePendingCallbacks() override; | |
| 75 void reportError(ErrorCallbackBase*, FileError::ErrorCode) override; | |
| 76 | |
| 77 static void reportError(ExecutionContext*, | |
| 78 ErrorCallbackBase*, | |
| 79 FileError::ErrorCode); | |
| 80 | |
| 81 // ScriptWrappable overrides. | |
| 82 bool hasPendingActivity() const final; | |
| 83 | |
| 84 void createWriter(const FileEntry*, FileWriterCallback*, ErrorCallbackBase*); | |
| 85 void createFile(const FileEntry*, BlobCallback*, ErrorCallbackBase*); | |
| 86 | |
| 87 // Schedule a callback. This should not cross threads (should be called on the | |
| 88 // same context thread). | |
| 89 static void scheduleCallback(ExecutionContext* executionContext, | |
| 90 std::unique_ptr<ExecutionContextTask> task) { | |
| 91 DCHECK(executionContext->isContextThread()); | |
| 92 executionContext->postTask(BLINK_FROM_HERE, std::move(task), | |
| 93 taskNameForInstrumentation()); | |
| 94 } | |
| 95 | |
| 96 DECLARE_VIRTUAL_TRACE(); | |
| 97 | |
| 98 private: | |
| 99 DOMFileSystem(ExecutionContext*, | |
| 100 const String& name, | |
| 101 FileSystemType, | |
| 102 const KURL& rootURL); | |
| 103 | |
| 104 static String taskNameForInstrumentation() { return "FileSystem"; } | |
| 105 | |
| 106 int m_numberOfPendingCallbacks; | |
| 107 Member<DirectoryEntry> m_rootEntry; | |
| 108 }; | |
| 109 | |
| 110 } // namespace blink | |
| 111 | |
| 112 #endif // DOMFileSystem_h | |
| OLD | NEW |