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

Side by Side Diff: mojo/shell/application_manager.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, 3 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
« no previous file with comments | « mojo/shell/application_instance.cc ('k') | mojo/shell/application_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_APPLICATION_MANAGER_H_ 5 #ifndef MOJO_SHELL_APPLICATION_MANAGER_H_
6 #define MOJO_SHELL_APPLICATION_MANAGER_H_ 6 #define MOJO_SHELL_APPLICATION_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 // Returns true if the shared instance has been created. 47 // Returns true if the shared instance has been created.
48 static bool HasCreatedInstance(); 48 static bool HasCreatedInstance();
49 // Returns true if there is a ApplicationInstance for this URL. 49 // Returns true if there is a ApplicationInstance for this URL.
50 bool HasRunningInstanceForURL(const GURL& url) const; 50 bool HasRunningInstanceForURL(const GURL& url) const;
51 private: 51 private:
52 ApplicationManager* manager_; 52 ApplicationManager* manager_;
53 53
54 DISALLOW_COPY_AND_ASSIGN(TestAPI); 54 DISALLOW_COPY_AND_ASSIGN(TestAPI);
55 }; 55 };
56 56
57 // Creates an ApplicationManager.
58 // |package_manager| is an instance of an object that handles URL resolution,
59 // fetching and updating of applications. See package_manager.h.
57 explicit ApplicationManager(scoped_ptr<PackageManager> package_manager); 60 explicit ApplicationManager(scoped_ptr<PackageManager> package_manager);
61 // |native_runner_factory| is an instance of an object capable of vending
62 // implementations of NativeRunner, e.g. for in or out-of-process execution.
63 // See native_runner.h and RunNativeApplication().
64 // |task_runner| provides access to a thread to perform file copy operations
65 // on. This may be null only in testing environments where applications are
66 // loaded via ApplicationLoader implementations.
67 ApplicationManager(scoped_ptr<PackageManager> package_manager,
68 scoped_ptr<NativeRunnerFactory> native_runner_factory,
69 base::TaskRunner* task_runner);
58 ~ApplicationManager(); 70 ~ApplicationManager();
59 71
60 // Loads a service if necessary and establishes a new client connection. 72 // Loads a service if necessary and establishes a new client connection.
61 // Please see the comments in connect_to_application_params.h for more details 73 // Please see the comments in connect_to_application_params.h for more details
62 // about the parameters. 74 // about the parameters.
63 void ConnectToApplication(scoped_ptr<ConnectToApplicationParams> params); 75 void ConnectToApplication(scoped_ptr<ConnectToApplicationParams> params);
64 76
65 // Sets the default Loader to be used if not overridden by SetLoaderForURL(). 77 // Sets the default Loader to be used if not overridden by SetLoaderForURL().
66 void set_default_loader(scoped_ptr<ApplicationLoader> loader) { 78 void set_default_loader(scoped_ptr<ApplicationLoader> loader) {
67 default_loader_ = loader.Pass(); 79 default_loader_ = loader.Pass();
68 } 80 }
69 void set_native_runner_factory( 81
70 scoped_ptr<NativeRunnerFactory> runner_factory) {
71 native_runner_factory_ = runner_factory.Pass();
72 }
73 void set_blocking_pool(base::SequencedWorkerPool* blocking_pool) {
74 blocking_pool_ = blocking_pool;
75 }
76 // Sets a Loader to be used for a specific url. 82 // Sets a Loader to be used for a specific url.
77 void SetLoaderForURL(scoped_ptr<ApplicationLoader> loader, const GURL& url); 83 void SetLoaderForURL(scoped_ptr<ApplicationLoader> loader, const GURL& url);
78 84
79 // Destroys all Shell-ends of connections established with Applications. 85 // Destroys all Shell-ends of connections established with Applications.
80 // Applications connected by this ApplicationManager will observe pipe errors 86 // Applications connected by this ApplicationManager will observe pipe errors
81 // and have a chance to shutdown. 87 // and have a chance to shutdown.
82 void TerminateShellConnections(); 88 void TerminateShellConnections();
83 89
84 // Removes a ApplicationInstance when it encounters an error. 90 // Removes a ApplicationInstance when it encounters an error.
85 void OnApplicationInstanceError(ApplicationInstance* instance); 91 void OnApplicationInstanceError(ApplicationInstance* instance);
86 92
87 // Removes a ContentHandler when its connection is closed.
88 void OnContentHandlerConnectionClosed(
89 ContentHandlerConnection* content_handler);
90
91 ApplicationInstance* GetApplicationInstance(const Identity& identity) const; 93 ApplicationInstance* GetApplicationInstance(const Identity& identity) const;
92 94
93 private: 95 private:
94 using IdentityToInstanceMap = std::map<Identity, ApplicationInstance*>; 96 using IdentityToInstanceMap = std::map<Identity, ApplicationInstance*>;
95 using IdentityToContentHandlerMap =
96 std::map<Identity, ContentHandlerConnection*>;
97 using URLToLoaderMap = std::map<GURL, ApplicationLoader*>; 97 using URLToLoaderMap = std::map<GURL, ApplicationLoader*>;
98 98
99 // Takes the contents of |params| only when it returns true. 99 // Takes the contents of |params| only when it returns true.
100 bool ConnectToRunningApplication( 100 bool ConnectToRunningApplication(
101 scoped_ptr<ConnectToApplicationParams>* params); 101 scoped_ptr<ConnectToApplicationParams>* params);
102 102
103 InterfaceRequest<Application> CreateInstance( 103 InterfaceRequest<Application> CreateInstance(
104 scoped_ptr<ConnectToApplicationParams> params, 104 scoped_ptr<ConnectToApplicationParams> params,
105 ApplicationInstance** instance); 105 ApplicationInstance** instance);
106 106
107 // Called once |fetcher| has found app. |params->app_url()| is the url of 107 // Called once |fetcher| has found app. |params->app_url()| is the url of
108 // the requested application before any mappings/resolution have been applied. 108 // the requested application before any mappings/resolution have been applied.
109 // The corresponding URLRequest struct in |params| has been taken. 109 // The corresponding URLRequest struct in |params| has been taken.
110 void HandleFetchCallback(scoped_ptr<ConnectToApplicationParams> params, 110 void HandleFetchCallback(scoped_ptr<ConnectToApplicationParams> params,
111 scoped_ptr<Fetcher> fetcher); 111 scoped_ptr<Fetcher> fetcher);
112 112
113 void RunNativeApplication(InterfaceRequest<Application> application_request, 113 void RunNativeApplication(InterfaceRequest<Application> application_request,
114 bool start_sandboxed, 114 bool start_sandboxed,
115 scoped_ptr<Fetcher> fetcher, 115 scoped_ptr<Fetcher> fetcher,
116 const base::FilePath& file_path, 116 const base::FilePath& file_path,
117 bool path_exists); 117 bool path_exists);
118 118
119 void LoadWithContentHandler(
120 const Identity& source,
121 const Identity& content_handler,
122 const Shell::ConnectToApplicationCallback& connect_callback,
123 ApplicationInstance* app,
124 InterfaceRequest<Application> application_request,
125 URLResponsePtr url_response);
126
127 // Returns the appropriate loader for |url|, or the default loader if there is 119 // Returns the appropriate loader for |url|, or the default loader if there is
128 // no loader configured for the URL. 120 // no loader configured for the URL.
129 ApplicationLoader* GetLoaderForURL(const GURL& url); 121 ApplicationLoader* GetLoaderForURL(const GURL& url);
130 122
131 void CleanupRunner(NativeRunner* runner); 123 void CleanupRunner(NativeRunner* runner);
132 124
133 scoped_ptr<PackageManager> const package_manager_; 125 scoped_ptr<PackageManager> const package_manager_;
134 // Loader management. 126 // Loader management.
135 // Loaders are chosen in the order they are listed here. 127 // Loaders are chosen in the order they are listed here.
136 URLToLoaderMap url_to_loader_; 128 URLToLoaderMap url_to_loader_;
137 scoped_ptr<ApplicationLoader> default_loader_; 129 scoped_ptr<ApplicationLoader> default_loader_;
138 scoped_ptr<NativeRunnerFactory> native_runner_factory_;
139 130
140 IdentityToInstanceMap identity_to_instance_; 131 IdentityToInstanceMap identity_to_instance_;
141 IdentityToContentHandlerMap identity_to_content_handler_;
142 132
143 base::SequencedWorkerPool* blocking_pool_; 133 base::TaskRunner* task_runner_;
134 scoped_ptr<NativeRunnerFactory> native_runner_factory_;
144 ScopedVector<NativeRunner> native_runners_; 135 ScopedVector<NativeRunner> native_runners_;
145 // Counter used to assign ids to content_handlers.
146 uint32_t content_handler_id_counter_;
147 base::WeakPtrFactory<ApplicationManager> weak_ptr_factory_; 136 base::WeakPtrFactory<ApplicationManager> weak_ptr_factory_;
148 137
149 DISALLOW_COPY_AND_ASSIGN(ApplicationManager); 138 DISALLOW_COPY_AND_ASSIGN(ApplicationManager);
150 }; 139 };
151 140
152 Shell::ConnectToApplicationCallback EmptyConnectCallback(); 141 Shell::ConnectToApplicationCallback EmptyConnectCallback();
153 142
154 } // namespace shell 143 } // namespace shell
155 } // namespace mojo 144 } // namespace mojo
156 145
157 #endif // MOJO_SHELL_APPLICATION_MANAGER_H_ 146 #endif // MOJO_SHELL_APPLICATION_MANAGER_H_
OLDNEW
« no previous file with comments | « mojo/shell/application_instance.cc ('k') | mojo/shell/application_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698