| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions are | |
| 6 * met: | |
| 7 * | |
| 8 * * Redistributions of source code must retain the above copyright | |
| 9 * notice, this list of conditions and the following disclaimer. | |
| 10 * * Redistributions in binary form must reproduce the above | |
| 11 * copyright notice, this list of conditions and the following disclaimer | |
| 12 * in the documentation and/or other materials provided with the | |
| 13 * distribution. | |
| 14 * * Neither the name of Google Inc. nor the names of its | |
| 15 * contributors may be used to endorse or promote products derived from | |
| 16 * this software without specific prior written permission. | |
| 17 * | |
| 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 29 */ | |
| 30 | |
| 31 #ifndef SKY_ENGINE_CORE_HTML_IMPORTS_HTMLIMPORTLOADER_H_ | |
| 32 #define SKY_ENGINE_CORE_HTML_IMPORTS_HTMLIMPORTLOADER_H_ | |
| 33 | |
| 34 #include "sky/engine/platform/fetcher/MojoFetcher.h" | |
| 35 #include "sky/engine/platform/heap/Handle.h" | |
| 36 #include "sky/engine/wtf/OwnPtr.h" | |
| 37 #include "sky/engine/wtf/PassOwnPtr.h" | |
| 38 #include "sky/engine/wtf/Vector.h" | |
| 39 | |
| 40 namespace blink { | |
| 41 | |
| 42 class Document; | |
| 43 class HTMLImportChild; | |
| 44 class HTMLImportsController; | |
| 45 class Module; | |
| 46 | |
| 47 class HTMLImportLoader final : public MojoFetcher::Client { | |
| 48 public: | |
| 49 enum State { | |
| 50 StateLoading, | |
| 51 StateWritten, | |
| 52 StateParsed, | |
| 53 StateLoaded, | |
| 54 StateError | |
| 55 }; | |
| 56 | |
| 57 static PassOwnPtr<HTMLImportLoader> create(HTMLImportsController* controller
) | |
| 58 { | |
| 59 return adoptPtr(new HTMLImportLoader(controller)); | |
| 60 } | |
| 61 | |
| 62 virtual ~HTMLImportLoader(); | |
| 63 | |
| 64 Document* document() const { return m_document.get(); } | |
| 65 Module* module() const { return m_module.get(); } | |
| 66 | |
| 67 void addImport(HTMLImportChild*); | |
| 68 #if !ENABLE(OILPAN) | |
| 69 void removeImport(HTMLImportChild*); | |
| 70 #endif | |
| 71 void moveToFirst(HTMLImportChild*); | |
| 72 HTMLImportChild* firstImport() const { return m_imports[0]; } | |
| 73 bool isFirstImport(const HTMLImportChild* child) const { return m_imports.si
ze() ? firstImport() == child : false; } | |
| 74 | |
| 75 bool isDone() const { return m_state == StateLoaded || m_state == StateError
; } | |
| 76 bool hasError() const { return m_state == StateError; } | |
| 77 bool shouldBlockScriptExecution() const; | |
| 78 | |
| 79 #if !ENABLE(OILPAN) | |
| 80 void importDestroyed(); | |
| 81 #endif | |
| 82 void startLoading(const KURL&); | |
| 83 | |
| 84 // Tells the loader that the parser is done with this import. | |
| 85 // Called by Document::finishedParsing, after DOMContentLoaded was dispatche
d. | |
| 86 void didFinishParsing(); | |
| 87 | |
| 88 private: | |
| 89 HTMLImportLoader(HTMLImportsController*); | |
| 90 | |
| 91 // MojoFetcher::Client | |
| 92 void OnReceivedResponse(mojo::URLResponsePtr) override; | |
| 93 | |
| 94 State startWritingAndParsing(mojo::URLResponsePtr); | |
| 95 State finishWriting(); | |
| 96 State finishParsing(); | |
| 97 State finishLoading(); | |
| 98 | |
| 99 void setState(State); | |
| 100 void didFinishLoading(); | |
| 101 #if !ENABLE(OILPAN) | |
| 102 void clear(); | |
| 103 #endif | |
| 104 | |
| 105 RawPtr<HTMLImportsController> m_controller; | |
| 106 Vector<RawPtr<HTMLImportChild> > m_imports; | |
| 107 State m_state; | |
| 108 RefPtr<Module> m_module; | |
| 109 RefPtr<Document> m_document; | |
| 110 | |
| 111 OwnPtr<MojoFetcher> m_fetcher; | |
| 112 }; | |
| 113 | |
| 114 } // namespace blink | |
| 115 | |
| 116 #endif // SKY_ENGINE_CORE_HTML_IMPORTS_HTMLIMPORTLOADER_H_ | |
| OLD | NEW |