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

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

Powered by Google App Engine
This is Rietveld 408576698