| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 class FileSystemCallbacksBase : public AsyncFileSystemCallbacks { | 56 class FileSystemCallbacksBase : public AsyncFileSystemCallbacks { |
| 57 public: | 57 public: |
| 58 virtual ~FileSystemCallbacksBase(); | 58 virtual ~FileSystemCallbacksBase(); |
| 59 | 59 |
| 60 // For ErrorCallback. | 60 // For ErrorCallback. |
| 61 virtual void didFail(int code) OVERRIDE FINAL; | 61 virtual void didFail(int code) OVERRIDE FINAL; |
| 62 | 62 |
| 63 // Other callback methods are implemented by each subclass. | 63 // Other callback methods are implemented by each subclass. |
| 64 | 64 |
| 65 protected: | 65 protected: |
| 66 FileSystemCallbacksBase(PassOwnPtrWillBeRawPtr<ErrorCallback>, DOMFileSystem
Base*, ExecutionContext*); | 66 FileSystemCallbacksBase(ErrorCallback*, DOMFileSystemBase*, ExecutionContext
*); |
| 67 | 67 |
| 68 bool shouldScheduleCallback() const; | 68 bool shouldScheduleCallback() const; |
| 69 | 69 |
| 70 #if !ENABLE(OILPAN) | 70 #if !ENABLE(OILPAN) |
| 71 template <typename CB, typename CBArg> | 71 template <typename CB, typename CBArg> |
| 72 void handleEventOrScheduleCallback(PassOwnPtr<CB>, RawPtr<CBArg>); | 72 void handleEventOrScheduleCallback(RawPtr<CB>, RawPtr<CBArg>); |
| 73 #endif | 73 #endif |
| 74 | 74 |
| 75 template <typename CB, typename CBArg> | 75 template <typename CB, typename CBArg> |
| 76 void handleEventOrScheduleCallback(PassOwnPtrWillBeRawPtr<CB>, CBArg*); | 76 void handleEventOrScheduleCallback(RawPtr<CB>, CBArg*); |
| 77 | 77 |
| 78 template <typename CB, typename CBArg> | 78 template <typename CB, typename CBArg> |
| 79 void handleEventOrScheduleCallback(PassOwnPtrWillBeRawPtr<CB>, PassRefPtrWil
lBeRawPtr<CBArg>); | 79 void handleEventOrScheduleCallback(RawPtr<CB>, PassRefPtrWillBeRawPtr<CBArg>
); |
| 80 | 80 |
| 81 template <typename CB> | 81 template <typename CB> |
| 82 void handleEventOrScheduleCallback(PassOwnPtrWillBeRawPtr<CB>); | 82 void handleEventOrScheduleCallback(RawPtr<CB>); |
| 83 | 83 |
| 84 OwnPtrWillBePersistent<ErrorCallback> m_errorCallback; | 84 Persistent<ErrorCallback> m_errorCallback; |
| 85 Persistent<DOMFileSystemBase> m_fileSystem; | 85 Persistent<DOMFileSystemBase> m_fileSystem; |
| 86 RefPtrWillBePersistent<ExecutionContext> m_executionContext; | 86 RefPtrWillBePersistent<ExecutionContext> m_executionContext; |
| 87 int m_asyncOperationId; | 87 int m_asyncOperationId; |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 // Subclasses ---------------------------------------------------------------- | 90 // Subclasses ---------------------------------------------------------------- |
| 91 | 91 |
| 92 class EntryCallbacks FINAL : public FileSystemCallbacksBase { | 92 class EntryCallbacks FINAL : public FileSystemCallbacksBase { |
| 93 public: | 93 public: |
| 94 static PassOwnPtr<AsyncFileSystemCallbacks> create(PassOwnPtrWillBeRawPtr<En
tryCallback>, PassOwnPtrWillBeRawPtr<ErrorCallback>, ExecutionContext*, DOMFileS
ystemBase*, const String& expectedPath, bool isDirectory); | 94 static PassOwnPtr<AsyncFileSystemCallbacks> create(EntryCallback*, ErrorCall
back*, ExecutionContext*, DOMFileSystemBase*, const String& expectedPath, bool i
sDirectory); |
| 95 virtual void didSucceed() OVERRIDE; | 95 virtual void didSucceed() OVERRIDE; |
| 96 | 96 |
| 97 private: | 97 private: |
| 98 EntryCallbacks(PassOwnPtrWillBeRawPtr<EntryCallback>, PassOwnPtrWillBeRawPtr
<ErrorCallback>, ExecutionContext*, DOMFileSystemBase*, const String& expectedPa
th, bool isDirectory); | 98 EntryCallbacks(EntryCallback*, ErrorCallback*, ExecutionContext*, DOMFileSys
temBase*, const String& expectedPath, bool isDirectory); |
| 99 OwnPtrWillBePersistent<EntryCallback> m_successCallback; | 99 Persistent<EntryCallback> m_successCallback; |
| 100 String m_expectedPath; | 100 String m_expectedPath; |
| 101 bool m_isDirectory; | 101 bool m_isDirectory; |
| 102 }; | 102 }; |
| 103 | 103 |
| 104 class EntriesCallbacks FINAL : public FileSystemCallbacksBase { | 104 class EntriesCallbacks FINAL : public FileSystemCallbacksBase { |
| 105 public: | 105 public: |
| 106 static PassOwnPtr<AsyncFileSystemCallbacks> create(PassOwnPtrWillBeRawPtr<En
triesCallback>, PassOwnPtrWillBeRawPtr<ErrorCallback>, ExecutionContext*, Direct
oryReaderBase*, const String& basePath); | 106 static PassOwnPtr<AsyncFileSystemCallbacks> create(EntriesCallback*, ErrorCa
llback*, ExecutionContext*, DirectoryReaderBase*, const String& basePath); |
| 107 virtual void didReadDirectoryEntry(const String& name, bool isDirectory) OVE
RRIDE; | 107 virtual void didReadDirectoryEntry(const String& name, bool isDirectory) OVE
RRIDE; |
| 108 virtual void didReadDirectoryEntries(bool hasMore) OVERRIDE; | 108 virtual void didReadDirectoryEntries(bool hasMore) OVERRIDE; |
| 109 | 109 |
| 110 private: | 110 private: |
| 111 EntriesCallbacks(PassOwnPtrWillBeRawPtr<EntriesCallback>, PassOwnPtrWillBeRa
wPtr<ErrorCallback>, ExecutionContext*, DirectoryReaderBase*, const String& base
Path); | 111 EntriesCallbacks(EntriesCallback*, ErrorCallback*, ExecutionContext*, Direct
oryReaderBase*, const String& basePath); |
| 112 OwnPtrWillBePersistent<EntriesCallback> m_successCallback; | 112 Persistent<EntriesCallback> m_successCallback; |
| 113 Persistent<DirectoryReaderBase> m_directoryReader; | 113 Persistent<DirectoryReaderBase> m_directoryReader; |
| 114 String m_basePath; | 114 String m_basePath; |
| 115 PersistentHeapVector<Member<Entry> > m_entries; | 115 PersistentHeapVector<Member<Entry> > m_entries; |
| 116 }; | 116 }; |
| 117 | 117 |
| 118 class FileSystemCallbacks FINAL : public FileSystemCallbacksBase { | 118 class FileSystemCallbacks FINAL : public FileSystemCallbacksBase { |
| 119 public: | 119 public: |
| 120 static PassOwnPtr<AsyncFileSystemCallbacks> create(PassOwnPtrWillBeRawPtr<Fi
leSystemCallback>, PassOwnPtrWillBeRawPtr<ErrorCallback>, ExecutionContext*, Fil
eSystemType); | 120 static PassOwnPtr<AsyncFileSystemCallbacks> create(FileSystemCallback*, Erro
rCallback*, ExecutionContext*, FileSystemType); |
| 121 virtual void didOpenFileSystem(const String& name, const KURL& rootURL) OVER
RIDE; | 121 virtual void didOpenFileSystem(const String& name, const KURL& rootURL) OVER
RIDE; |
| 122 | 122 |
| 123 private: | 123 private: |
| 124 FileSystemCallbacks(PassOwnPtrWillBeRawPtr<FileSystemCallback>, PassOwnPtrWi
llBeRawPtr<ErrorCallback>, ExecutionContext*, FileSystemType); | 124 FileSystemCallbacks(FileSystemCallback*, ErrorCallback*, ExecutionContext*,
FileSystemType); |
| 125 OwnPtrWillBePersistent<FileSystemCallback> m_successCallback; | 125 Persistent<FileSystemCallback> m_successCallback; |
| 126 FileSystemType m_type; | 126 FileSystemType m_type; |
| 127 }; | 127 }; |
| 128 | 128 |
| 129 class ResolveURICallbacks FINAL : public FileSystemCallbacksBase { | 129 class ResolveURICallbacks FINAL : public FileSystemCallbacksBase { |
| 130 public: | 130 public: |
| 131 static PassOwnPtr<AsyncFileSystemCallbacks> create(PassOwnPtrWillBeRawPtr<En
tryCallback>, PassOwnPtrWillBeRawPtr<ErrorCallback>, ExecutionContext*); | 131 static PassOwnPtr<AsyncFileSystemCallbacks> create(EntryCallback*, ErrorCall
back*, ExecutionContext*); |
| 132 virtual void didResolveURL(const String& name, const KURL& rootURL, FileSyst
emType, const String& filePath, bool isDirectry) OVERRIDE; | 132 virtual void didResolveURL(const String& name, const KURL& rootURL, FileSyst
emType, const String& filePath, bool isDirectry) OVERRIDE; |
| 133 | 133 |
| 134 private: | 134 private: |
| 135 ResolveURICallbacks(PassOwnPtrWillBeRawPtr<EntryCallback>, PassOwnPtrWillBeR
awPtr<ErrorCallback>, ExecutionContext*); | 135 ResolveURICallbacks(EntryCallback*, ErrorCallback*, ExecutionContext*); |
| 136 OwnPtrWillBePersistent<EntryCallback> m_successCallback; | 136 Persistent<EntryCallback> m_successCallback; |
| 137 }; | 137 }; |
| 138 | 138 |
| 139 class MetadataCallbacks FINAL : public FileSystemCallbacksBase { | 139 class MetadataCallbacks FINAL : public FileSystemCallbacksBase { |
| 140 public: | 140 public: |
| 141 static PassOwnPtr<AsyncFileSystemCallbacks> create(PassOwnPtrWillBeRawPtr<Me
tadataCallback>, PassOwnPtrWillBeRawPtr<ErrorCallback>, ExecutionContext*, DOMFi
leSystemBase*); | 141 static PassOwnPtr<AsyncFileSystemCallbacks> create(MetadataCallback*, ErrorC
allback*, ExecutionContext*, DOMFileSystemBase*); |
| 142 virtual void didReadMetadata(const FileMetadata&) OVERRIDE; | 142 virtual void didReadMetadata(const FileMetadata&) OVERRIDE; |
| 143 | 143 |
| 144 private: | 144 private: |
| 145 MetadataCallbacks(PassOwnPtrWillBeRawPtr<MetadataCallback>, PassOwnPtrWillBe
RawPtr<ErrorCallback>, ExecutionContext*, DOMFileSystemBase*); | 145 MetadataCallbacks(MetadataCallback*, ErrorCallback*, ExecutionContext*, DOMF
ileSystemBase*); |
| 146 OwnPtrWillBePersistent<MetadataCallback> m_successCallback; | 146 Persistent<MetadataCallback> m_successCallback; |
| 147 }; | 147 }; |
| 148 | 148 |
| 149 class FileWriterBaseCallbacks FINAL : public FileSystemCallbacksBase { | 149 class FileWriterBaseCallbacks FINAL : public FileSystemCallbacksBase { |
| 150 public: | 150 public: |
| 151 static PassOwnPtr<AsyncFileSystemCallbacks> create(PassRefPtrWillBeRawPtr<Fi
leWriterBase>, PassOwnPtrWillBeRawPtr<FileWriterBaseCallback>, PassOwnPtrWillBeR
awPtr<ErrorCallback>, ExecutionContext*); | 151 static PassOwnPtr<AsyncFileSystemCallbacks> create(PassRefPtrWillBeRawPtr<Fi
leWriterBase>, FileWriterBaseCallback*, ErrorCallback*, ExecutionContext*); |
| 152 virtual void didCreateFileWriter(PassOwnPtr<WebFileWriter>, long long length
) OVERRIDE; | 152 virtual void didCreateFileWriter(PassOwnPtr<WebFileWriter>, long long length
) OVERRIDE; |
| 153 | 153 |
| 154 private: | 154 private: |
| 155 FileWriterBaseCallbacks(PassRefPtrWillBeRawPtr<FileWriterBase>, PassOwnPtrWi
llBeRawPtr<FileWriterBaseCallback>, PassOwnPtrWillBeRawPtr<ErrorCallback>, Execu
tionContext*); | 155 FileWriterBaseCallbacks(PassRefPtrWillBeRawPtr<FileWriterBase>, FileWriterBa
seCallback*, ErrorCallback*, ExecutionContext*); |
| 156 Persistent<FileWriterBase> m_fileWriter; | 156 Persistent<FileWriterBase> m_fileWriter; |
| 157 OwnPtrWillBePersistent<FileWriterBaseCallback> m_successCallback; | 157 Persistent<FileWriterBaseCallback> m_successCallback; |
| 158 }; | 158 }; |
| 159 | 159 |
| 160 class SnapshotFileCallback FINAL : public FileSystemCallbacksBase { | 160 class SnapshotFileCallback FINAL : public FileSystemCallbacksBase { |
| 161 public: | 161 public: |
| 162 static PassOwnPtr<AsyncFileSystemCallbacks> create(DOMFileSystemBase*, const
String& name, const KURL&, PassOwnPtrWillBeRawPtr<FileCallback>, PassOwnPtrWill
BeRawPtr<ErrorCallback>, ExecutionContext*); | 162 static PassOwnPtr<AsyncFileSystemCallbacks> create(DOMFileSystemBase*, const
String& name, const KURL&, FileCallback*, ErrorCallback*, ExecutionContext*); |
| 163 virtual void didCreateSnapshotFile(const FileMetadata&, PassRefPtr<BlobDataH
andle> snapshot); | 163 virtual void didCreateSnapshotFile(const FileMetadata&, PassRefPtr<BlobDataH
andle> snapshot); |
| 164 | 164 |
| 165 private: | 165 private: |
| 166 SnapshotFileCallback(DOMFileSystemBase*, const String& name, const KURL&, Pa
ssOwnPtrWillBeRawPtr<FileCallback>, PassOwnPtrWillBeRawPtr<ErrorCallback>, Execu
tionContext*); | 166 SnapshotFileCallback(DOMFileSystemBase*, const String& name, const KURL&, Fi
leCallback*, ErrorCallback*, ExecutionContext*); |
| 167 String m_name; | 167 String m_name; |
| 168 KURL m_url; | 168 KURL m_url; |
| 169 OwnPtrWillBePersistent<FileCallback> m_successCallback; | 169 Persistent<FileCallback> m_successCallback; |
| 170 }; | 170 }; |
| 171 | 171 |
| 172 class VoidCallbacks FINAL : public FileSystemCallbacksBase { | 172 class VoidCallbacks FINAL : public FileSystemCallbacksBase { |
| 173 public: | 173 public: |
| 174 static PassOwnPtr<AsyncFileSystemCallbacks> create(PassOwnPtrWillBeRawPtr<Vo
idCallback>, PassOwnPtrWillBeRawPtr<ErrorCallback>, ExecutionContext*, DOMFileSy
stemBase*); | 174 static PassOwnPtr<AsyncFileSystemCallbacks> create(VoidCallback*, ErrorCallb
ack*, ExecutionContext*, DOMFileSystemBase*); |
| 175 virtual void didSucceed() OVERRIDE; | 175 virtual void didSucceed() OVERRIDE; |
| 176 | 176 |
| 177 private: | 177 private: |
| 178 VoidCallbacks(PassOwnPtrWillBeRawPtr<VoidCallback>, PassOwnPtrWillBeRawPtr<E
rrorCallback>, ExecutionContext*, DOMFileSystemBase*); | 178 VoidCallbacks(VoidCallback*, ErrorCallback*, ExecutionContext*, DOMFileSyste
mBase*); |
| 179 OwnPtrWillBePersistent<VoidCallback> m_successCallback; | 179 Persistent<VoidCallback> m_successCallback; |
| 180 }; | 180 }; |
| 181 | 181 |
| 182 } // namespace blink | 182 } // namespace blink |
| 183 | 183 |
| 184 #endif // FileSystemCallbacks_h | 184 #endif // FileSystemCallbacks_h |
| OLD | NEW |