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

Side by Side Diff: sky/tools/packager/loader.cc

Issue 1197133004: Add support for snapshot loading to Sky (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Fix mirror-system.sky 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 unified diff | Download patch
« no previous file with comments | « sky/tools/packager/loader.h ('k') | sky/tools/packager/vm.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "sky/tools/packager/loader.h" 5 #include "sky/tools/packager/loader.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "sky/tools/packager/logging.h" 12 #include "sky/tools/packager/logging.h"
13 #include "sky/tools/packager/scope.h" 13 #include "sky/tools/packager/scope.h"
14 #include "sky/tools/packager/switches.h" 14 #include "sky/tools/packager/switches.h"
15 15
16 namespace { 16 namespace {
17 17
18 static const char kSkyInternalsLibraryName[] = "dart:sky.internals";
19 static const char kSkyInternalsURL[] = "package:sky/internals.dart";
20
21 std::string Fetch(const std::string& url) { 18 std::string Fetch(const std::string& url) {
22 base::FilePath path(url); 19 base::FilePath path(url);
23 std::string source; 20 std::string source;
24 CHECK(base::ReadFileToString(path, &source)) << url; 21 CHECK(base::ReadFileToString(path, &source)) << url;
25 return source; 22 return source;
26 } 23 }
27 24
28 base::FilePath SimplifyPath(const base::FilePath& path) { 25 base::FilePath SimplifyPath(const base::FilePath& path) {
29 std::vector<base::FilePath::StringType> components; 26 std::vector<base::FilePath::StringType> components;
30 path.GetComponents(&components); 27 path.GetComponents(&components);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 112
116 if (tag == Dart_kImportTag) 113 if (tag == Dart_kImportTag)
117 return GetLoader().Import(url); 114 return GetLoader().Import(url);
118 115
119 if (tag == Dart_kSourceTag) 116 if (tag == Dart_kSourceTag)
120 return GetLoader().Source(library, url); 117 return GetLoader().Source(library, url);
121 118
122 return Dart_NewApiError("Unknown library tag."); 119 return Dart_NewApiError("Unknown library tag.");
123 } 120 }
124 121
125 void LoadSkyInternals() {
126 DartApiScope api_scope;
127
128 Dart_Handle library_name = StringToDart(kSkyInternalsLibraryName);
129 std::string url = GetLoader().CanonicalizePackageURL(kSkyInternalsURL);
130 LogIfError(Dart_LoadLibrary(library_name, StringToDart(Fetch(url)), 0, 0));
131 }
132
133 void LoadScript(const std::string& url) { 122 void LoadScript(const std::string& url) {
134 LogIfError( 123 LogIfError(
135 Dart_LoadScript(StringToDart(url), StringToDart(Fetch(url)), 0, 0)); 124 Dart_LoadScript(StringToDart(url), StringToDart(Fetch(url)), 0, 0));
136 } 125 }
OLDNEW
« no previous file with comments | « sky/tools/packager/loader.h ('k') | sky/tools/packager/vm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698