OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 void start(ExecutionContext*); | 194 void start(ExecutionContext*); |
195 | 195 |
196 private: | 196 private: |
197 bool didHitError(FileError* error) | 197 bool didHitError(FileError* error) |
198 { | 198 { |
199 reportResult(error->code()); | 199 reportResult(error->code()); |
200 return true; | 200 return true; |
201 } | 201 } |
202 | 202 |
203 bool didGetEntry(Entry*); | 203 bool didGetEntry(Entry*); |
204 bool didReadDirectoryEntries(const EntryVector&); | 204 bool didReadDirectoryEntries(const EntryHeapVector&); |
205 | 205 |
206 void reportResult(FileError::ErrorCode errorCode, PassRefPtr<Array<TypeBuild
er::FileSystem::Entry> > entries = nullptr) | 206 void reportResult(FileError::ErrorCode errorCode, PassRefPtr<Array<TypeBuild
er::FileSystem::Entry> > entries = nullptr) |
207 { | 207 { |
208 m_requestCallback->sendSuccess(static_cast<int>(errorCode), entries); | 208 m_requestCallback->sendSuccess(static_cast<int>(errorCode), entries); |
209 } | 209 } |
210 | 210 |
211 DirectoryContentRequest(PassRefPtr<RequestDirectoryContentCallback> requestC
allback, const String& url) | 211 DirectoryContentRequest(PassRefPtr<RequestDirectoryContentCallback> requestC
allback, const String& url) |
212 : m_requestCallback(requestCallback) | 212 : m_requestCallback(requestCallback) |
213 , m_url(ParsedURLString, url) { } | 213 , m_url(ParsedURLString, url) { } |
214 | 214 |
215 void readDirectoryEntries(); | 215 void readDirectoryEntries(); |
216 | 216 |
217 RefPtr<RequestDirectoryContentCallback> m_requestCallback; | 217 RefPtr<RequestDirectoryContentCallback> m_requestCallback; |
218 KURL m_url; | 218 KURL m_url; |
219 RefPtr<Array<TypeBuilder::FileSystem::Entry> > m_entries; | 219 RefPtr<Array<TypeBuilder::FileSystem::Entry> > m_entries; |
220 RefPtr<DirectoryReader> m_directoryReader; | 220 RefPtrWillBePersistent<DirectoryReader> m_directoryReader; |
221 }; | 221 }; |
222 | 222 |
223 void DirectoryContentRequest::start(ExecutionContext* executionContext) | 223 void DirectoryContentRequest::start(ExecutionContext* executionContext) |
224 { | 224 { |
225 ASSERT(executionContext); | 225 ASSERT(executionContext); |
226 | 226 |
227 OwnPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallbac
k>::create(this, &DirectoryContentRequest::didHitError); | 227 OwnPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallbac
k>::create(this, &DirectoryContentRequest::didHitError); |
228 OwnPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallb
ack>::create(this, &DirectoryContentRequest::didGetEntry); | 228 OwnPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallb
ack>::create(this, &DirectoryContentRequest::didGetEntry); |
229 | 229 |
230 OwnPtr<AsyncFileSystemCallbacks> fileSystemCallbacks = ResolveURICallbacks::
create(successCallback.release(), errorCallback.release(), executionContext); | 230 OwnPtr<AsyncFileSystemCallbacks> fileSystemCallbacks = ResolveURICallbacks::
create(successCallback.release(), errorCallback.release(), executionContext); |
(...skipping 19 matching lines...) Expand all Loading... |
250 if (!m_directoryReader->filesystem()->executionContext()) { | 250 if (!m_directoryReader->filesystem()->executionContext()) { |
251 reportResult(FileError::ABORT_ERR); | 251 reportResult(FileError::ABORT_ERR); |
252 return; | 252 return; |
253 } | 253 } |
254 | 254 |
255 OwnPtr<EntriesCallback> successCallback = CallbackDispatcherFactory<EntriesC
allback>::create(this, &DirectoryContentRequest::didReadDirectoryEntries); | 255 OwnPtr<EntriesCallback> successCallback = CallbackDispatcherFactory<EntriesC
allback>::create(this, &DirectoryContentRequest::didReadDirectoryEntries); |
256 OwnPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallbac
k>::create(this, &DirectoryContentRequest::didHitError); | 256 OwnPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallbac
k>::create(this, &DirectoryContentRequest::didHitError); |
257 m_directoryReader->readEntries(successCallback.release(), errorCallback.rele
ase()); | 257 m_directoryReader->readEntries(successCallback.release(), errorCallback.rele
ase()); |
258 } | 258 } |
259 | 259 |
260 bool DirectoryContentRequest::didReadDirectoryEntries(const EntryVector& entries
) | 260 bool DirectoryContentRequest::didReadDirectoryEntries(const EntryHeapVector& ent
ries) |
261 { | 261 { |
262 if (entries.isEmpty()) { | 262 if (entries.isEmpty()) { |
263 reportResult(static_cast<FileError::ErrorCode>(0), m_entries); | 263 reportResult(static_cast<FileError::ErrorCode>(0), m_entries); |
264 return true; | 264 return true; |
265 } | 265 } |
266 | 266 |
267 for (size_t i = 0; i < entries.size(); ++i) { | 267 for (size_t i = 0; i < entries.size(); ++i) { |
268 RefPtr<Entry> entry = entries[i]; | 268 RefPtrWillBeRawPtr<Entry> entry = entries[i]; |
269 RefPtr<TypeBuilder::FileSystem::Entry> entryForFrontend = TypeBuilder::F
ileSystem::Entry::create() | 269 RefPtr<TypeBuilder::FileSystem::Entry> entryForFrontend = TypeBuilder::F
ileSystem::Entry::create() |
270 .setUrl(entry->toURL()) | 270 .setUrl(entry->toURL()) |
271 .setName(entry->name()) | 271 .setName(entry->name()) |
272 .setIsDirectory(entry->isDirectory()); | 272 .setIsDirectory(entry->isDirectory()); |
273 | 273 |
274 using TypeBuilder::Page::ResourceType; | 274 using TypeBuilder::Page::ResourceType; |
275 if (!entry->isDirectory()) { | 275 if (!entry->isDirectory()) { |
276 String mimeType = MIMETypeRegistry::getMIMETypeForPath(entry->name()
); | 276 String mimeType = MIMETypeRegistry::getMIMETypeForPath(entry->name()
); |
277 ResourceType::Enum resourceType; | 277 ResourceType::Enum resourceType; |
278 if (MIMETypeRegistry::isSupportedImageMIMEType(mimeType)) { | 278 if (MIMETypeRegistry::isSupportedImageMIMEType(mimeType)) { |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 , m_charset(charset) { } | 426 , m_charset(charset) { } |
427 | 427 |
428 RefPtr<RequestFileContentCallback> m_requestCallback; | 428 RefPtr<RequestFileContentCallback> m_requestCallback; |
429 KURL m_url; | 429 KURL m_url; |
430 bool m_readAsText; | 430 bool m_readAsText; |
431 int m_start; | 431 int m_start; |
432 long long m_end; | 432 long long m_end; |
433 String m_mimeType; | 433 String m_mimeType; |
434 String m_charset; | 434 String m_charset; |
435 | 435 |
436 RefPtr<FileReader> m_reader; | 436 RefPtrWillBePersistent<FileReader> m_reader; |
437 }; | 437 }; |
438 | 438 |
439 void FileContentRequest::start(ExecutionContext* executionContext) | 439 void FileContentRequest::start(ExecutionContext* executionContext) |
440 { | 440 { |
441 ASSERT(executionContext); | 441 ASSERT(executionContext); |
442 | 442 |
443 OwnPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallbac
k>::create(this, &FileContentRequest::didHitError); | 443 OwnPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallbac
k>::create(this, &FileContentRequest::didHitError); |
444 OwnPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallb
ack>::create(this, &FileContentRequest::didGetEntry); | 444 OwnPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallb
ack>::create(this, &FileContentRequest::didGetEntry); |
445 | 445 |
446 OwnPtr<AsyncFileSystemCallbacks> fileSystemCallbacks = ResolveURICallbacks::
create(successCallback.release(), errorCallback.release(), executionContext); | 446 OwnPtr<AsyncFileSystemCallbacks> fileSystemCallbacks = ResolveURICallbacks::
create(successCallback.release(), errorCallback.release(), executionContext); |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
718 for (LocalFrame* frame = m_page->mainFrame(); frame; frame = frame->tree().t
raverseNext()) { | 718 for (LocalFrame* frame = m_page->mainFrame(); frame; frame = frame->tree().t
raverseNext()) { |
719 if (frame->document() && frame->document()->securityOrigin()->isSameSche
meHostPort(origin)) | 719 if (frame->document() && frame->document()->securityOrigin()->isSameSche
meHostPort(origin)) |
720 return frame->document(); | 720 return frame->document(); |
721 } | 721 } |
722 | 722 |
723 *error = "No frame is available for the request"; | 723 *error = "No frame is available for the request"; |
724 return 0; | 724 return 0; |
725 } | 725 } |
726 | 726 |
727 } // namespace WebCore | 727 } // namespace WebCore |
OLD | NEW |