Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: third_party/WebKit/Source/modules/filesystem/FileSystemEntrySync.cpp

Issue 2297043002: Web expose FileSystemFileEntry, FileSystemDirectoryEntry and friends (Closed)
Patch Set: Rebased Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 10 matching lines...) Expand all
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 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. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "modules/filesystem/EntrySync.h" 31 #include "modules/filesystem/FileSystemEntrySync.h"
32 32
33 #include "bindings/core/v8/ExceptionMessages.h" 33 #include "bindings/core/v8/ExceptionMessages.h"
34 #include "bindings/core/v8/ExceptionState.h" 34 #include "bindings/core/v8/ExceptionState.h"
35 #include "modules/filesystem/DOMFilePath.h" 35 #include "modules/filesystem/DOMFilePath.h"
36 #include "modules/filesystem/DirectoryEntry.h" 36 #include "modules/filesystem/FileSystemDirectoryEntry.h"
37 #include "modules/filesystem/DirectoryEntrySync.h" 37 #include "modules/filesystem/FileSystemDirectoryEntrySync.h"
38 #include "modules/filesystem/FileEntrySync.h" 38 #include "modules/filesystem/FileSystemFileEntrySync.h"
39 #include "modules/filesystem/Metadata.h" 39 #include "modules/filesystem/FileSystemMetadata.h"
40 #include "modules/filesystem/SyncCallbackHelper.h" 40 #include "modules/filesystem/SyncCallbackHelper.h"
41 41
42 namespace blink { 42 namespace blink {
43 43
44 EntrySync* EntrySync::create(EntryBase* entry) { 44 FileSystemEntrySync* FileSystemEntrySync::create(FileSystemEntryBase* entry) {
45 if (entry->isFile()) 45 if (entry->isFile()) {
46 return FileEntrySync::create(entry->m_fileSystem, entry->m_fullPath); 46 return FileSystemFileEntrySync::create(entry->m_fileSystem,
47 return DirectoryEntrySync::create(entry->m_fileSystem, entry->m_fullPath); 47 entry->m_fullPath);
48 }
49 return FileSystemDirectoryEntrySync::create(entry->m_fileSystem,
50 entry->m_fullPath);
48 } 51 }
49 52
50 Metadata* EntrySync::getMetadata(ExceptionState& exceptionState) { 53 FileSystemMetadata* FileSystemEntrySync::getMetadata(
54 ExceptionState& exceptionState) {
51 MetadataSyncCallbackHelper* helper = MetadataSyncCallbackHelper::create(); 55 MetadataSyncCallbackHelper* helper = MetadataSyncCallbackHelper::create();
52 m_fileSystem->getMetadata(this, helper->getSuccessCallback(), 56 m_fileSystem->getMetadata(this, helper->getSuccessCallback(),
53 helper->getErrorCallback(), 57 helper->getErrorCallback(),
54 DOMFileSystemBase::Synchronous); 58 FileSystemBase::Synchronous);
55 return helper->getResult(exceptionState); 59 return helper->getResult(exceptionState);
56 } 60 }
57 61
58 EntrySync* EntrySync::moveTo(DirectoryEntrySync* parent, 62 FileSystemEntrySync* FileSystemEntrySync::moveTo(
59 const String& name, 63 FileSystemDirectoryEntrySync* parent,
60 ExceptionState& exceptionState) const { 64 const String& name,
65 ExceptionState& exceptionState) const {
61 EntrySyncCallbackHelper* helper = EntrySyncCallbackHelper::create(); 66 EntrySyncCallbackHelper* helper = EntrySyncCallbackHelper::create();
62 m_fileSystem->move(this, parent, name, helper->getSuccessCallback(), 67 m_fileSystem->move(this, parent, name, helper->getSuccessCallback(),
63 helper->getErrorCallback(), 68 helper->getErrorCallback(), FileSystemBase::Synchronous);
64 DOMFileSystemBase::Synchronous);
65 return helper->getResult(exceptionState); 69 return helper->getResult(exceptionState);
66 } 70 }
67 71
68 EntrySync* EntrySync::copyTo(DirectoryEntrySync* parent, 72 FileSystemEntrySync* FileSystemEntrySync::copyTo(
69 const String& name, 73 FileSystemDirectoryEntrySync* parent,
70 ExceptionState& exceptionState) const { 74 const String& name,
75 ExceptionState& exceptionState) const {
71 EntrySyncCallbackHelper* helper = EntrySyncCallbackHelper::create(); 76 EntrySyncCallbackHelper* helper = EntrySyncCallbackHelper::create();
72 m_fileSystem->copy(this, parent, name, helper->getSuccessCallback(), 77 m_fileSystem->copy(this, parent, name, helper->getSuccessCallback(),
73 helper->getErrorCallback(), 78 helper->getErrorCallback(), FileSystemBase::Synchronous);
74 DOMFileSystemBase::Synchronous);
75 return helper->getResult(exceptionState); 79 return helper->getResult(exceptionState);
76 } 80 }
77 81
78 void EntrySync::remove(ExceptionState& exceptionState) const { 82 void FileSystemEntrySync::remove(ExceptionState& exceptionState) const {
79 VoidSyncCallbackHelper* helper = VoidSyncCallbackHelper::create(); 83 VoidSyncCallbackHelper* helper = VoidSyncCallbackHelper::create();
80 m_fileSystem->remove(this, helper->getSuccessCallback(), 84 m_fileSystem->remove(this, helper->getSuccessCallback(),
81 helper->getErrorCallback(), 85 helper->getErrorCallback(), FileSystemBase::Synchronous);
82 DOMFileSystemBase::Synchronous);
83 helper->getResult(exceptionState); 86 helper->getResult(exceptionState);
84 } 87 }
85 88
86 EntrySync* EntrySync::getParent() const { 89 FileSystemEntrySync* FileSystemEntrySync::getParent() const {
87 // Sync verion of getParent doesn't throw exceptions. 90 // Sync verion of getParent doesn't throw exceptions.
88 String parentPath = DOMFilePath::getDirectory(fullPath()); 91 String parentPath = DOMFilePath::getDirectory(fullPath());
89 return DirectoryEntrySync::create(m_fileSystem, parentPath); 92 return FileSystemDirectoryEntrySync::create(m_fileSystem, parentPath);
90 } 93 }
91 94
92 EntrySync::EntrySync(DOMFileSystemBase* fileSystem, const String& fullPath) 95 FileSystemEntrySync::FileSystemEntrySync(FileSystemBase* fileSystem,
93 : EntryBase(fileSystem, fullPath) {} 96 const String& fullPath)
97 : FileSystemEntryBase(fileSystem, fullPath) {}
94 98
95 DEFINE_TRACE(EntrySync) { 99 DEFINE_TRACE(FileSystemEntrySync) {
96 EntryBase::trace(visitor); 100 FileSystemEntryBase::trace(visitor);
97 } 101 }
98 102
99 } // namespace blink 103 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698