| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 | 73 |
| 74 namespace WebCore { | 74 namespace WebCore { |
| 75 | 75 |
| 76 namespace FileSystemAgentState { | 76 namespace FileSystemAgentState { |
| 77 static const char fileSystemAgentEnabled[] = "fileSystemAgentEnabled"; | 77 static const char fileSystemAgentEnabled[] = "fileSystemAgentEnabled"; |
| 78 } | 78 } |
| 79 | 79 |
| 80 namespace { | 80 namespace { |
| 81 | 81 |
| 82 template<typename BaseCallback, typename Handler, typename Argument> | 82 template<typename BaseCallback, typename Handler, typename Argument> |
| 83 class CallbackDispatcher : public BaseCallback { | 83 class CallbackDispatcher FINAL : public BaseCallback { |
| 84 public: | 84 public: |
| 85 typedef bool (Handler::*HandlingMethod)(Argument); | 85 typedef bool (Handler::*HandlingMethod)(Argument); |
| 86 | 86 |
| 87 static PassOwnPtr<CallbackDispatcher> create(PassRefPtr<Handler> handler, Ha
ndlingMethod handlingMethod) | 87 static PassOwnPtr<CallbackDispatcher> create(PassRefPtr<Handler> handler, Ha
ndlingMethod handlingMethod) |
| 88 { | 88 { |
| 89 return adoptPtr(new CallbackDispatcher(handler, handlingMethod)); | 89 return adoptPtr(new CallbackDispatcher(handler, handlingMethod)); |
| 90 } | 90 } |
| 91 | 91 |
| 92 virtual void handleEvent(Argument argument) OVERRIDE | 92 virtual void handleEvent(Argument argument) OVERRIDE |
| 93 { | 93 { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 bool FileSystemRootRequest::didGetEntry(Entry* entry) | 171 bool FileSystemRootRequest::didGetEntry(Entry* entry) |
| 172 { | 172 { |
| 173 RefPtr<TypeBuilder::FileSystem::Entry> result = TypeBuilder::FileSystem::Ent
ry::create() | 173 RefPtr<TypeBuilder::FileSystem::Entry> result = TypeBuilder::FileSystem::Ent
ry::create() |
| 174 .setUrl(entry->toURL()) | 174 .setUrl(entry->toURL()) |
| 175 .setName("/") | 175 .setName("/") |
| 176 .setIsDirectory(true); | 176 .setIsDirectory(true); |
| 177 reportResult(static_cast<FileError::ErrorCode>(0), result); | 177 reportResult(static_cast<FileError::ErrorCode>(0), result); |
| 178 return true; | 178 return true; |
| 179 } | 179 } |
| 180 | 180 |
| 181 class DirectoryContentRequest : public RefCounted<DirectoryContentRequest> { | 181 class DirectoryContentRequest FINAL : public RefCounted<DirectoryContentRequest>
{ |
| 182 WTF_MAKE_NONCOPYABLE(DirectoryContentRequest); | 182 WTF_MAKE_NONCOPYABLE(DirectoryContentRequest); |
| 183 public: | 183 public: |
| 184 static PassRefPtr<DirectoryContentRequest> create(PassRefPtr<RequestDirector
yContentCallback> requestCallback, const String& url) | 184 static PassRefPtr<DirectoryContentRequest> create(PassRefPtr<RequestDirector
yContentCallback> requestCallback, const String& url) |
| 185 { | 185 { |
| 186 return adoptRef(new DirectoryContentRequest(requestCallback, url)); | 186 return adoptRef(new DirectoryContentRequest(requestCallback, url)); |
| 187 } | 187 } |
| 188 | 188 |
| 189 virtual ~DirectoryContentRequest() | 189 ~DirectoryContentRequest() |
| 190 { | 190 { |
| 191 reportResult(FileError::ABORT_ERR); | 191 reportResult(FileError::ABORT_ERR); |
| 192 } | 192 } |
| 193 | 193 |
| 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()); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 entryForFrontend->setMimeType(mimeType); | 292 entryForFrontend->setMimeType(mimeType); |
| 293 entryForFrontend->setResourceType(resourceType); | 293 entryForFrontend->setResourceType(resourceType); |
| 294 } | 294 } |
| 295 | 295 |
| 296 m_entries->addItem(entryForFrontend); | 296 m_entries->addItem(entryForFrontend); |
| 297 } | 297 } |
| 298 readDirectoryEntries(); | 298 readDirectoryEntries(); |
| 299 return true; | 299 return true; |
| 300 } | 300 } |
| 301 | 301 |
| 302 class MetadataRequest : public RefCounted<MetadataRequest> { | 302 class MetadataRequest FINAL : public RefCounted<MetadataRequest> { |
| 303 WTF_MAKE_NONCOPYABLE(MetadataRequest); | 303 WTF_MAKE_NONCOPYABLE(MetadataRequest); |
| 304 public: | 304 public: |
| 305 static PassRefPtr<MetadataRequest> create(PassRefPtr<RequestMetadataCallback
> requestCallback, const String& url) | 305 static PassRefPtr<MetadataRequest> create(PassRefPtr<RequestMetadataCallback
> requestCallback, const String& url) |
| 306 { | 306 { |
| 307 return adoptRef(new MetadataRequest(requestCallback, url)); | 307 return adoptRef(new MetadataRequest(requestCallback, url)); |
| 308 } | 308 } |
| 309 | 309 |
| 310 virtual ~MetadataRequest() | 310 ~MetadataRequest() |
| 311 { | 311 { |
| 312 reportResult(FileError::ABORT_ERR); | 312 reportResult(FileError::ABORT_ERR); |
| 313 } | 313 } |
| 314 | 314 |
| 315 void start(ExecutionContext*); | 315 void start(ExecutionContext*); |
| 316 | 316 |
| 317 private: | 317 private: |
| 318 bool didHitError(FileError* error) | 318 bool didHitError(FileError* error) |
| 319 { | 319 { |
| 320 reportResult(error->code()); | 320 reportResult(error->code()); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 bool MetadataRequest::didGetMetadata(Metadata* metadata) | 365 bool MetadataRequest::didGetMetadata(Metadata* metadata) |
| 366 { | 366 { |
| 367 using TypeBuilder::FileSystem::Metadata; | 367 using TypeBuilder::FileSystem::Metadata; |
| 368 RefPtr<Metadata> result = Metadata::create() | 368 RefPtr<Metadata> result = Metadata::create() |
| 369 .setModificationTime(metadata->modificationTime()) | 369 .setModificationTime(metadata->modificationTime()) |
| 370 .setSize(metadata->size()); | 370 .setSize(metadata->size()); |
| 371 reportResult(static_cast<FileError::ErrorCode>(0), result); | 371 reportResult(static_cast<FileError::ErrorCode>(0), result); |
| 372 return true; | 372 return true; |
| 373 } | 373 } |
| 374 | 374 |
| 375 class FileContentRequest : public EventListener { | 375 class FileContentRequest FINAL : public EventListener { |
| 376 WTF_MAKE_NONCOPYABLE(FileContentRequest); | 376 WTF_MAKE_NONCOPYABLE(FileContentRequest); |
| 377 public: | 377 public: |
| 378 static PassRefPtr<FileContentRequest> create(PassRefPtr<RequestFileContentCa
llback> requestCallback, const String& url, bool readAsText, long long start, lo
ng long end, const String& charset) | 378 static PassRefPtr<FileContentRequest> create(PassRefPtr<RequestFileContentCa
llback> requestCallback, const String& url, bool readAsText, long long start, lo
ng long end, const String& charset) |
| 379 { | 379 { |
| 380 return adoptRef(new FileContentRequest(requestCallback, url, readAsText,
start, end, charset)); | 380 return adoptRef(new FileContentRequest(requestCallback, url, readAsText,
start, end, charset)); |
| 381 } | 381 } |
| 382 | 382 |
| 383 virtual ~FileContentRequest() | 383 virtual ~FileContentRequest() |
| 384 { | 384 { |
| 385 reportResult(FileError::ABORT_ERR); | 385 reportResult(FileError::ABORT_ERR); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 return; | 489 return; |
| 490 } | 490 } |
| 491 | 491 |
| 492 OwnPtr<TextResourceDecoder> decoder = TextResourceDecoder::create(m_mimeType
, m_charset, true); | 492 OwnPtr<TextResourceDecoder> decoder = TextResourceDecoder::create(m_mimeType
, m_charset, true); |
| 493 String result = decoder->decode(static_cast<char*>(buffer->data()), buffer->
byteLength()); | 493 String result = decoder->decode(static_cast<char*>(buffer->data()), buffer->
byteLength()); |
| 494 result.append(decoder->flush()); | 494 result.append(decoder->flush()); |
| 495 m_charset = decoder->encoding().name(); | 495 m_charset = decoder->encoding().name(); |
| 496 reportResult(static_cast<FileError::ErrorCode>(0), &result, &m_charset); | 496 reportResult(static_cast<FileError::ErrorCode>(0), &result, &m_charset); |
| 497 } | 497 } |
| 498 | 498 |
| 499 class DeleteEntryRequest : public RefCounted<DeleteEntryRequest> { | 499 class DeleteEntryRequest FINAL : public RefCounted<DeleteEntryRequest> { |
| 500 public: | 500 public: |
| 501 static PassRefPtr<DeleteEntryRequest> create(PassRefPtr<DeleteEntryCallback>
requestCallback, const KURL& url) | 501 static PassRefPtr<DeleteEntryRequest> create(PassRefPtr<DeleteEntryCallback>
requestCallback, const KURL& url) |
| 502 { | 502 { |
| 503 return adoptRef(new DeleteEntryRequest(requestCallback, url)); | 503 return adoptRef(new DeleteEntryRequest(requestCallback, url)); |
| 504 } | 504 } |
| 505 | 505 |
| 506 virtual ~DeleteEntryRequest() | 506 ~DeleteEntryRequest() |
| 507 { | 507 { |
| 508 reportResult(FileError::ABORT_ERR); | 508 reportResult(FileError::ABORT_ERR); |
| 509 } | 509 } |
| 510 | 510 |
| 511 void start(ExecutionContext*); | 511 void start(ExecutionContext*); |
| 512 | 512 |
| 513 private: | 513 private: |
| 514 // CallbackDispatcherFactory doesn't handle 0-arg handleEvent methods | 514 // CallbackDispatcherFactory doesn't handle 0-arg handleEvent methods |
| 515 class VoidCallbackImpl : public VoidCallback { | 515 class VoidCallbackImpl FINAL : public VoidCallback { |
| 516 public: | 516 public: |
| 517 explicit VoidCallbackImpl(PassRefPtr<DeleteEntryRequest> handler) | 517 explicit VoidCallbackImpl(PassRefPtr<DeleteEntryRequest> handler) |
| 518 : m_handler(handler) | 518 : m_handler(handler) |
| 519 { | 519 { |
| 520 } | 520 } |
| 521 | 521 |
| 522 virtual void handleEvent() OVERRIDE | 522 virtual void handleEvent() OVERRIDE |
| 523 { | 523 { |
| 524 m_handler->didDeleteEntry(); | 524 m_handler->didDeleteEntry(); |
| 525 } | 525 } |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 720 for (Frame* frame = m_pageAgent->mainFrame(); frame; frame = frame->tree().t
raverseNext()) { | 720 for (Frame* frame = m_pageAgent->mainFrame(); frame; frame = frame->tree().t
raverseNext()) { |
| 721 if (frame->document() && frame->document()->securityOrigin()->isSameSche
meHostPort(origin)) | 721 if (frame->document() && frame->document()->securityOrigin()->isSameSche
meHostPort(origin)) |
| 722 return frame->document(); | 722 return frame->document(); |
| 723 } | 723 } |
| 724 | 724 |
| 725 *error = "No frame is available for the request"; | 725 *error = "No frame is available for the request"; |
| 726 return 0; | 726 return 0; |
| 727 } | 727 } |
| 728 | 728 |
| 729 } // namespace WebCore | 729 } // namespace WebCore |
| OLD | NEW |