| 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 "tonic/dart_library_provider_network.h" | 5 #include "tonic/dart_library_provider_network.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "tonic/dart_converter.h" | 9 #include "tonic/dart_converter.h" |
| 10 #include "url/gurl.h" | 10 #include "url/gurl.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 74 |
| 75 void DartLibraryProviderNetwork::GetLibraryAsStream( | 75 void DartLibraryProviderNetwork::GetLibraryAsStream( |
| 76 const std::string& name, | 76 const std::string& name, |
| 77 DataPipeConsumerCallback callback) { | 77 DataPipeConsumerCallback callback) { |
| 78 jobs_.insert(std::unique_ptr<Job>(new Job(this, name, callback))); | 78 jobs_.insert(std::unique_ptr<Job>(new Job(this, name, callback))); |
| 79 } | 79 } |
| 80 | 80 |
| 81 Dart_Handle DartLibraryProviderNetwork::CanonicalizeURL(Dart_Handle library, | 81 Dart_Handle DartLibraryProviderNetwork::CanonicalizeURL(Dart_Handle library, |
| 82 Dart_Handle url) { | 82 Dart_Handle url) { |
| 83 std::string string = StdStringFromDart(url); | 83 std::string string = StdStringFromDart(url); |
| 84 if (base::StartsWithASCII(string, "dart:", true)) | 84 if (base::StartsWith(string, "dart:", base::CompareCase::SENSITIVE)) |
| 85 return url; | 85 return url; |
| 86 // TODO(abarth): The package root should be configurable. | 86 // TODO(abarth): The package root should be configurable. |
| 87 if (base::StartsWithASCII(string, "package:", true)) | 87 if (base::StartsWith(string, "package:", base::CompareCase::SENSITIVE)) |
| 88 base::ReplaceFirstSubstringAfterOffset(&string, 0, "package:", | 88 base::ReplaceFirstSubstringAfterOffset(&string, 0, "package:", |
| 89 "/packages/"); | 89 "/packages/"); |
| 90 GURL library_url(StdStringFromDart(Dart_LibraryUrl(library))); | 90 GURL library_url(StdStringFromDart(Dart_LibraryUrl(library))); |
| 91 GURL resolved_url = library_url.Resolve(string); | 91 GURL resolved_url = library_url.Resolve(string); |
| 92 return StdStringToDart(resolved_url.spec()); | 92 return StdStringToDart(resolved_url.spec()); |
| 93 } | 93 } |
| 94 | 94 |
| 95 } // namespace tonic | 95 } // namespace tonic |
| OLD | NEW |