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

Side by Side Diff: sky/engine/core/script/dart_library_provider_webview.cc

Issue 1209033016: Remove dead code from DartController (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 5 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 unified diff | Download patch
« no previous file with comments | « sky/engine/core/script/dart_library_provider_webview.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "sky/engine/core/script/dart_library_provider_webview.h"
6
7 #include "sky/engine/platform/fetcher/MojoFetcher.h"
8 #include "sky/engine/platform/weborigin/KURL.h"
9 #include "sky/engine/tonic/dart_converter.h"
10
11 namespace blink {
12
13 class DartLibraryProviderWebView::Job : public MojoFetcher::Client {
14 public:
15 Job(DartLibraryProviderWebView* provider,
16 const String& name,
17 DataPipeConsumerCallback callback)
18 : provider_(provider), callback_(callback) {
19 fetcher_ = adoptPtr(new MojoFetcher(this, KURL(ParsedURLString, name)));
20 }
21
22 ~Job() override {}
23
24 private:
25 void OnReceivedResponse(mojo::URLResponsePtr response) {
26 if (response->status_code != 200) {
27 callback_.Run(mojo::ScopedDataPipeConsumerHandle());
28 } else {
29 callback_.Run(response->body.Pass());
30 }
31 provider_->jobs_.remove(this);
32 // We're deleted now.
33 }
34
35 DartLibraryProviderWebView* provider_;
36 DataPipeConsumerCallback callback_;
37 OwnPtr<MojoFetcher> fetcher_;
38 };
39
40 DartLibraryProviderWebView::DartLibraryProviderWebView() {
41 }
42
43 DartLibraryProviderWebView::~DartLibraryProviderWebView() {
44 }
45
46 void DartLibraryProviderWebView::GetLibraryAsStream(
47 const String& name,
48 DataPipeConsumerCallback callback) {
49 jobs_.add(adoptPtr(new Job(this, name, callback)));
50 }
51
52 Dart_Handle DartLibraryProviderWebView::CanonicalizeURL(Dart_Handle library,
53 Dart_Handle url) {
54 String string = StringFromDart(url);
55 if (string.startsWith("dart:"))
56 return url;
57 // TODO(abarth): The package root should be configurable.
58 if (string.startsWith("package:"))
59 string.replace("package:", "/packages/");
60 String library_url_string = StringFromDart(Dart_LibraryUrl(library));
61 KURL library_url = KURL(ParsedURLString, library_url_string);
62 KURL resolved_url = KURL(library_url, string);
63 return StringToDart(DartState::Current(), resolved_url.string());
64 }
65
66 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/script/dart_library_provider_webview.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698