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

Unified Diff: shell/url_resolver.cc

Issue 868283006: Rename MojoURLResolver to URLResolver (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Fix test Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « shell/url_resolver.h ('k') | shell/url_resolver_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: shell/url_resolver.cc
diff --git a/shell/mojo_url_resolver.cc b/shell/url_resolver.cc
similarity index 52%
rename from shell/mojo_url_resolver.cc
rename to shell/url_resolver.cc
index 9e93aa1142763a71f68a09f947258f07670bf8e8..e1ceb99a113440be2a57974e0462bd6c644d6f05 100644
--- a/shell/mojo_url_resolver.cc
+++ b/shell/url_resolver.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "shell/mojo_url_resolver.h"
+#include "shell/url_resolver.h"
#include "base/base_paths.h"
#include "base/files/file_path.h"
@@ -13,43 +13,22 @@
namespace mojo {
namespace shell {
-MojoURLResolver::MojoURLResolver() {
+URLResolver::URLResolver() {
// Needed to treat first component of mojo URLs as host, not path.
url::AddStandardScheme("mojo");
}
-MojoURLResolver::~MojoURLResolver() {
+URLResolver::~URLResolver() {
}
-void MojoURLResolver::SetBaseURL(const GURL& base_url) {
- DCHECK(base_url.is_valid());
- // Force a trailing slash on the base_url to simplify resolving
- // relative files and URLs below.
- base_url_ = AddTrailingSlashIfNeeded(base_url);
-}
-
-void MojoURLResolver::AddCustomMapping(const GURL& mojo_url,
- const GURL& resolved_url) {
- url_map_[mojo_url] = resolved_url;
-}
-
-GURL MojoURLResolver::Resolve(const GURL& mojo_url) const {
- const GURL mapped_url(ApplyCustomMappings(mojo_url));
-
- if (mapped_url.scheme() != "mojo") {
- // The mapping has produced some sort of non-mojo: URL - file:, http:, etc.
- return mapped_url;
- } else {
- // It's still a mojo: URL, use the default mapping scheme.
- std::string lib = mapped_url.host() + ".mojo";
- return base_url_.Resolve(lib);
- }
+void URLResolver::AddURLMapping(const GURL& url, const GURL& resolved_url) {
+ url_map_[url] = resolved_url;
}
-GURL MojoURLResolver::ApplyCustomMappings(const GURL& url) const {
+GURL URLResolver::ApplyURLMappings(const GURL& url) const {
GURL mapped_url(url);
for (;;) {
- std::map<GURL, GURL>::const_iterator it = url_map_.find(mapped_url);
+ const auto& it = url_map_.find(mapped_url);
if (it == url_map_.end())
break;
mapped_url = it->second;
@@ -57,5 +36,23 @@ GURL MojoURLResolver::ApplyCustomMappings(const GURL& url) const {
return mapped_url;
}
+void URLResolver::SetMojoBaseURL(const GURL& mojo_base_url) {
+ DCHECK(mojo_base_url.is_valid());
+ // Force a trailing slash on the base_url to simplify resolving
+ // relative files and URLs below.
+ mojo_base_url_ = AddTrailingSlashIfNeeded(mojo_base_url);
+}
+
+GURL URLResolver::ResolveMojoURL(const GURL& mojo_url) const {
+ if (mojo_url.scheme() != "mojo") {
+ // The mapping has produced some sort of non-mojo: URL - file:, http:, etc.
+ return mojo_url;
+ } else {
+ // It's still a mojo: URL, use the default mapping scheme.
+ std::string lib = mojo_url.host() + ".mojo";
+ return mojo_base_url_.Resolve(lib);
+ }
+}
+
} // namespace shell
} // namespace mojo
« no previous file with comments | « shell/url_resolver.h ('k') | shell/url_resolver_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698