| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 class FileSystemCallbacksBase : public AsyncFileSystemCallbacks { | 55 class FileSystemCallbacksBase : public AsyncFileSystemCallbacks { |
| 56 public: | 56 public: |
| 57 virtual ~FileSystemCallbacksBase(); | 57 virtual ~FileSystemCallbacksBase(); |
| 58 | 58 |
| 59 // For ErrorCallback. | 59 // For ErrorCallback. |
| 60 virtual void didFail(int code) OVERRIDE FINAL; | 60 virtual void didFail(int code) OVERRIDE FINAL; |
| 61 | 61 |
| 62 // Other callback methods are implemented by each subclass. | 62 // Other callback methods are implemented by each subclass. |
| 63 | 63 |
| 64 protected: | 64 protected: |
| 65 FileSystemCallbacksBase(PassOwnPtr<ErrorCallback>, PassRefPtrWillBeRawPtr<DO
MFileSystemBase>, ExecutionContext*); | 65 FileSystemCallbacksBase(PassOwnPtr<ErrorCallback>, DOMFileSystemBase*, Execu
tionContext*); |
| 66 | 66 |
| 67 bool shouldScheduleCallback() const; | 67 bool shouldScheduleCallback() const; |
| 68 | 68 |
| 69 template <typename CB, typename CBArg> | 69 template <typename CB, typename CBArg> |
| 70 void handleEventOrScheduleCallback(PassOwnPtr<CB>, CBArg*); |
| 71 |
| 72 template <typename CB, typename CBArg> |
| 70 void handleEventOrScheduleCallback(PassOwnPtr<CB>, PassRefPtrWillBeRawPtr<CB
Arg>); | 73 void handleEventOrScheduleCallback(PassOwnPtr<CB>, PassRefPtrWillBeRawPtr<CB
Arg>); |
| 71 | 74 |
| 72 template <typename CB> | 75 template <typename CB> |
| 73 void handleEventOrScheduleCallback(PassOwnPtr<CB>); | 76 void handleEventOrScheduleCallback(PassOwnPtr<CB>); |
| 74 | 77 |
| 75 OwnPtr<ErrorCallback> m_errorCallback; | 78 OwnPtr<ErrorCallback> m_errorCallback; |
| 76 RefPtrWillBePersistent<DOMFileSystemBase> m_fileSystem; | 79 Persistent<DOMFileSystemBase> m_fileSystem; |
| 77 RefPtrWillBePersistent<ExecutionContext> m_executionContext; | 80 RefPtrWillBePersistent<ExecutionContext> m_executionContext; |
| 78 }; | 81 }; |
| 79 | 82 |
| 80 // Subclasses ---------------------------------------------------------------- | 83 // Subclasses ---------------------------------------------------------------- |
| 81 | 84 |
| 82 class EntryCallbacks FINAL : public FileSystemCallbacksBase { | 85 class EntryCallbacks FINAL : public FileSystemCallbacksBase { |
| 83 public: | 86 public: |
| 84 static PassOwnPtr<AsyncFileSystemCallbacks> create(PassOwnPtr<EntryCallback>
, PassOwnPtr<ErrorCallback>, ExecutionContext*, PassRefPtrWillBeRawPtr<DOMFileSy
stemBase>, const String& expectedPath, bool isDirectory); | 87 static PassOwnPtr<AsyncFileSystemCallbacks> create(PassOwnPtr<EntryCallback>
, PassOwnPtr<ErrorCallback>, ExecutionContext*, DOMFileSystemBase*, const String
& expectedPath, bool isDirectory); |
| 85 virtual void didSucceed() OVERRIDE; | 88 virtual void didSucceed() OVERRIDE; |
| 86 | 89 |
| 87 private: | 90 private: |
| 88 EntryCallbacks(PassOwnPtr<EntryCallback>, PassOwnPtr<ErrorCallback>, Executi
onContext*, PassRefPtrWillBeRawPtr<DOMFileSystemBase>, const String& expectedPat
h, bool isDirectory); | 91 EntryCallbacks(PassOwnPtr<EntryCallback>, PassOwnPtr<ErrorCallback>, Executi
onContext*, DOMFileSystemBase*, const String& expectedPath, bool isDirectory); |
| 89 OwnPtr<EntryCallback> m_successCallback; | 92 OwnPtr<EntryCallback> m_successCallback; |
| 90 String m_expectedPath; | 93 String m_expectedPath; |
| 91 bool m_isDirectory; | 94 bool m_isDirectory; |
| 92 }; | 95 }; |
| 93 | 96 |
| 94 class EntriesCallbacks FINAL : public FileSystemCallbacksBase { | 97 class EntriesCallbacks FINAL : public FileSystemCallbacksBase { |
| 95 public: | 98 public: |
| 96 static PassOwnPtr<AsyncFileSystemCallbacks> create(PassOwnPtr<EntriesCallbac
k>, PassOwnPtr<ErrorCallback>, ExecutionContext*, PassRefPtrWillBeRawPtr<Directo
ryReaderBase>, const String& basePath); | 99 static PassOwnPtr<AsyncFileSystemCallbacks> create(PassOwnPtr<EntriesCallbac
k>, PassOwnPtr<ErrorCallback>, ExecutionContext*, DirectoryReaderBase*, const St
ring& basePath); |
| 97 virtual void didReadDirectoryEntry(const String& name, bool isDirectory) OVE
RRIDE; | 100 virtual void didReadDirectoryEntry(const String& name, bool isDirectory) OVE
RRIDE; |
| 98 virtual void didReadDirectoryEntries(bool hasMore) OVERRIDE; | 101 virtual void didReadDirectoryEntries(bool hasMore) OVERRIDE; |
| 99 | 102 |
| 100 private: | 103 private: |
| 101 EntriesCallbacks(PassOwnPtr<EntriesCallback>, PassOwnPtr<ErrorCallback>, Exe
cutionContext*, PassRefPtrWillBeRawPtr<DirectoryReaderBase>, const String& baseP
ath); | 104 EntriesCallbacks(PassOwnPtr<EntriesCallback>, PassOwnPtr<ErrorCallback>, Exe
cutionContext*, DirectoryReaderBase*, const String& basePath); |
| 102 OwnPtr<EntriesCallback> m_successCallback; | 105 OwnPtr<EntriesCallback> m_successCallback; |
| 103 RefPtrWillBePersistent<DirectoryReaderBase> m_directoryReader; | 106 Persistent<DirectoryReaderBase> m_directoryReader; |
| 104 String m_basePath; | 107 String m_basePath; |
| 105 WillBePersistentHeapVector<RefPtrWillBeMember<Entry> > m_entries; | 108 PersistentHeapVector<Member<Entry> > m_entries; |
| 106 }; | 109 }; |
| 107 | 110 |
| 108 class FileSystemCallbacks FINAL : public FileSystemCallbacksBase { | 111 class FileSystemCallbacks FINAL : public FileSystemCallbacksBase { |
| 109 public: | 112 public: |
| 110 static PassOwnPtr<AsyncFileSystemCallbacks> create(PassOwnPtr<FileSystemCall
back>, PassOwnPtr<ErrorCallback>, ExecutionContext*, FileSystemType); | 113 static PassOwnPtr<AsyncFileSystemCallbacks> create(PassOwnPtr<FileSystemCall
back>, PassOwnPtr<ErrorCallback>, ExecutionContext*, FileSystemType); |
| 111 virtual void didOpenFileSystem(const String& name, const KURL& rootURL) OVER
RIDE; | 114 virtual void didOpenFileSystem(const String& name, const KURL& rootURL) OVER
RIDE; |
| 112 | 115 |
| 113 private: | 116 private: |
| 114 FileSystemCallbacks(PassOwnPtr<FileSystemCallback>, PassOwnPtr<ErrorCallback
>, ExecutionContext*, FileSystemType); | 117 FileSystemCallbacks(PassOwnPtr<FileSystemCallback>, PassOwnPtr<ErrorCallback
>, ExecutionContext*, FileSystemType); |
| 115 OwnPtr<FileSystemCallback> m_successCallback; | 118 OwnPtr<FileSystemCallback> m_successCallback; |
| 116 FileSystemType m_type; | 119 FileSystemType m_type; |
| 117 }; | 120 }; |
| 118 | 121 |
| 119 class ResolveURICallbacks FINAL : public FileSystemCallbacksBase { | 122 class ResolveURICallbacks FINAL : public FileSystemCallbacksBase { |
| 120 public: | 123 public: |
| 121 static PassOwnPtr<AsyncFileSystemCallbacks> create(PassOwnPtr<EntryCallback>
, PassOwnPtr<ErrorCallback>, ExecutionContext*); | 124 static PassOwnPtr<AsyncFileSystemCallbacks> create(PassOwnPtr<EntryCallback>
, PassOwnPtr<ErrorCallback>, ExecutionContext*); |
| 122 virtual void didResolveURL(const String& name, const KURL& rootURL, FileSyst
emType, const String& filePath, bool isDirectry) OVERRIDE; | 125 virtual void didResolveURL(const String& name, const KURL& rootURL, FileSyst
emType, const String& filePath, bool isDirectry) OVERRIDE; |
| 123 | 126 |
| 124 private: | 127 private: |
| 125 ResolveURICallbacks(PassOwnPtr<EntryCallback>, PassOwnPtr<ErrorCallback>, Ex
ecutionContext*); | 128 ResolveURICallbacks(PassOwnPtr<EntryCallback>, PassOwnPtr<ErrorCallback>, Ex
ecutionContext*); |
| 126 OwnPtr<EntryCallback> m_successCallback; | 129 OwnPtr<EntryCallback> m_successCallback; |
| 127 }; | 130 }; |
| 128 | 131 |
| 129 class MetadataCallbacks FINAL : public FileSystemCallbacksBase { | 132 class MetadataCallbacks FINAL : public FileSystemCallbacksBase { |
| 130 public: | 133 public: |
| 131 static PassOwnPtr<AsyncFileSystemCallbacks> create(PassOwnPtr<MetadataCallba
ck>, PassOwnPtr<ErrorCallback>, ExecutionContext*, PassRefPtrWillBeRawPtr<DOMFil
eSystemBase>); | 134 static PassOwnPtr<AsyncFileSystemCallbacks> create(PassOwnPtr<MetadataCallba
ck>, PassOwnPtr<ErrorCallback>, ExecutionContext*, DOMFileSystemBase*); |
| 132 virtual void didReadMetadata(const FileMetadata&) OVERRIDE; | 135 virtual void didReadMetadata(const FileMetadata&) OVERRIDE; |
| 133 | 136 |
| 134 private: | 137 private: |
| 135 MetadataCallbacks(PassOwnPtr<MetadataCallback>, PassOwnPtr<ErrorCallback>, E
xecutionContext*, PassRefPtrWillBeRawPtr<DOMFileSystemBase>); | 138 MetadataCallbacks(PassOwnPtr<MetadataCallback>, PassOwnPtr<ErrorCallback>, E
xecutionContext*, DOMFileSystemBase*); |
| 136 OwnPtr<MetadataCallback> m_successCallback; | 139 OwnPtr<MetadataCallback> m_successCallback; |
| 137 }; | 140 }; |
| 138 | 141 |
| 139 class FileWriterBaseCallbacks FINAL : public FileSystemCallbacksBase { | 142 class FileWriterBaseCallbacks FINAL : public FileSystemCallbacksBase { |
| 140 public: | 143 public: |
| 141 static PassOwnPtr<AsyncFileSystemCallbacks> create(PassRefPtrWillBeRawPtr<Fi
leWriterBase>, PassOwnPtr<FileWriterBaseCallback>, PassOwnPtr<ErrorCallback>, Ex
ecutionContext*); | 144 static PassOwnPtr<AsyncFileSystemCallbacks> create(PassRefPtrWillBeRawPtr<Fi
leWriterBase>, PassOwnPtr<FileWriterBaseCallback>, PassOwnPtr<ErrorCallback>, Ex
ecutionContext*); |
| 142 virtual void didCreateFileWriter(PassOwnPtr<blink::WebFileWriter>, long long
length) OVERRIDE; | 145 virtual void didCreateFileWriter(PassOwnPtr<blink::WebFileWriter>, long long
length) OVERRIDE; |
| 143 | 146 |
| 144 private: | 147 private: |
| 145 FileWriterBaseCallbacks(PassRefPtrWillBeRawPtr<FileWriterBase>, PassOwnPtr<F
ileWriterBaseCallback>, PassOwnPtr<ErrorCallback>, ExecutionContext*); | 148 FileWriterBaseCallbacks(PassRefPtrWillBeRawPtr<FileWriterBase>, PassOwnPtr<F
ileWriterBaseCallback>, PassOwnPtr<ErrorCallback>, ExecutionContext*); |
| 146 RefPtrWillBePersistent<FileWriterBase> m_fileWriter; | 149 Persistent<FileWriterBase> m_fileWriter; |
| 147 OwnPtr<FileWriterBaseCallback> m_successCallback; | 150 OwnPtr<FileWriterBaseCallback> m_successCallback; |
| 148 }; | 151 }; |
| 149 | 152 |
| 150 class VoidCallbacks FINAL : public FileSystemCallbacksBase { | 153 class VoidCallbacks FINAL : public FileSystemCallbacksBase { |
| 151 public: | 154 public: |
| 152 static PassOwnPtr<AsyncFileSystemCallbacks> create(PassOwnPtr<VoidCallback>,
PassOwnPtr<ErrorCallback>, ExecutionContext*, PassRefPtrWillBeRawPtr<DOMFileSys
temBase>); | 155 static PassOwnPtr<AsyncFileSystemCallbacks> create(PassOwnPtr<VoidCallback>,
PassOwnPtr<ErrorCallback>, ExecutionContext*, DOMFileSystemBase*); |
| 153 virtual void didSucceed() OVERRIDE; | 156 virtual void didSucceed() OVERRIDE; |
| 154 | 157 |
| 155 private: | 158 private: |
| 156 VoidCallbacks(PassOwnPtr<VoidCallback>, PassOwnPtr<ErrorCallback>, Execution
Context*, PassRefPtrWillBeRawPtr<DOMFileSystemBase>); | 159 VoidCallbacks(PassOwnPtr<VoidCallback>, PassOwnPtr<ErrorCallback>, Execution
Context*, DOMFileSystemBase*); |
| 157 OwnPtr<VoidCallback> m_successCallback; | 160 OwnPtr<VoidCallback> m_successCallback; |
| 158 }; | 161 }; |
| 159 | 162 |
| 160 } // namespace | 163 } // namespace |
| 161 | 164 |
| 162 #endif // FileSystemCallbacks_h | 165 #endif // FileSystemCallbacks_h |
| OLD | NEW |