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

Side by Side Diff: third_party/WebKit/Source/modules/filesystem/FileSystemEntry.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
11 * copyright notice, this list of conditions and the following disclaimer 11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the 12 * in the documentation and/or other materials provided with the
13 * distribution. 13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its 14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from 15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission. 16 * this software without specific prior written permission.
17 * 17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
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 #include "modules/filesystem/Entry.h" 30 #include "modules/filesystem/FileSystemEntry.h"
31 31
32 #include "core/dom/ExecutionContext.h" 32 #include "core/dom/ExecutionContext.h"
33 #include "core/fileapi/FileError.h" 33 #include "core/fileapi/FileError.h"
34 #include "core/frame/UseCounter.h" 34 #include "core/frame/UseCounter.h"
35 #include "core/html/VoidCallback.h" 35 #include "core/html/VoidCallback.h"
36 #include "modules/filesystem/DirectoryEntry.h"
37 #include "modules/filesystem/EntryCallback.h"
38 #include "modules/filesystem/ErrorCallback.h" 36 #include "modules/filesystem/ErrorCallback.h"
39 #include "modules/filesystem/FileSystemCallbacks.h" 37 #include "modules/filesystem/FileSystemCallbacks.h"
40 #include "modules/filesystem/MetadataCallback.h" 38 #include "modules/filesystem/FileSystemDirectoryEntry.h"
39 #include "modules/filesystem/FileSystemEntryCallback.h"
40 #include "modules/filesystem/FileSystemMetadataCallback.h"
41 #include "platform/weborigin/SecurityOrigin.h" 41 #include "platform/weborigin/SecurityOrigin.h"
42 #include "wtf/text/StringBuilder.h" 42 #include "wtf/text/StringBuilder.h"
43 43
44 namespace blink { 44 namespace blink {
45 45
46 Entry::Entry(DOMFileSystemBase* fileSystem, const String& fullPath) 46 FileSystemEntry::FileSystemEntry(FileSystemBase* fileSystem,
47 : EntryBase(fileSystem, fullPath) {} 47 const String& fullPath)
48 : FileSystemEntryBase(fileSystem, fullPath) {}
48 49
49 DOMFileSystem* Entry::filesystem(ExecutionContext* context) const { 50 FileSystem* FileSystemEntry::filesystem(ExecutionContext* context) const {
50 if (m_fileSystem->type() == FileSystemTypeIsolated) 51 if (m_fileSystem->type() == FileSystemTypeIsolated) {
51 UseCounter::count( 52 UseCounter::count(
52 context, 53 context,
53 UseCounter::Entry_Filesystem_AttributeGetter_IsolatedFileSystem); 54 UseCounter::Entry_Filesystem_AttributeGetter_IsolatedFileSystem);
55 }
54 return filesystem(); 56 return filesystem();
55 } 57 }
56 58
57 void Entry::getMetadata(ExecutionContext* context, 59 void FileSystemEntry::getMetadata(ExecutionContext* context,
58 MetadataCallback* successCallback, 60 FileSystemMetadataCallback* successCallback,
59 ErrorCallback* errorCallback) { 61 ErrorCallback* errorCallback) {
60 if (m_fileSystem->type() == FileSystemTypeIsolated) 62 if (m_fileSystem->type() == FileSystemTypeIsolated) {
61 UseCounter::count(context, 63 UseCounter::count(context,
62 UseCounter::Entry_GetMetadata_Method_IsolatedFileSystem); 64 UseCounter::Entry_GetMetadata_Method_IsolatedFileSystem);
65 }
63 m_fileSystem->getMetadata(this, successCallback, 66 m_fileSystem->getMetadata(this, successCallback,
64 ScriptErrorCallback::wrap(errorCallback)); 67 ScriptErrorCallback::wrap(errorCallback));
65 } 68 }
66 69
67 void Entry::moveTo(ExecutionContext* context, 70 void FileSystemEntry::moveTo(ExecutionContext* context,
68 DirectoryEntry* parent, 71 FileSystemDirectoryEntry* parent,
69 const String& name, 72 const String& name,
70 EntryCallback* successCallback, 73 FileSystemEntryCallback* successCallback,
71 ErrorCallback* errorCallback) const { 74 ErrorCallback* errorCallback) const {
72 if (m_fileSystem->type() == FileSystemTypeIsolated) 75 if (m_fileSystem->type() == FileSystemTypeIsolated) {
73 UseCounter::count(context, 76 UseCounter::count(context,
74 UseCounter::Entry_MoveTo_Method_IsolatedFileSystem); 77 UseCounter::Entry_MoveTo_Method_IsolatedFileSystem);
78 }
75 m_fileSystem->move(this, parent, name, successCallback, 79 m_fileSystem->move(this, parent, name, successCallback,
76 ScriptErrorCallback::wrap(errorCallback)); 80 ScriptErrorCallback::wrap(errorCallback));
77 } 81 }
78 82
79 void Entry::copyTo(ExecutionContext* context, 83 void FileSystemEntry::copyTo(ExecutionContext* context,
80 DirectoryEntry* parent, 84 FileSystemDirectoryEntry* parent,
81 const String& name, 85 const String& name,
82 EntryCallback* successCallback, 86 FileSystemEntryCallback* successCallback,
83 ErrorCallback* errorCallback) const { 87 ErrorCallback* errorCallback) const {
84 if (m_fileSystem->type() == FileSystemTypeIsolated) 88 if (m_fileSystem->type() == FileSystemTypeIsolated) {
85 UseCounter::count(context, 89 UseCounter::count(context,
86 UseCounter::Entry_CopyTo_Method_IsolatedFileSystem); 90 UseCounter::Entry_CopyTo_Method_IsolatedFileSystem);
91 }
87 m_fileSystem->copy(this, parent, name, successCallback, 92 m_fileSystem->copy(this, parent, name, successCallback,
88 ScriptErrorCallback::wrap(errorCallback)); 93 ScriptErrorCallback::wrap(errorCallback));
89 } 94 }
90 95
91 void Entry::remove(ExecutionContext* context, 96 void FileSystemEntry::remove(ExecutionContext* context,
92 VoidCallback* successCallback, 97 VoidCallback* successCallback,
93 ErrorCallback* errorCallback) const { 98 ErrorCallback* errorCallback) const {
94 if (m_fileSystem->type() == FileSystemTypeIsolated) 99 if (m_fileSystem->type() == FileSystemTypeIsolated) {
95 UseCounter::count(context, 100 UseCounter::count(context,
96 UseCounter::Entry_Remove_Method_IsolatedFileSystem); 101 UseCounter::Entry_Remove_Method_IsolatedFileSystem);
102 }
97 m_fileSystem->remove(this, successCallback, 103 m_fileSystem->remove(this, successCallback,
98 ScriptErrorCallback::wrap(errorCallback)); 104 ScriptErrorCallback::wrap(errorCallback));
99 } 105 }
100 106
101 void Entry::getParent(ExecutionContext* context, 107 void FileSystemEntry::getParent(ExecutionContext* context,
102 EntryCallback* successCallback, 108 FileSystemEntryCallback* successCallback,
103 ErrorCallback* errorCallback) const { 109 ErrorCallback* errorCallback) const {
104 if (m_fileSystem->type() == FileSystemTypeIsolated) 110 if (m_fileSystem->type() == FileSystemTypeIsolated) {
105 UseCounter::count(context, 111 UseCounter::count(context,
106 UseCounter::Entry_GetParent_Method_IsolatedFileSystem); 112 UseCounter::Entry_GetParent_Method_IsolatedFileSystem);
113 }
107 m_fileSystem->getParent(this, successCallback, 114 m_fileSystem->getParent(this, successCallback,
108 ScriptErrorCallback::wrap(errorCallback)); 115 ScriptErrorCallback::wrap(errorCallback));
109 } 116 }
110 117
111 String Entry::toURL(ExecutionContext* context) const { 118 String FileSystemEntry::toURL(ExecutionContext* context) const {
112 if (m_fileSystem->type() == FileSystemTypeIsolated) 119 if (m_fileSystem->type() == FileSystemTypeIsolated) {
113 UseCounter::count(context, 120 UseCounter::count(context,
114 UseCounter::Entry_ToURL_Method_IsolatedFileSystem); 121 UseCounter::Entry_ToURL_Method_IsolatedFileSystem);
115 return static_cast<const EntryBase*>(this)->toURL(); 122 }
123 return static_cast<const FileSystemEntryBase*>(this)->toURL();
116 } 124 }
117 125
118 DEFINE_TRACE(Entry) { 126 DEFINE_TRACE(FileSystemEntry) {
119 EntryBase::trace(visitor); 127 FileSystemEntryBase::trace(visitor);
120 } 128 }
121 129
122 } // namespace blink 130 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698