Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2278)

Unified Diff: sky/viewer/document_view.cc

Issue 1203143004: Make it possible to run Sky apps offline (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: gn check Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/viewer/document_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/viewer/document_view.cc
diff --git a/sky/viewer/document_view.cc b/sky/viewer/document_view.cc
index 1e0bb78e79b891abcda5b8d726eaebb3513b55e2..9e22009d38b412b1895f15db778a03a368515f10 100644
--- a/sky/viewer/document_view.cc
+++ b/sky/viewer/document_view.cc
@@ -36,13 +36,13 @@
#include "sky/engine/public/web/WebView.h"
#include "sky/services/platform/url_request_types.h"
#include "sky/viewer/converters/input_event_types.h"
+#include "sky/viewer/dart_library_provider_impl.h"
#include "sky/viewer/internals.h"
#include "sky/viewer/runtime_flags.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkColor.h"
#include "third_party/skia/include/core/SkDevice.h"
#include "ui/events/gestures/gesture_recognizer.h"
-#include "v8/include/v8.h"
namespace sky {
namespace {
@@ -94,6 +94,18 @@ scoped_ptr<ui::TouchEvent> ConvertToUITouchEvent(
base::TimeDelta::FromMillisecondsD(pointer_event.timeStampMS)));
}
+scoped_ptr<DartLibraryProviderImpl::PrefetchedLibrary>
+CreatePrefetchedLibraryIfNeeded(const String& name,
+ mojo::URLResponsePtr response) {
+ scoped_ptr<DartLibraryProviderImpl::PrefetchedLibrary> prefetched;
+ if (response->status_code == 200) {
+ prefetched.reset(new DartLibraryProviderImpl::PrefetchedLibrary());
+ prefetched->name = name;
+ prefetched->pipe = response->body.Pass();
+ }
+ return prefetched.Pass();
+}
+
} // namespace
DocumentView::DocumentView(
@@ -161,9 +173,13 @@ void DocumentView::Load(mojo::URLResponsePtr response) {
GURL responseURL(response->url);
if (!blink::WebView::shouldUseWebView(responseURL)) {
+ String name = String::fromUTF8(responseURL.spec());
+ library_provider_.reset(new DartLibraryProviderImpl(
+ blink::Platform::current()->networkService(),
+ CreatePrefetchedLibraryIfNeeded(name, response.Pass())));
sky_view_ = blink::SkyView::Create(this);
initializeLayerTreeView();
- sky_view_->Load(responseURL, response.Pass());
+ sky_view_->RunFromLibrary(name, library_provider_.get());
return;
}
« no previous file with comments | « sky/viewer/document_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698