diff --git a/engine/core/loader/MojoLoader.cpp b/engine/core/loader/MojoLoader.cpp index d5939881127..307b34090c5 100644 --- a/engine/core/loader/MojoLoader.cpp +++ b/engine/core/loader/MojoLoader.cpp @@ -17,15 +17,12 @@ namespace blink { -using namespace mojo; - MojoLoader::MojoLoader(LocalFrame& frame) : m_frame(frame) { } -void MojoLoader::load(const KURL& url, ScopedDataPipeConsumerHandle responseStream) -{ +void MojoLoader::init(const KURL& url) { DocumentInit init(url, &m_frame); // FIXME(sky): Poorly named method for creating the FrameView: @@ -40,8 +37,11 @@ void MojoLoader::load(const KURL& url, ScopedDataPipeConsumerHandle responseStre document->setReadyState(Document::Loading); // FIXME: This should read the Content-Language out of the // response headers and set them on Document::contentLanguage. +} - document->startParsing()->parse(responseStream.Pass(), base::Bind(base::DoNothing)); +void MojoLoader::parse(mojo::ScopedDataPipeConsumerHandle responseStream) { + m_frame.document()->startParsing()->parse(responseStream.Pass(), + base::Bind(base::DoNothing)); } } diff --git a/engine/core/loader/MojoLoader.h b/engine/core/loader/MojoLoader.h index 33f273c91bb..616182e449e 100644 --- a/engine/core/loader/MojoLoader.h +++ b/engine/core/loader/MojoLoader.h @@ -16,7 +16,8 @@ class MojoLoader { public: explicit MojoLoader(LocalFrame&); - void load(const KURL&, mojo::ScopedDataPipeConsumerHandle); + void init(const KURL&); + void parse(mojo::ScopedDataPipeConsumerHandle); private: LocalFrame& m_frame; diff --git a/engine/public/web/WebFrame.h b/engine/public/web/WebFrame.h index df747da8279..ba00e8c0b80 100644 --- a/engine/public/web/WebFrame.h +++ b/engine/public/web/WebFrame.h @@ -134,7 +134,9 @@ public: // Navigation ---------------------------------------------------------- - virtual void load(const WebURL&, mojo::ScopedDataPipeConsumerHandle) = 0; + virtual void load(const WebURL&) = 0; + + virtual void loadFromDataPipeWithURL(mojo::ScopedDataPipeConsumerHandle, const WebURL&) = 0; // Editing ------------------------------------------------------------- diff --git a/engine/web/WebLocalFrameImpl.cpp b/engine/web/WebLocalFrameImpl.cpp index 08e46fd0f2d..cb290495c3f 100644 --- a/engine/web/WebLocalFrameImpl.cpp +++ b/engine/web/WebLocalFrameImpl.cpp @@ -257,9 +257,24 @@ void WebLocalFrameImpl::collectGarbage() // TODO(dart): Implement. } -void WebLocalFrameImpl::load(const WebURL& url, mojo::ScopedDataPipeConsumerHandle responseStream) +void WebLocalFrameImpl::loadFromDataPipeWithURL(mojo::ScopedDataPipeConsumerHandle responseStream, const WebURL& url) { - frame()->mojoLoader().load(url, responseStream.Pass()); + frame()->mojoLoader().init(url); + frame()->mojoLoader().parse(responseStream.Pass()); +} + +void WebLocalFrameImpl::load(const WebURL& url) +{ + frame()->mojoLoader().init(url); + m_fetcher = adoptPtr(new MojoFetcher(this, url)); +} + +void WebLocalFrameImpl::OnReceivedResponse(mojo::URLResponsePtr response) +{ + m_fetcher.clear(); + if (!response->body.is_valid()) + LOG(FATAL) << "Response has no body."; + frame()->mojoLoader().parse(response->body.Pass()); } void WebLocalFrameImpl::replaceSelection(const WebString& text) diff --git a/engine/web/WebLocalFrameImpl.h b/engine/web/WebLocalFrameImpl.h index 9d31f669665..1f0f4f9d171 100644 --- a/engine/web/WebLocalFrameImpl.h +++ b/engine/web/WebLocalFrameImpl.h @@ -32,6 +32,7 @@ #define SKY_ENGINE_WEB_WEBLOCALFRAMEIMPL_H_ #include "sky/engine/core/frame/LocalFrame.h" +#include "sky/engine/platform/fetcher/MojoFetcher.h" #include "sky/engine/platform/geometry/FloatRect.h" #include "sky/engine/public/web/WebLocalFrame.h" #include "sky/engine/web/FrameLoaderClientImpl.h" @@ -56,6 +57,7 @@ template class WebVector; // Implementation of WebFrame, note that this is a reference counted object. class WebLocalFrameImpl final : public WebLocalFrame + , public MojoFetcher::Client , public RefCounted { public: // WebFrame methods: @@ -70,7 +72,8 @@ public: virtual void executeScript(const WebScriptSource&) override; virtual void addMessageToConsole(const WebConsoleMessage&) override; virtual void collectGarbage() override; - virtual void load(const WebURL&, mojo::ScopedDataPipeConsumerHandle); + virtual void load(const WebURL&); + virtual void loadFromDataPipeWithURL(mojo::ScopedDataPipeConsumerHandle, const WebURL&); virtual void replaceSelection(const WebString&) override; virtual void insertText(const WebString&) override; virtual void setMarkedText(const WebString&, unsigned location, unsigned length) override; @@ -137,6 +140,9 @@ private: // Sets the local core frame and registers destruction observers. void setCoreFrame(PassRefPtr); + // MojoFetcher::Client + void OnReceivedResponse(mojo::URLResponsePtr) override; + FrameLoaderClientImpl m_frameLoaderClientImpl; // The embedder retains a reference to the WebCore LocalFrame while it is active in the DOM. This @@ -145,6 +151,7 @@ private: RefPtr m_frame; WebFrameClient* m_client; + OwnPtr m_fetcher; // Stores the additional input events offset and scale when device metrics emulation is enabled. IntSize m_inputEventsOffsetForEmulation; diff --git a/viewer/document_view.cc b/viewer/document_view.cc index 30ea4080968..e6fc4fa3ded 100644 --- a/viewer/document_view.cc +++ b/viewer/document_view.cc @@ -151,7 +151,8 @@ void DocumentView::Load(mojo::URLResponsePtr response) { web_view_ = blink::WebView::create(this); ConfigureSettings(web_view_->settings()); web_view_->setMainFrame(blink::WebLocalFrame::create(this)); - web_view_->mainFrame()->load(GURL(response->url), response->body.Pass()); + web_view_->mainFrame()->loadFromDataPipeWithURL( + response->body.Pass(), GURL(response->url)); } void DocumentView::initializeLayerTreeView() {