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

Side by Side Diff: tonic/dart_library_provider_files.cc

Issue 1641513004: Update //base to chromium 9659b08ea5a34f889dc4166217f438095ddc10d2 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 10 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 | « third_party/zlib/google/zip_reader.cc ('k') | tonic/dart_library_provider_network.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 "tonic/dart_library_provider_files.h" 5 #include "tonic/dart_library_provider_files.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 callback.Run(pipe.consumer_handle.Pass()); 55 callback.Run(pipe.consumer_handle.Pass());
56 56
57 base::FilePath source(name); 57 base::FilePath source(name);
58 scoped_refptr<base::SingleThreadTaskRunner> runner = 58 scoped_refptr<base::SingleThreadTaskRunner> runner =
59 base::MessageLoop::current()->task_runner(); 59 base::MessageLoop::current()->task_runner();
60 mojo::common::CopyFromFile(source, pipe.producer_handle.Pass(), 0, 60 mojo::common::CopyFromFile(source, pipe.producer_handle.Pass(), 0,
61 runner.get(), base::Bind(&CopyComplete, source)); 61 runner.get(), base::Bind(&CopyComplete, source));
62 } 62 }
63 63
64 std::string DartLibraryProviderFiles::CanonicalizePackageURL(std::string url) { 64 std::string DartLibraryProviderFiles::CanonicalizePackageURL(std::string url) {
65 DCHECK(StartsWithASCII(url, "package:", true)); 65 DCHECK(base::StartsWithASCII(url, "package:", true));
66 ReplaceFirstSubstringAfterOffset(&url, 0, "package:", ""); 66 base::ReplaceFirstSubstringAfterOffset(&url, 0, "package:", "");
67 return package_root_.Append(url).AsUTF8Unsafe(); 67 return package_root_.Append(url).AsUTF8Unsafe();
68 } 68 }
69 69
70 Dart_Handle DartLibraryProviderFiles::CanonicalizeURL(Dart_Handle library, 70 Dart_Handle DartLibraryProviderFiles::CanonicalizeURL(Dart_Handle library,
71 Dart_Handle url) { 71 Dart_Handle url) {
72 std::string string = StdStringFromDart(url); 72 std::string string = StdStringFromDart(url);
73 if (StartsWithASCII(string, "dart:", true)) 73 if (base::StartsWithASCII(string, "dart:", true))
74 return url; 74 return url;
75 if (StartsWithASCII(string, "package:", true)) 75 if (base::StartsWithASCII(string, "package:", true))
76 return StdStringToDart(CanonicalizePackageURL(string)); 76 return StdStringToDart(CanonicalizePackageURL(string));
77 base::FilePath base_path(StdStringFromDart(Dart_LibraryUrl(library))); 77 base::FilePath base_path(StdStringFromDart(Dart_LibraryUrl(library)));
78 base::FilePath resolved_path = base_path.DirName().Append(string); 78 base::FilePath resolved_path = base_path.DirName().Append(string);
79 base::FilePath normalized_path = SimplifyPath(resolved_path); 79 base::FilePath normalized_path = SimplifyPath(resolved_path);
80 return StdStringToDart(normalized_path.AsUTF8Unsafe()); 80 return StdStringToDart(normalized_path.AsUTF8Unsafe());
81 } 81 }
82 82
83 } // namespace tonic 83 } // namespace tonic
OLDNEW
« no previous file with comments | « third_party/zlib/google/zip_reader.cc ('k') | tonic/dart_library_provider_network.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698