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 24 matching lines...) Expand all Loading... |
35 #include "core/fileapi/FileError.h" | 35 #include "core/fileapi/FileError.h" |
36 #include "core/html/VoidCallback.h" | 36 #include "core/html/VoidCallback.h" |
37 #include "core/platform/AsyncFileSystem.h" | 37 #include "core/platform/AsyncFileSystem.h" |
38 #include "core/platform/FileMetadata.h" | 38 #include "core/platform/FileMetadata.h" |
39 #include "modules/filesystem/AsyncFileWriter.h" | 39 #include "modules/filesystem/AsyncFileWriter.h" |
40 #include "modules/filesystem/DOMFilePath.h" | 40 #include "modules/filesystem/DOMFilePath.h" |
41 #include "modules/filesystem/DOMFileSystemBase.h" | 41 #include "modules/filesystem/DOMFileSystemBase.h" |
42 #include "modules/filesystem/DirectoryEntry.h" | 42 #include "modules/filesystem/DirectoryEntry.h" |
43 #include "modules/filesystem/DirectoryReader.h" | 43 #include "modules/filesystem/DirectoryReader.h" |
44 #include "modules/filesystem/EntriesCallback.h" | 44 #include "modules/filesystem/EntriesCallback.h" |
45 #include "modules/filesystem/EntryArray.h" | 45 #include "modules/filesystem/Entry.h" |
46 #include "modules/filesystem/EntryCallback.h" | 46 #include "modules/filesystem/EntryCallback.h" |
47 #include "modules/filesystem/ErrorCallback.h" | 47 #include "modules/filesystem/ErrorCallback.h" |
48 #include "modules/filesystem/FileEntry.h" | 48 #include "modules/filesystem/FileEntry.h" |
49 #include "modules/filesystem/FileSystemCallback.h" | 49 #include "modules/filesystem/FileSystemCallback.h" |
50 #include "modules/filesystem/FileWriterBase.h" | 50 #include "modules/filesystem/FileWriterBase.h" |
51 #include "modules/filesystem/FileWriterBaseCallback.h" | 51 #include "modules/filesystem/FileWriterBaseCallback.h" |
52 #include "modules/filesystem/Metadata.h" | 52 #include "modules/filesystem/Metadata.h" |
53 #include "modules/filesystem/MetadataCallback.h" | 53 #include "modules/filesystem/MetadataCallback.h" |
54 | 54 |
55 namespace WebCore { | 55 namespace WebCore { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 PassOwnPtr<EntriesCallbacks> EntriesCallbacks::create(PassRefPtr<EntriesCallback
> successCallback, PassRefPtr<ErrorCallback> errorCallback, PassRefPtr<Directory
ReaderBase> directoryReader, const String& basePath) | 104 PassOwnPtr<EntriesCallbacks> EntriesCallbacks::create(PassRefPtr<EntriesCallback
> successCallback, PassRefPtr<ErrorCallback> errorCallback, PassRefPtr<Directory
ReaderBase> directoryReader, const String& basePath) |
105 { | 105 { |
106 return adoptPtr(new EntriesCallbacks(successCallback, errorCallback, directo
ryReader, basePath)); | 106 return adoptPtr(new EntriesCallbacks(successCallback, errorCallback, directo
ryReader, basePath)); |
107 } | 107 } |
108 | 108 |
109 EntriesCallbacks::EntriesCallbacks(PassRefPtr<EntriesCallback> successCallback,
PassRefPtr<ErrorCallback> errorCallback, PassRefPtr<DirectoryReaderBase> directo
ryReader, const String& basePath) | 109 EntriesCallbacks::EntriesCallbacks(PassRefPtr<EntriesCallback> successCallback,
PassRefPtr<ErrorCallback> errorCallback, PassRefPtr<DirectoryReaderBase> directo
ryReader, const String& basePath) |
110 : FileSystemCallbacksBase(errorCallback) | 110 : FileSystemCallbacksBase(errorCallback) |
111 , m_successCallback(successCallback) | 111 , m_successCallback(successCallback) |
112 , m_directoryReader(directoryReader) | 112 , m_directoryReader(directoryReader) |
113 , m_basePath(basePath) | 113 , m_basePath(basePath) |
114 , m_entries(EntryArray::create()) | |
115 { | 114 { |
116 ASSERT(m_directoryReader); | 115 ASSERT(m_directoryReader); |
117 } | 116 } |
118 | 117 |
119 void EntriesCallbacks::didReadDirectoryEntry(const String& name, bool isDirector
y) | 118 void EntriesCallbacks::didReadDirectoryEntry(const String& name, bool isDirector
y) |
120 { | 119 { |
121 if (isDirectory) | 120 if (isDirectory) |
122 m_entries->append(DirectoryEntry::create(m_directoryReader->filesystem()
, DOMFilePath::append(m_basePath, name))); | 121 m_entries.append(DirectoryEntry::create(m_directoryReader->filesystem(),
DOMFilePath::append(m_basePath, name))); |
123 else | 122 else |
124 m_entries->append(FileEntry::create(m_directoryReader->filesystem(), DOM
FilePath::append(m_basePath, name))); | 123 m_entries.append(FileEntry::create(m_directoryReader->filesystem(), DOMF
ilePath::append(m_basePath, name))); |
125 } | 124 } |
126 | 125 |
127 void EntriesCallbacks::didReadDirectoryEntries(bool hasMore) | 126 void EntriesCallbacks::didReadDirectoryEntries(bool hasMore) |
128 { | 127 { |
129 m_directoryReader->setHasMoreEntries(hasMore); | 128 m_directoryReader->setHasMoreEntries(hasMore); |
130 if (m_successCallback) | 129 if (m_successCallback) |
131 m_successCallback->handleEvent(m_entries.get()); | 130 m_successCallback->handleEvent(m_entries); |
132 } | 131 } |
133 | 132 |
134 // FileSystemCallbacks -------------------------------------------------------- | 133 // FileSystemCallbacks -------------------------------------------------------- |
135 | 134 |
136 PassOwnPtr<FileSystemCallbacks> FileSystemCallbacks::create(PassRefPtr<FileSyste
mCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback, ScriptExecu
tionContext* scriptExecutionContext, FileSystemType type) | 135 PassOwnPtr<FileSystemCallbacks> FileSystemCallbacks::create(PassRefPtr<FileSyste
mCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback, ScriptExecu
tionContext* scriptExecutionContext, FileSystemType type) |
137 { | 136 { |
138 return adoptPtr(new FileSystemCallbacks(successCallback, errorCallback, scri
ptExecutionContext, type)); | 137 return adoptPtr(new FileSystemCallbacks(successCallback, errorCallback, scri
ptExecutionContext, type)); |
139 } | 138 } |
140 | 139 |
141 FileSystemCallbacks::FileSystemCallbacks(PassRefPtr<FileSystemCallback> successC
allback, PassRefPtr<ErrorCallback> errorCallback, ScriptExecutionContext* contex
t, FileSystemType type) | 140 FileSystemCallbacks::FileSystemCallbacks(PassRefPtr<FileSystemCallback> successC
allback, PassRefPtr<ErrorCallback> errorCallback, ScriptExecutionContext* contex
t, FileSystemType type) |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 } | 272 } |
274 | 273 |
275 void VoidCallbacks::didSucceed() | 274 void VoidCallbacks::didSucceed() |
276 { | 275 { |
277 if (m_successCallback) | 276 if (m_successCallback) |
278 m_successCallback->handleEvent(); | 277 m_successCallback->handleEvent(); |
279 m_successCallback.clear(); | 278 m_successCallback.clear(); |
280 } | 279 } |
281 | 280 |
282 } // namespace | 281 } // namespace |
OLD | NEW |