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

Side by Side Diff: mojo/shell/package_manager/package_manager_impl.h

Issue 1566253002: Move package_manager into mojo/shell (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 11 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
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 #ifndef MOJO_PACKAGE_MANAGER_PACKAGE_MANAGER_IMPL_H_ 5 #ifndef MOJO_SHELL_PACKAGE_MANAGER_PACKAGE_MANAGER_IMPL_H_
6 #define MOJO_PACKAGE_MANAGER_PACKAGE_MANAGER_IMPL_H_ 6 #define MOJO_SHELL_PACKAGE_MANAGER_PACKAGE_MANAGER_IMPL_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "mojo/fetcher/url_resolver.h" 12 #include "mojo/fetcher/url_resolver.h"
13 #include "mojo/services/network/public/interfaces/network_service.mojom.h" 13 #include "mojo/services/network/public/interfaces/network_service.mojom.h"
14 #include "mojo/services/network/public/interfaces/url_loader_factory.mojom.h" 14 #include "mojo/services/network/public/interfaces/url_loader_factory.mojom.h"
15 #include "mojo/shell/package_manager.h" 15 #include "mojo/shell/package_manager.h"
16 16
17 namespace base { 17 namespace base {
18 class TaskRunner; 18 class TaskRunner;
19 } 19 }
20 20
21 namespace mojo { 21 namespace mojo {
22 class ContentHandler; 22 class ContentHandler;
23 namespace shell { 23 namespace shell {
24 class ContentHandlerConnection;
24 class Fetcher; 25 class Fetcher;
25 class Identity; 26 class Identity;
26 }
27 namespace package_manager {
28 class ContentHandlerConnection;
29 27
30 // This is the default implementation of shell::PackageManager. It loads 28 // This is the default implementation of PackageManager. It loads http/s urls
31 // http/s urls off the network as well as providing special handling for mojo: 29 // off the network as well as providing special handling for mojo: and about:
32 // and about: urls. 30 // urls.
33 class PackageManagerImpl : public shell::PackageManager { 31 class PackageManagerImpl : public PackageManager {
34 public: 32 public:
35 // mojo: urls are only supported if |shell_file_root| is non-empty. 33 // mojo: urls are only supported if |shell_file_root| is non-empty.
36 // |task_runner| is used by Fetchers created by the PackageManager to complete 34 // |task_runner| is used by Fetchers created by the PackageManager to complete
37 // file copies needed to obtain library paths that the ApplicationManager can 35 // file copies needed to obtain library paths that the ApplicationManager can
38 // load. This can be null only in tests where application loading is handled 36 // load. This can be null only in tests where application loading is handled
39 // by custom ApplicationLoader implementations. 37 // by custom ApplicationLoader implementations.
40 PackageManagerImpl(const base::FilePath& shell_file_root, 38 PackageManagerImpl(const base::FilePath& shell_file_root,
41 base::TaskRunner* task_runner); 39 base::TaskRunner* task_runner);
42 ~PackageManagerImpl() override; 40 ~PackageManagerImpl() override;
43 41
44 // Register a content handler to handle content of |mime_type|. 42 // Register a content handler to handle content of |mime_type|.
45 void RegisterContentHandler(const std::string& mime_type, 43 void RegisterContentHandler(const std::string& mime_type,
46 const GURL& content_handler_url); 44 const GURL& content_handler_url);
47 45
48 // Registers a package alias. When attempting to load |alias|, it will 46 // Registers a package alias. When attempting to load |alias|, it will
49 // instead redirect to |content_handler_package|, which is a content handler 47 // instead redirect to |content_handler_package|, which is a content handler
50 // which will be passed the |alias| as the URLResponse::url. Different values 48 // which will be passed the |alias| as the URLResponse::url. Different values
51 // of |alias| with the same |qualifier| that are in the same 49 // of |alias| with the same |qualifier| that are in the same
52 // |content_handler_package| will run in the same process in multi-process 50 // |content_handler_package| will run in the same process in multi-process
53 // mode. 51 // mode.
54 void RegisterApplicationPackageAlias( 52 void RegisterApplicationPackageAlias(
55 const GURL& alias, 53 const GURL& alias,
56 const GURL& content_handler_package, 54 const GURL& content_handler_package,
57 const std::string& qualifier); 55 const std::string& qualifier);
58 56
59 private: 57 private:
60 using ApplicationPackagedAlias = std::map<GURL, std::pair<GURL, std::string>>; 58 using ApplicationPackagedAlias = std::map<GURL, std::pair<GURL, std::string>>;
61 using MimeTypeToURLMap = std::map<std::string, GURL>; 59 using MimeTypeToURLMap = std::map<std::string, GURL>;
62 using IdentityToContentHandlerMap = 60 using IdentityToContentHandlerMap =
63 std::map<shell::Identity, ContentHandlerConnection*>; 61 std::map<Identity, ContentHandlerConnection*>;
64 62
65 // Overridden from shell::PackageManager: 63 // Overridden from PackageManager:
66 void SetApplicationManager(shell::ApplicationManager* manager) override; 64 void SetApplicationManager(ApplicationManager* manager) override;
67 void FetchRequest( 65 void FetchRequest(
68 URLRequestPtr request, 66 URLRequestPtr request,
69 const shell::Fetcher::FetchCallback& loader_callback) override; 67 const Fetcher::FetchCallback& loader_callback) override;
70 uint32_t HandleWithContentHandler( 68 uint32_t HandleWithContentHandler(
71 shell::Fetcher* fetcher, 69 Fetcher* fetcher,
72 const shell::Identity& source, 70 const Identity& source,
73 const GURL& target_url, 71 const GURL& target_url,
74 const shell::CapabilityFilter& target_filter, 72 const CapabilityFilter& target_filter,
75 InterfaceRequest<Application>* application_request) override; 73 InterfaceRequest<Application>* application_request) override;
76 74
77 GURL ResolveURL(const GURL& url); 75 GURL ResolveURL(const GURL& url);
78 bool ShouldHandleWithContentHandler( 76 bool ShouldHandleWithContentHandler(
79 shell::Fetcher* fetcher, 77 Fetcher* fetcher,
80 const GURL& target_url, 78 const GURL& target_url,
81 const shell::CapabilityFilter& target_filter, 79 const CapabilityFilter& target_filter,
82 shell::Identity* content_handler_identity, 80 Identity* content_handler_identity,
83 URLResponsePtr* response) const; 81 URLResponsePtr* response) const;
84 82
85 // Returns a running ContentHandler for |content_handler_identity|, if there 83 // Returns a running ContentHandler for |content_handler_identity|, if there
86 // is not one running one is started for |source_identity|. 84 // is not one running one is started for |source_identity|.
87 ContentHandlerConnection* GetContentHandler( 85 ContentHandlerConnection* GetContentHandler(
88 const shell::Identity& content_handler_identity, 86 const Identity& content_handler_identity,
89 const shell::Identity& source_identity); 87 const Identity& source_identity);
90 88
91 void OnContentHandlerConnectionClosed( 89 void OnContentHandlerConnectionClosed(
92 ContentHandlerConnection* content_handler); 90 ContentHandlerConnection* content_handler);
93 91
94 shell::ApplicationManager* application_manager_; 92 ApplicationManager* application_manager_;
95 scoped_ptr<fetcher::URLResolver> url_resolver_; 93 scoped_ptr<fetcher::URLResolver> url_resolver_;
96 const bool disable_cache_; 94 const bool disable_cache_;
97 NetworkServicePtr network_service_; 95 NetworkServicePtr network_service_;
98 URLLoaderFactoryPtr url_loader_factory_; 96 URLLoaderFactoryPtr url_loader_factory_;
99 ApplicationPackagedAlias application_package_alias_; 97 ApplicationPackagedAlias application_package_alias_;
100 MimeTypeToURLMap mime_type_to_url_; 98 MimeTypeToURLMap mime_type_to_url_;
101 IdentityToContentHandlerMap identity_to_content_handler_; 99 IdentityToContentHandlerMap identity_to_content_handler_;
102 // Counter used to assign ids to content handlers. 100 // Counter used to assign ids to content handlers.
103 uint32_t content_handler_id_counter_; 101 uint32_t content_handler_id_counter_;
104 base::TaskRunner* task_runner_; 102 base::TaskRunner* task_runner_;
105 base::FilePath shell_file_root_; 103 base::FilePath shell_file_root_;
106 104
107 DISALLOW_COPY_AND_ASSIGN(PackageManagerImpl); 105 DISALLOW_COPY_AND_ASSIGN(PackageManagerImpl);
108 }; 106 };
109 107
110 } // namespace package_manager 108 } // namespace shell
111 } // namespace mojo 109 } // namespace mojo
112 110
113 #endif // MOJO_PACKAGE_MANAGER_PACKAGE_MANAGER_IMPL_H_ 111 #endif // MOJO_SHELL_PACKAGE_MANAGER_PACKAGE_MANAGER_IMPL_H_
OLDNEW
« no previous file with comments | « mojo/shell/package_manager/content_handler_unittest.cc ('k') | mojo/shell/package_manager/package_manager_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698