OLD | NEW |
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" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 Dart_Handle result = Dart_LoadSource(library, url, source, 0, 0); | 86 Dart_Handle result = Dart_LoadSource(library, url, source, 0, 0); |
87 LogIfError(result); | 87 LogIfError(result); |
88 return result; | 88 return result; |
89 } | 89 } |
90 | 90 |
91 Loader* g_loader = nullptr; | 91 Loader* g_loader = nullptr; |
92 | 92 |
93 Loader& GetLoader() { | 93 Loader& GetLoader() { |
94 if (!g_loader) { | 94 if (!g_loader) { |
95 base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); | 95 base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); |
96 CHECK(command_line.HasSwitch(kPackageRoot)) << "Need --package-root"; | 96 CHECK(command_line.HasSwitch(switches::kPackageRoot)) |
97 g_loader = new Loader(command_line.GetSwitchValuePath(kPackageRoot)); | 97 << "Need --package-root"; |
| 98 g_loader = |
| 99 new Loader(command_line.GetSwitchValuePath(switches::kPackageRoot)); |
98 } | 100 } |
99 return *g_loader; | 101 return *g_loader; |
100 } | 102 } |
101 | 103 |
102 } // namespace | 104 } // namespace |
103 | 105 |
104 Dart_Handle HandleLibraryTag(Dart_LibraryTag tag, | 106 Dart_Handle HandleLibraryTag(Dart_LibraryTag tag, |
105 Dart_Handle library, | 107 Dart_Handle library, |
106 Dart_Handle url) { | 108 Dart_Handle url) { |
107 CHECK(Dart_IsLibrary(library)); | 109 CHECK(Dart_IsLibrary(library)); |
108 CHECK(Dart_IsString(url)); | 110 CHECK(Dart_IsString(url)); |
109 | 111 |
110 if (tag == Dart_kCanonicalizeUrl) | 112 if (tag == Dart_kCanonicalizeUrl) |
111 return GetLoader().CanonicalizeURL(library, url); | 113 return GetLoader().CanonicalizeURL(library, url); |
112 | 114 |
113 if (tag == Dart_kImportTag) | 115 if (tag == Dart_kImportTag) |
114 return GetLoader().Import(url); | 116 return GetLoader().Import(url); |
115 | 117 |
116 if (tag == Dart_kSourceTag) | 118 if (tag == Dart_kSourceTag) |
117 return GetLoader().Source(library, url); | 119 return GetLoader().Source(library, url); |
118 | 120 |
119 return Dart_NewApiError("Unknown library tag."); | 121 return Dart_NewApiError("Unknown library tag."); |
120 } | 122 } |
121 | 123 |
122 void LoadScript(const std::string& url) { | 124 void LoadScript(const std::string& url) { |
123 LogIfError( | 125 LogIfError( |
124 Dart_LoadScript(StringToDart(url), StringToDart(Fetch(url)), 0, 0)); | 126 Dart_LoadScript(StringToDart(url), StringToDart(Fetch(url)), 0, 0)); |
125 } | 127 } |
OLD | NEW |