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

Side by Side Diff: mojo/shell/mojo_url_resolver.h

Issue 782013002: Android: decouple mojo shell from the network service. (Closed) Base URL: https://github.com/domokit/mojo.git@build-rule-for-the-network-service
Patch Set: Created 6 years 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef MOJO_SHELL_MOJO_URL_RESOLVER_H_ 5 #ifndef MOJO_SHELL_MOJO_URL_RESOLVER_H_
6 #define MOJO_SHELL_MOJO_URL_RESOLVER_H_ 6 #define MOJO_SHELL_MOJO_URL_RESOLVER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/files/file_path.h"
12 #include "url/gurl.h" 13 #include "url/gurl.h"
13 14
14 namespace mojo { 15 namespace mojo {
15 namespace shell { 16 namespace shell {
16 17
17 // This class resolves "mojo:" URLs to physical URLs (e.g., "file:" and 18 // This class resolves "mojo:" URLs to physical URLs (e.g., "file:" and
18 // "https:" URLs). By default, "mojo:" URLs resolve to a file location, but 19 // "https:" URLs). By default, "mojo:" URLs resolve to a file location, but
19 // that resolution can be customized via the AddCustomMapping method. 20 // that resolution can be customized via the AddCustomMapping method.
20 class MojoURLResolver { 21 class MojoURLResolver {
21 public: 22 public:
22 MojoURLResolver(); 23 MojoURLResolver();
23 ~MojoURLResolver(); 24 ~MojoURLResolver();
24 25
25 // If specified, then unknown "mojo:" URLs will be resolved relative to this 26 // If specified, then unknown "mojo:" URLs will be resolved relative to this
26 // base URL. That is, the portion after the colon will be appeneded to 27 // base URL. That is, the portion after the colon will be appeneded to
27 // |base_url| with platform-specific shared library prefix and suffix 28 // |base_url| with platform-specific shared library prefix and suffix
28 // inserted. 29 // inserted.
29 void SetBaseURL(const GURL& base_url); 30 void SetBaseURL(const GURL& base_url);
30 31
32 // Set the location of applications bundled with the Mojo Shell.
33 void SetLocalAppsPath(const base::FilePath& local_apps_path);
34
31 // Add a custom mapping for a particular "mojo:" URL. If |resolved_url| is 35 // Add a custom mapping for a particular "mojo:" URL. If |resolved_url| is
32 // itself a mojo url normal resolution rules apply. 36 // itself a mojo url normal resolution rules apply.
33 void AddCustomMapping(const GURL& mojo_url, const GURL& resolved_url); 37 void AddCustomMapping(const GURL& mojo_url, const GURL& resolved_url);
34 38
35 // Add a local file mapping for a particular "mojo:" URL. This causes the 39 // Add a local file mapping for a particular "mojo:" URL. This causes the
36 // "mojo:" URL to be resolved to a base::DIR_MODULE-relative shared library. 40 // "mojo:" URL to be resolved to a local_apps_url_-relative shared library.
qsr 2014/12/05 17:02:58 having the _ here is weird. Also please specify th
ppi 2014/12/10 16:21:00 Done.
37 void AddLocalFileMapping(const GURL& mojo_url); 41 void AddLocalFileMapping(const GURL& mojo_url);
38 42
39 // Resolve the given "mojo:" URL to the URL that should be used to fetch the 43 // Resolve the given "mojo:" URL to the URL that should be used to fetch the
40 // code for the corresponding Mojo App. 44 // code for the corresponding Mojo App.
41 GURL Resolve(const GURL& mojo_url) const; 45 GURL Resolve(const GURL& mojo_url) const;
42 46
43 private: 47 private:
44 // Applies all custom mappings for |url|, returning the last non-mapped url. 48 // Applies all custom mappings for |url|, returning the last non-mapped url.
45 // For example, if 'a' maps to 'b' and 'b' maps to 'c' calling this with 'a' 49 // For example, if 'a' maps to 'b' and 'b' maps to 'c' calling this with 'a'
46 // returns 'c'. 50 // returns 'c'.
47 GURL ApplyCustomMappings(const GURL& url) const; 51 GURL ApplyCustomMappings(const GURL& url) const;
48 52
49 std::map<GURL, GURL> url_map_; 53 std::map<GURL, GURL> url_map_;
50 std::set<GURL> local_file_set_; 54 std::set<GURL> local_file_set_;
51 GURL default_base_url_; 55 GURL local_apps_url_;
52 GURL base_url_; 56 GURL base_url_;
53 57
54 DISALLOW_COPY_AND_ASSIGN(MojoURLResolver); 58 DISALLOW_COPY_AND_ASSIGN(MojoURLResolver);
55 }; 59 };
56 60
57 } // namespace shell 61 } // namespace shell
58 } // namespace mojo 62 } // namespace mojo
59 63
60 #endif // MOJO_SHELL_MOJO_URL_RESOLVER_H_ 64 #endif // MOJO_SHELL_MOJO_URL_RESOLVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698