| 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 18 matching lines...) Expand all Loading... |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "modules/filesystem/InspectorFileSystemAgent.h" | 31 #include "modules/filesystem/InspectorFileSystemAgent.h" |
| 32 | 32 |
| 33 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 33 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
| 34 #include "bindings/core/v8/UnionTypesCore.h" | 34 #include "bindings/core/v8/UnionTypesCore.h" |
| 35 #include "core/dom/DOMArrayBuffer.h" | 35 #include "core/dom/DOMArrayBuffer.h" |
| 36 #include "core/dom/DOMImplementation.h" | 36 #include "core/dom/DOMImplementation.h" |
| 37 #include "core/dom/Document.h" | 37 #include "core/dom/Document.h" |
| 38 #include "core/events/Event.h" | 38 #include "core/events/Event.h" |
| 39 #include "core/fileapi/BlobCallback.h" |
| 39 #include "core/fileapi/File.h" | 40 #include "core/fileapi/File.h" |
| 40 #include "core/fileapi/FileCallback.h" | |
| 41 #include "core/fileapi/FileError.h" | 41 #include "core/fileapi/FileError.h" |
| 42 #include "core/fileapi/FileReader.h" | 42 #include "core/fileapi/FileReader.h" |
| 43 #include "core/frame/LocalFrame.h" | 43 #include "core/frame/LocalFrame.h" |
| 44 #include "core/html/HTMLMediaElement.h" | 44 #include "core/html/HTMLMediaElement.h" |
| 45 #include "core/html/VoidCallback.h" | 45 #include "core/html/VoidCallback.h" |
| 46 #include "core/html/parser/TextResourceDecoder.h" | 46 #include "core/html/parser/TextResourceDecoder.h" |
| 47 #include "core/inspector/InspectedFrames.h" | 47 #include "core/inspector/InspectedFrames.h" |
| 48 #include "core/inspector/InspectorState.h" | 48 #include "core/inspector/InspectorState.h" |
| 49 #include "modules/filesystem/DOMFileSystem.h" | 49 #include "modules/filesystem/DOMFileSystem.h" |
| 50 #include "modules/filesystem/DirectoryEntry.h" | 50 #include "modules/filesystem/DirectoryEntry.h" |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 } | 433 } |
| 434 | 434 |
| 435 private: | 435 private: |
| 436 bool didHitError(FileError* error) | 436 bool didHitError(FileError* error) |
| 437 { | 437 { |
| 438 reportResult(error->code()); | 438 reportResult(error->code()); |
| 439 return true; | 439 return true; |
| 440 } | 440 } |
| 441 | 441 |
| 442 bool didGetEntry(Entry*); | 442 bool didGetEntry(Entry*); |
| 443 bool didGetFile(File*); | 443 bool didGetFile(Blob*); |
| 444 void didRead(); | 444 void didRead(); |
| 445 | 445 |
| 446 void reportResult(FileError::ErrorCode errorCode, const String* result = 0,
const String* charset = 0) | 446 void reportResult(FileError::ErrorCode errorCode, const String* result = 0,
const String* charset = 0) |
| 447 { | 447 { |
| 448 m_requestCallback->sendSuccess(static_cast<int>(errorCode), result, char
set); | 448 m_requestCallback->sendSuccess(static_cast<int>(errorCode), result, char
set); |
| 449 } | 449 } |
| 450 | 450 |
| 451 FileContentRequest(PassRefPtrWillBeRawPtr<RequestFileContentCallback> reques
tCallback, const String& url, bool readAsText, long long start, long long end, c
onst String& charset) | 451 FileContentRequest(PassRefPtrWillBeRawPtr<RequestFileContentCallback> reques
tCallback, const String& url, bool readAsText, long long start, long long end, c
onst String& charset) |
| 452 : EventListener(EventListener::CPPEventListenerType) | 452 : EventListener(EventListener::CPPEventListenerType) |
| 453 , m_requestCallback(requestCallback) | 453 , m_requestCallback(requestCallback) |
| (...skipping 30 matching lines...) Expand all Loading... |
| 484 if (entry->isDirectory()) { | 484 if (entry->isDirectory()) { |
| 485 reportResult(FileError::TYPE_MISMATCH_ERR); | 485 reportResult(FileError::TYPE_MISMATCH_ERR); |
| 486 return true; | 486 return true; |
| 487 } | 487 } |
| 488 | 488 |
| 489 if (!entry->filesystem()->executionContext()) { | 489 if (!entry->filesystem()->executionContext()) { |
| 490 reportResult(FileError::ABORT_ERR); | 490 reportResult(FileError::ABORT_ERR); |
| 491 return true; | 491 return true; |
| 492 } | 492 } |
| 493 | 493 |
| 494 FileCallback* successCallback = CallbackDispatcherFactory<FileCallback>::cre
ate(this, &FileContentRequest::didGetFile); | 494 BlobCallback* successCallback = CallbackDispatcherFactory<BlobCallback>::cre
ate(this, &FileContentRequest::didGetFile); |
| 495 ErrorCallback* errorCallback = CallbackDispatcherFactory<ErrorCallback>::cre
ate(this, &FileContentRequest::didHitError); | 495 ErrorCallback* errorCallback = CallbackDispatcherFactory<ErrorCallback>::cre
ate(this, &FileContentRequest::didHitError); |
| 496 toFileEntry(entry)->file(successCallback, errorCallback); | 496 toFileEntry(entry)->file(successCallback, errorCallback); |
| 497 | 497 |
| 498 m_reader = FileReader::create(entry->filesystem()->executionContext()); | 498 m_reader = FileReader::create(entry->filesystem()->executionContext()); |
| 499 m_mimeType = MIMETypeRegistry::getMIMETypeForPath(entry->name()); | 499 m_mimeType = MIMETypeRegistry::getMIMETypeForPath(entry->name()); |
| 500 | 500 |
| 501 return true; | 501 return true; |
| 502 } | 502 } |
| 503 | 503 |
| 504 bool FileContentRequest::didGetFile(File* file) | 504 bool FileContentRequest::didGetFile(Blob* file) |
| 505 { | 505 { |
| 506 Blob* blob = file->Blob::slice(m_start, m_end, IGNORE_EXCEPTION); | 506 Blob* blob = file->slice(m_start, m_end, IGNORE_EXCEPTION); |
| 507 m_reader->setOnload(this); | 507 m_reader->setOnload(this); |
| 508 m_reader->setOnerror(this); | 508 m_reader->setOnerror(this); |
| 509 | 509 |
| 510 m_reader->readAsArrayBuffer(blob, IGNORE_EXCEPTION); | 510 m_reader->readAsArrayBuffer(blob, IGNORE_EXCEPTION); |
| 511 return true; | 511 return true; |
| 512 } | 512 } |
| 513 | 513 |
| 514 void FileContentRequest::didRead() | 514 void FileContentRequest::didRead() |
| 515 { | 515 { |
| 516 StringOrArrayBuffer resultAttribute; | 516 StringOrArrayBuffer resultAttribute; |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 return 0; | 762 return 0; |
| 763 } | 763 } |
| 764 | 764 |
| 765 DEFINE_TRACE(InspectorFileSystemAgent) | 765 DEFINE_TRACE(InspectorFileSystemAgent) |
| 766 { | 766 { |
| 767 visitor->trace(m_inspectedFrames); | 767 visitor->trace(m_inspectedFrames); |
| 768 InspectorBaseAgent::trace(visitor); | 768 InspectorBaseAgent::trace(visitor); |
| 769 } | 769 } |
| 770 | 770 |
| 771 } // namespace blink | 771 } // namespace blink |
| OLD | NEW |