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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 errorCallback->handleEvent(fileError.get()); | 70 errorCallback->handleEvent(fileError.get()); |
71 } | 71 } |
72 | 72 |
73 PassRefPtr<DirectoryEntrySync> DOMFileSystemSync::root() | 73 PassRefPtr<DirectoryEntrySync> DOMFileSystemSync::root() |
74 { | 74 { |
75 return DirectoryEntrySync::create(this, DOMFilePath::root); | 75 return DirectoryEntrySync::create(this, DOMFilePath::root); |
76 } | 76 } |
77 | 77 |
78 namespace { | 78 namespace { |
79 | 79 |
80 class CreateFileHelper : public AsyncFileSystemCallbacks { | 80 class CreateFileHelper FINAL : public AsyncFileSystemCallbacks { |
81 public: | 81 public: |
82 class CreateFileResult : public RefCounted<CreateFileResult> { | 82 class CreateFileResult : public RefCounted<CreateFileResult> { |
83 public: | 83 public: |
84 static PassRefPtr<CreateFileResult> create() | 84 static PassRefPtr<CreateFileResult> create() |
85 { | 85 { |
86 return adoptRef(new CreateFileResult()); | 86 return adoptRef(new CreateFileResult()); |
87 } | 87 } |
88 | 88 |
89 bool m_failed; | 89 bool m_failed; |
90 int m_code; | 90 int m_code; |
(...skipping 10 matching lines...) Expand all Loading... |
101 { | 101 { |
102 } | 102 } |
103 friend class WTF::RefCounted<CreateFileResult>; | 103 friend class WTF::RefCounted<CreateFileResult>; |
104 }; | 104 }; |
105 | 105 |
106 static PassOwnPtr<AsyncFileSystemCallbacks> create(PassRefPtr<CreateFileResu
lt> result, const String& name, const KURL& url, FileSystemType type) | 106 static PassOwnPtr<AsyncFileSystemCallbacks> create(PassRefPtr<CreateFileResu
lt> result, const String& name, const KURL& url, FileSystemType type) |
107 { | 107 { |
108 return adoptPtr(static_cast<AsyncFileSystemCallbacks*>(new CreateFileHel
per(result, name, url, type))); | 108 return adoptPtr(static_cast<AsyncFileSystemCallbacks*>(new CreateFileHel
per(result, name, url, type))); |
109 } | 109 } |
110 | 110 |
111 virtual void didFail(int code) | 111 virtual void didFail(int code) OVERRIDE |
112 { | 112 { |
113 m_result->m_failed = true; | 113 m_result->m_failed = true; |
114 m_result->m_code = code; | 114 m_result->m_code = code; |
115 } | 115 } |
116 | 116 |
117 virtual ~CreateFileHelper() | 117 virtual ~CreateFileHelper() |
118 { | 118 { |
119 } | 119 } |
120 | 120 |
121 virtual void didCreateSnapshotFile(const FileMetadata& metadata, PassRefPtr<
BlobDataHandle> snapshot) | 121 virtual void didCreateSnapshotFile(const FileMetadata& metadata, PassRefPtr<
BlobDataHandle> snapshot) OVERRIDE |
122 { | 122 { |
123 // We can't directly use the snapshot blob data handle because the conte
nt type on it hasn't been set. | 123 // We can't directly use the snapshot blob data handle because the conte
nt type on it hasn't been set. |
124 // The |snapshot| param is here to provide a a chain of custody thru thr
ead bridging that is held onto until | 124 // The |snapshot| param is here to provide a a chain of custody thru thr
ead bridging that is held onto until |
125 // *after* we've coined a File with a new handle that has the correct ty
pe set on it. This allows the | 125 // *after* we've coined a File with a new handle that has the correct ty
pe set on it. This allows the |
126 // blob storage system to track when a temp file can and can't be safely
deleted. | 126 // blob storage system to track when a temp file can and can't be safely
deleted. |
127 | 127 |
128 // For regular filesystem types (temporary or persistent), we should not
cache file metadata as it could change File semantics. | 128 // For regular filesystem types (temporary or persistent), we should not
cache file metadata as it could change File semantics. |
129 // For other filesystem types (which could be platform-specific ones), t
here's a chance that the files are on remote filesystem. | 129 // For other filesystem types (which could be platform-specific ones), t
here's a chance that the files are on remote filesystem. |
130 // If the port has returned metadata just pass it to File constructor (s
o we may cache the metadata). | 130 // If the port has returned metadata just pass it to File constructor (s
o we may cache the metadata). |
131 // FIXME: We should use the snapshot metadata for all files. | 131 // FIXME: We should use the snapshot metadata for all files. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 fileSystem()->createSnapshotFileAndReadMetadata(fileSystemURL, CreateFileHel
per::create(result, fileEntry->name(), fileSystemURL, type())); | 170 fileSystem()->createSnapshotFileAndReadMetadata(fileSystemURL, CreateFileHel
per::create(result, fileEntry->name(), fileSystemURL, type())); |
171 if (result->m_failed) { | 171 if (result->m_failed) { |
172 exceptionState.throwUninformativeAndGenericDOMException(result->m_code); | 172 exceptionState.throwUninformativeAndGenericDOMException(result->m_code); |
173 return 0; | 173 return 0; |
174 } | 174 } |
175 return result->m_file; | 175 return result->m_file; |
176 } | 176 } |
177 | 177 |
178 namespace { | 178 namespace { |
179 | 179 |
180 class ReceiveFileWriterCallback : public FileWriterBaseCallback { | 180 class ReceiveFileWriterCallback FINAL : public FileWriterBaseCallback { |
181 public: | 181 public: |
182 static PassOwnPtr<ReceiveFileWriterCallback> create() | 182 static PassOwnPtr<ReceiveFileWriterCallback> create() |
183 { | 183 { |
184 return adoptPtr(new ReceiveFileWriterCallback()); | 184 return adoptPtr(new ReceiveFileWriterCallback()); |
185 } | 185 } |
186 | 186 |
187 void handleEvent(FileWriterBase*) | 187 virtual void handleEvent(FileWriterBase*) OVERRIDE |
188 { | 188 { |
189 } | 189 } |
190 | 190 |
191 private: | 191 private: |
192 ReceiveFileWriterCallback() | 192 ReceiveFileWriterCallback() |
193 { | 193 { |
194 } | 194 } |
195 }; | 195 }; |
196 | 196 |
197 class LocalErrorCallback : public ErrorCallback { | 197 class LocalErrorCallback FINAL : public ErrorCallback { |
198 public: | 198 public: |
199 static PassOwnPtr<LocalErrorCallback> create(FileError::ErrorCode& errorCode
) | 199 static PassOwnPtr<LocalErrorCallback> create(FileError::ErrorCode& errorCode
) |
200 { | 200 { |
201 return adoptPtr(new LocalErrorCallback(errorCode)); | 201 return adoptPtr(new LocalErrorCallback(errorCode)); |
202 } | 202 } |
203 | 203 |
204 void handleEvent(FileError* error) | 204 virtual void handleEvent(FileError* error) OVERRIDE |
205 { | 205 { |
206 ASSERT(error->code() != FileError::OK); | 206 ASSERT(error->code() != FileError::OK); |
207 m_errorCode = error->code(); | 207 m_errorCode = error->code(); |
208 } | 208 } |
209 | 209 |
210 private: | 210 private: |
211 explicit LocalErrorCallback(FileError::ErrorCode& errorCode) | 211 explicit LocalErrorCallback(FileError::ErrorCode& errorCode) |
212 : m_errorCode(errorCode) | 212 : m_errorCode(errorCode) |
213 { | 213 { |
214 } | 214 } |
(...skipping 17 matching lines...) Expand all Loading... |
232 | 232 |
233 fileSystem()->createFileWriter(createFileSystemURL(fileEntry), fileWriter.ge
t(), callbacks.release()); | 233 fileSystem()->createFileWriter(createFileSystemURL(fileEntry), fileWriter.ge
t(), callbacks.release()); |
234 if (errorCode != FileError::OK) { | 234 if (errorCode != FileError::OK) { |
235 FileError::throwDOMException(exceptionState, errorCode); | 235 FileError::throwDOMException(exceptionState, errorCode); |
236 return 0; | 236 return 0; |
237 } | 237 } |
238 return fileWriter.release(); | 238 return fileWriter.release(); |
239 } | 239 } |
240 | 240 |
241 } | 241 } |
OLD | NEW |