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

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

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