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 | 55 |
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; | 61 virtual void didFail(int code) OVERRIDE; |
62 | 62 |
63 // Other callback methods are implemented by each subclass. | 63 // Other callback methods are implemented by each subclass. |
64 | 64 |
65 virtual bool shouldBlockUntilCompletion() const OVERRIDE | |
66 { | |
67 return m_blockUntilCompletion; | |
68 } | |
69 | |
70 void setShouldBlockUntilCompletion(bool flag) | |
71 { | |
72 m_blockUntilCompletion = flag; | |
73 } | |
74 | |
75 protected: | 65 protected: |
76 FileSystemCallbacksBase(PassRefPtr<ErrorCallback>); | 66 FileSystemCallbacksBase(PassRefPtr<ErrorCallback>, DOMFileSystemBase*); |
77 RefPtr<ErrorCallback> m_errorCallback; | 67 RefPtr<ErrorCallback> m_errorCallback; |
78 bool m_blockUntilCompletion; | 68 DOMFileSystemBase* m_fileSystem; |
79 }; | 69 }; |
80 | 70 |
81 // Subclasses ---------------------------------------------------------------- | 71 // Subclasses ---------------------------------------------------------------- |
82 | 72 |
83 class EntryCallbacks : public FileSystemCallbacksBase { | 73 class EntryCallbacks : public FileSystemCallbacksBase { |
84 public: | 74 public: |
85 static PassOwnPtr<EntryCallbacks> create(PassRefPtr<EntryCallback>, PassRefP
tr<ErrorCallback>, PassRefPtr<DOMFileSystemBase>, const String& expectedPath, bo
ol isDirectory); | 75 static PassOwnPtr<AsyncFileSystemCallbacks> create(PassRefPtr<EntryCallback>
, PassRefPtr<ErrorCallback>, PassRefPtr<DOMFileSystemBase>, const String& expect
edPath, bool isDirectory); |
86 virtual void didSucceed(); | 76 virtual void didSucceed(); |
87 | 77 |
88 private: | 78 private: |
89 EntryCallbacks(PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>, PassRef
Ptr<DOMFileSystemBase>, const String& expectedPath, bool isDirectory); | 79 EntryCallbacks(PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>, PassRef
Ptr<DOMFileSystemBase>, const String& expectedPath, bool isDirectory); |
90 RefPtr<EntryCallback> m_successCallback; | 80 RefPtr<EntryCallback> m_successCallback; |
91 RefPtr<DOMFileSystemBase> m_fileSystem; | |
92 String m_expectedPath; | 81 String m_expectedPath; |
93 bool m_isDirectory; | 82 bool m_isDirectory; |
94 }; | 83 }; |
95 | 84 |
96 class EntriesCallbacks : public FileSystemCallbacksBase { | 85 class EntriesCallbacks : public FileSystemCallbacksBase { |
97 public: | 86 public: |
98 static PassOwnPtr<EntriesCallbacks> create(PassRefPtr<EntriesCallback>, Pass
RefPtr<ErrorCallback>, PassRefPtr<DirectoryReaderBase>, const String& basePath); | 87 static PassOwnPtr<AsyncFileSystemCallbacks> create(PassRefPtr<EntriesCallbac
k>, PassRefPtr<ErrorCallback>, PassRefPtr<DirectoryReaderBase>, const String& ba
sePath); |
99 virtual void didReadDirectoryEntry(const String& name, bool isDirectory); | 88 virtual void didReadDirectoryEntry(const String& name, bool isDirectory); |
100 virtual void didReadDirectoryEntries(bool hasMore); | 89 virtual void didReadDirectoryEntries(bool hasMore); |
101 | 90 |
102 private: | 91 private: |
103 EntriesCallbacks(PassRefPtr<EntriesCallback>, PassRefPtr<ErrorCallback>, Pas
sRefPtr<DirectoryReaderBase>, const String& basePath); | 92 EntriesCallbacks(PassRefPtr<EntriesCallback>, PassRefPtr<ErrorCallback>, Pas
sRefPtr<DirectoryReaderBase>, const String& basePath); |
104 RefPtr<EntriesCallback> m_successCallback; | 93 RefPtr<EntriesCallback> m_successCallback; |
105 RefPtr<DirectoryReaderBase> m_directoryReader; | 94 RefPtr<DirectoryReaderBase> m_directoryReader; |
106 String m_basePath; | 95 String m_basePath; |
107 EntryVector m_entries; | 96 EntryVector m_entries; |
108 }; | 97 }; |
109 | 98 |
110 class FileSystemCallbacks : public FileSystemCallbacksBase { | 99 class FileSystemCallbacks : public FileSystemCallbacksBase { |
111 public: | 100 public: |
112 static PassOwnPtr<FileSystemCallbacks> create(PassRefPtr<FileSystemCallback>
, PassRefPtr<ErrorCallback>, ScriptExecutionContext*, FileSystemType); | 101 static PassOwnPtr<AsyncFileSystemCallbacks> create(PassRefPtr<FileSystemCall
back>, PassRefPtr<ErrorCallback>, ScriptExecutionContext*, FileSystemType); |
113 virtual void didOpenFileSystem(const String& name, const KURL& rootURL, Pass
OwnPtr<AsyncFileSystem>); | 102 virtual void didOpenFileSystem(const String& name, const KURL& rootURL); |
114 | 103 |
115 private: | 104 private: |
116 FileSystemCallbacks(PassRefPtr<FileSystemCallback>, PassRefPtr<ErrorCallback
>, ScriptExecutionContext*, FileSystemType); | 105 FileSystemCallbacks(PassRefPtr<FileSystemCallback>, PassRefPtr<ErrorCallback
>, ScriptExecutionContext*, FileSystemType); |
117 RefPtr<FileSystemCallback> m_successCallback; | 106 RefPtr<FileSystemCallback> m_successCallback; |
118 RefPtr<ScriptExecutionContext> m_scriptExecutionContext; | 107 RefPtr<ScriptExecutionContext> m_scriptExecutionContext; |
119 FileSystemType m_type; | 108 FileSystemType m_type; |
120 }; | 109 }; |
121 | 110 |
122 class ResolveURICallbacks : public FileSystemCallbacksBase { | 111 class ResolveURICallbacks : public FileSystemCallbacksBase { |
123 public: | 112 public: |
124 static PassOwnPtr<ResolveURICallbacks> create(PassRefPtr<EntryCallback>, Pas
sRefPtr<ErrorCallback>, ScriptExecutionContext*, FileSystemType, const String& f
ilePath); | 113 static PassOwnPtr<AsyncFileSystemCallbacks> create(PassRefPtr<EntryCallback>
, PassRefPtr<ErrorCallback>, ScriptExecutionContext*, FileSystemType, const Stri
ng& filePath); |
125 virtual void didOpenFileSystem(const String& name, const KURL& rootURL, Pass
OwnPtr<AsyncFileSystem>); | 114 virtual void didOpenFileSystem(const String& name, const KURL& rootURL); |
126 | 115 |
127 private: | 116 private: |
128 ResolveURICallbacks(PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>, Sc
riptExecutionContext*, FileSystemType, const String& filePath); | 117 ResolveURICallbacks(PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>, Sc
riptExecutionContext*, FileSystemType, const String& filePath); |
129 RefPtr<EntryCallback> m_successCallback; | 118 RefPtr<EntryCallback> m_successCallback; |
130 RefPtr<ScriptExecutionContext> m_scriptExecutionContext; | 119 RefPtr<ScriptExecutionContext> m_scriptExecutionContext; |
131 FileSystemType m_type; | 120 FileSystemType m_type; |
132 String m_filePath; | 121 String m_filePath; |
133 }; | 122 }; |
134 | 123 |
135 class MetadataCallbacks : public FileSystemCallbacksBase { | 124 class MetadataCallbacks : public FileSystemCallbacksBase { |
136 public: | 125 public: |
137 static PassOwnPtr<MetadataCallbacks> create(PassRefPtr<MetadataCallback>, Pa
ssRefPtr<ErrorCallback>); | 126 static PassOwnPtr<AsyncFileSystemCallbacks> create(PassRefPtr<MetadataCallba
ck>, PassRefPtr<ErrorCallback>, DOMFileSystemBase*); |
138 virtual void didReadMetadata(const FileMetadata&); | 127 virtual void didReadMetadata(const FileMetadata&); |
139 | 128 |
140 private: | 129 private: |
141 MetadataCallbacks(PassRefPtr<MetadataCallback>, PassRefPtr<ErrorCallback>); | 130 MetadataCallbacks(PassRefPtr<MetadataCallback>, PassRefPtr<ErrorCallback>, D
OMFileSystemBase*); |
142 RefPtr<MetadataCallback> m_successCallback; | 131 RefPtr<MetadataCallback> m_successCallback; |
143 }; | 132 }; |
144 | 133 |
145 class FileWriterBaseCallbacks : public FileSystemCallbacksBase { | 134 class FileWriterBaseCallbacks : public FileSystemCallbacksBase { |
146 public: | 135 public: |
147 static PassOwnPtr<FileWriterBaseCallbacks> create(PassRefPtr<FileWriterBase>
, PassRefPtr<FileWriterBaseCallback>, PassRefPtr<ErrorCallback>); | 136 static PassOwnPtr<AsyncFileSystemCallbacks> create(PassRefPtr<FileWriterBase
>, PassRefPtr<FileWriterBaseCallback>, PassRefPtr<ErrorCallback>); |
148 virtual void didCreateFileWriter(PassOwnPtr<WebKit::WebFileWriter>, long lon
g length); | 137 virtual void didCreateFileWriter(PassOwnPtr<WebKit::WebFileWriter>, long lon
g length); |
149 | 138 |
150 private: | 139 private: |
151 FileWriterBaseCallbacks(PassRefPtr<FileWriterBase>, PassRefPtr<FileWriterBas
eCallback>, PassRefPtr<ErrorCallback>); | 140 FileWriterBaseCallbacks(PassRefPtr<FileWriterBase>, PassRefPtr<FileWriterBas
eCallback>, PassRefPtr<ErrorCallback>); |
152 RefPtr<FileWriterBase> m_fileWriter; | 141 RefPtr<FileWriterBase> m_fileWriter; |
153 RefPtr<FileWriterBaseCallback> m_successCallback; | 142 RefPtr<FileWriterBaseCallback> m_successCallback; |
154 }; | 143 }; |
155 | 144 |
156 class VoidCallbacks : public FileSystemCallbacksBase { | 145 class VoidCallbacks : public FileSystemCallbacksBase { |
157 public: | 146 public: |
158 static PassOwnPtr<VoidCallbacks> create(PassRefPtr<VoidCallback>, PassRefPtr
<ErrorCallback>); | 147 static PassOwnPtr<AsyncFileSystemCallbacks> create(PassRefPtr<VoidCallback>,
PassRefPtr<ErrorCallback>, DOMFileSystemBase*); |
159 virtual void didSucceed(); | 148 virtual void didSucceed(); |
160 | 149 |
161 private: | 150 private: |
162 VoidCallbacks(PassRefPtr<VoidCallback>, PassRefPtr<ErrorCallback>); | 151 VoidCallbacks(PassRefPtr<VoidCallback>, PassRefPtr<ErrorCallback>, DOMFileSy
stemBase*); |
163 RefPtr<VoidCallback> m_successCallback; | 152 RefPtr<VoidCallback> m_successCallback; |
164 }; | 153 }; |
165 | 154 |
166 } // namespace | 155 } // namespace |
167 | 156 |
168 #endif // FileSystemCallbacks_h | 157 #endif // FileSystemCallbacks_h |
OLD | NEW |