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