OLD | NEW |
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 12 matching lines...) Expand all Loading... |
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/Entry.h" |
31 | 31 |
32 #include "bindings/core/v8/ScriptState.h" | 32 #include "bindings/core/v8/ScriptState.h" |
33 #include "core/dom/ExecutionContext.h" | |
34 #include "core/fileapi/FileError.h" | 33 #include "core/fileapi/FileError.h" |
35 #include "core/frame/UseCounter.h" | 34 #include "core/frame/UseCounter.h" |
36 #include "core/html/VoidCallback.h" | 35 #include "core/html/VoidCallback.h" |
37 #include "modules/filesystem/DirectoryEntry.h" | 36 #include "modules/filesystem/DirectoryEntry.h" |
38 #include "modules/filesystem/EntryCallback.h" | 37 #include "modules/filesystem/EntryCallback.h" |
39 #include "modules/filesystem/ErrorCallback.h" | 38 #include "modules/filesystem/ErrorCallback.h" |
40 #include "modules/filesystem/FileSystemCallbacks.h" | 39 #include "modules/filesystem/FileSystemCallbacks.h" |
41 #include "modules/filesystem/MetadataCallback.h" | 40 #include "modules/filesystem/MetadataCallback.h" |
42 #include "platform/weborigin/SecurityOrigin.h" | 41 #include "platform/weborigin/SecurityOrigin.h" |
43 #include "platform/wtf/text/StringBuilder.h" | 42 #include "platform/wtf/text/StringBuilder.h" |
44 | 43 |
45 namespace blink { | 44 namespace blink { |
46 | 45 |
47 Entry::Entry(DOMFileSystemBase* file_system, const String& full_path) | 46 Entry::Entry(DOMFileSystemBase* file_system, const String& full_path) |
48 : EntryBase(file_system, full_path) {} | 47 : EntryBase(file_system, full_path) {} |
49 | 48 |
50 DOMFileSystem* Entry::filesystem(ScriptState* script_state) const { | 49 DOMFileSystem* Entry::filesystem(ScriptState* script_state) const { |
51 if (file_system_->GetType() == kFileSystemTypeIsolated) | 50 if (file_system_->GetType() == kFileSystemTypeIsolated) |
52 UseCounter::Count( | 51 UseCounter::Count( |
53 ExecutionContext::From(script_state), | 52 script_state->GetExecutionContext(), |
54 UseCounter::kEntry_Filesystem_AttributeGetter_IsolatedFileSystem); | 53 UseCounter::kEntry_Filesystem_AttributeGetter_IsolatedFileSystem); |
55 return filesystem(); | 54 return filesystem(); |
56 } | 55 } |
57 | 56 |
58 void Entry::getMetadata(ScriptState* script_state, | 57 void Entry::getMetadata(ScriptState* script_state, |
59 MetadataCallback* success_callback, | 58 MetadataCallback* success_callback, |
60 ErrorCallback* error_callback) { | 59 ErrorCallback* error_callback) { |
61 if (file_system_->GetType() == kFileSystemTypeIsolated) | 60 if (file_system_->GetType() == kFileSystemTypeIsolated) |
62 UseCounter::Count(ExecutionContext::From(script_state), | 61 UseCounter::Count(script_state->GetExecutionContext(), |
63 UseCounter::kEntry_GetMetadata_Method_IsolatedFileSystem); | 62 UseCounter::kEntry_GetMetadata_Method_IsolatedFileSystem); |
64 file_system_->GetMetadata(this, success_callback, | 63 file_system_->GetMetadata(this, success_callback, |
65 ScriptErrorCallback::Wrap(error_callback)); | 64 ScriptErrorCallback::Wrap(error_callback)); |
66 } | 65 } |
67 | 66 |
68 void Entry::moveTo(ScriptState* script_state, | 67 void Entry::moveTo(ScriptState* script_state, |
69 DirectoryEntry* parent, | 68 DirectoryEntry* parent, |
70 const String& name, | 69 const String& name, |
71 EntryCallback* success_callback, | 70 EntryCallback* success_callback, |
72 ErrorCallback* error_callback) const { | 71 ErrorCallback* error_callback) const { |
73 if (file_system_->GetType() == kFileSystemTypeIsolated) | 72 if (file_system_->GetType() == kFileSystemTypeIsolated) |
74 UseCounter::Count(ExecutionContext::From(script_state), | 73 UseCounter::Count(script_state->GetExecutionContext(), |
75 UseCounter::kEntry_MoveTo_Method_IsolatedFileSystem); | 74 UseCounter::kEntry_MoveTo_Method_IsolatedFileSystem); |
76 file_system_->Move(this, parent, name, success_callback, | 75 file_system_->Move(this, parent, name, success_callback, |
77 ScriptErrorCallback::Wrap(error_callback)); | 76 ScriptErrorCallback::Wrap(error_callback)); |
78 } | 77 } |
79 | 78 |
80 void Entry::copyTo(ScriptState* script_state, | 79 void Entry::copyTo(ScriptState* script_state, |
81 DirectoryEntry* parent, | 80 DirectoryEntry* parent, |
82 const String& name, | 81 const String& name, |
83 EntryCallback* success_callback, | 82 EntryCallback* success_callback, |
84 ErrorCallback* error_callback) const { | 83 ErrorCallback* error_callback) const { |
85 if (file_system_->GetType() == kFileSystemTypeIsolated) | 84 if (file_system_->GetType() == kFileSystemTypeIsolated) |
86 UseCounter::Count(ExecutionContext::From(script_state), | 85 UseCounter::Count(script_state->GetExecutionContext(), |
87 UseCounter::kEntry_CopyTo_Method_IsolatedFileSystem); | 86 UseCounter::kEntry_CopyTo_Method_IsolatedFileSystem); |
88 file_system_->Copy(this, parent, name, success_callback, | 87 file_system_->Copy(this, parent, name, success_callback, |
89 ScriptErrorCallback::Wrap(error_callback)); | 88 ScriptErrorCallback::Wrap(error_callback)); |
90 } | 89 } |
91 | 90 |
92 void Entry::remove(ScriptState* script_state, | 91 void Entry::remove(ScriptState* script_state, |
93 VoidCallback* success_callback, | 92 VoidCallback* success_callback, |
94 ErrorCallback* error_callback) const { | 93 ErrorCallback* error_callback) const { |
95 if (file_system_->GetType() == kFileSystemTypeIsolated) | 94 if (file_system_->GetType() == kFileSystemTypeIsolated) |
96 UseCounter::Count(ExecutionContext::From(script_state), | 95 UseCounter::Count(script_state->GetExecutionContext(), |
97 UseCounter::kEntry_Remove_Method_IsolatedFileSystem); | 96 UseCounter::kEntry_Remove_Method_IsolatedFileSystem); |
98 file_system_->Remove(this, success_callback, | 97 file_system_->Remove(this, success_callback, |
99 ScriptErrorCallback::Wrap(error_callback)); | 98 ScriptErrorCallback::Wrap(error_callback)); |
100 } | 99 } |
101 | 100 |
102 void Entry::getParent(ScriptState* script_state, | 101 void Entry::getParent(ScriptState* script_state, |
103 EntryCallback* success_callback, | 102 EntryCallback* success_callback, |
104 ErrorCallback* error_callback) const { | 103 ErrorCallback* error_callback) const { |
105 if (file_system_->GetType() == kFileSystemTypeIsolated) | 104 if (file_system_->GetType() == kFileSystemTypeIsolated) |
106 UseCounter::Count(ExecutionContext::From(script_state), | 105 UseCounter::Count(script_state->GetExecutionContext(), |
107 UseCounter::kEntry_GetParent_Method_IsolatedFileSystem); | 106 UseCounter::kEntry_GetParent_Method_IsolatedFileSystem); |
108 file_system_->GetParent(this, success_callback, | 107 file_system_->GetParent(this, success_callback, |
109 ScriptErrorCallback::Wrap(error_callback)); | 108 ScriptErrorCallback::Wrap(error_callback)); |
110 } | 109 } |
111 | 110 |
112 String Entry::toURL(ScriptState* script_state) const { | 111 String Entry::toURL(ScriptState* script_state) const { |
113 if (file_system_->GetType() == kFileSystemTypeIsolated) | 112 if (file_system_->GetType() == kFileSystemTypeIsolated) |
114 UseCounter::Count(ExecutionContext::From(script_state), | 113 UseCounter::Count(script_state->GetExecutionContext(), |
115 UseCounter::kEntry_ToURL_Method_IsolatedFileSystem); | 114 UseCounter::kEntry_ToURL_Method_IsolatedFileSystem); |
116 return static_cast<const EntryBase*>(this)->toURL(); | 115 return static_cast<const EntryBase*>(this)->toURL(); |
117 } | 116 } |
118 | 117 |
119 DEFINE_TRACE(Entry) { | 118 DEFINE_TRACE(Entry) { |
120 EntryBase::Trace(visitor); | 119 EntryBase::Trace(visitor); |
121 } | 120 } |
122 | 121 |
123 } // namespace blink | 122 } // namespace blink |
OLD | NEW |