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

Side by Side Diff: mojo/application_manager/application_manager.h

Issue 491443005: Get rid of KeepAlive. Quit shell when all urls run directly by Context are closed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Bring back ConnectToServiceViaNetwork Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | mojo/application_manager/application_manager.cc » ('j') | mojo/shell/context.h » ('J')
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_APPLICATION_MANAGER_APPLICATION_MANAGER_H_ 5 #ifndef MOJO_APPLICATION_MANAGER_APPLICATION_MANAGER_H_
6 #define MOJO_APPLICATION_MANAGER_APPLICATION_MANAGER_H_ 6 #define MOJO_APPLICATION_MANAGER_APPLICATION_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/gtest_prod_util.h" 11 #include "base/gtest_prod_util.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "mojo/application_manager/application_loader.h" 14 #include "mojo/application_manager/application_loader.h"
15 #include "mojo/application_manager/application_manager_export.h" 15 #include "mojo/application_manager/application_manager_export.h"
16 #include "mojo/public/interfaces/application/service_provider.mojom.h" 16 #include "mojo/public/interfaces/application/service_provider.mojom.h"
17 #include "url/gurl.h" 17 #include "url/gurl.h"
18 18
19 namespace mojo { 19 namespace mojo {
20 20
21 class MOJO_APPLICATION_MANAGER_EXPORT ApplicationManager { 21 class MOJO_APPLICATION_MANAGER_EXPORT ApplicationManager {
22 public: 22 public:
23 class Delegate {
24 public:
25 virtual void OnServiceError(const GURL& url) = 0;
tim (not reviewing) 2014/08/23 00:14:26 Please add a comment describing what a service err
DaveMoore 2014/08/24 22:31:11 Done and Done.
26 };
tim (not reviewing) 2014/08/23 00:14:27 Should have a virtual ~Delegate... (protected: if
DaveMoore 2014/08/24 22:31:11 Done.
27
23 // API for testing. 28 // API for testing.
24 class MOJO_APPLICATION_MANAGER_EXPORT TestAPI { 29 class MOJO_APPLICATION_MANAGER_EXPORT TestAPI {
25 public: 30 public:
26 explicit TestAPI(ApplicationManager* manager); 31 explicit TestAPI(ApplicationManager* manager);
27 ~TestAPI(); 32 ~TestAPI();
28 33
29 // Returns true if the shared instance has been created. 34 // Returns true if the shared instance has been created.
30 static bool HasCreatedInstance(); 35 static bool HasCreatedInstance();
31 // Returns true if there is a ShellImpl for this URL. 36 // Returns true if there is a ShellImpl for this URL.
32 bool HasFactoryForURL(const GURL& url) const; 37 bool HasFactoryForURL(const GURL& url) const;
(...skipping 30 matching lines...) Expand all
63 InterfacePtr<Interface>* ptr) { 68 InterfacePtr<Interface>* ptr) {
64 ScopedMessagePipeHandle service_handle = 69 ScopedMessagePipeHandle service_handle =
65 ConnectToServiceByName(application_url, Interface::Name_); 70 ConnectToServiceByName(application_url, Interface::Name_);
66 ptr->Bind(service_handle.Pass()); 71 ptr->Bind(service_handle.Pass());
67 } 72 }
68 73
69 ScopedMessagePipeHandle ConnectToServiceByName( 74 ScopedMessagePipeHandle ConnectToServiceByName(
70 const GURL& application_url, 75 const GURL& application_url,
71 const std::string& interface_name); 76 const std::string& interface_name);
72 77
78 void set_delegate(Delegate* delegate) { delegate_ = delegate; }
tim (not reviewing) 2014/08/23 00:14:27 Do we need to support the NULL-delegate case or co
DaveMoore 2014/08/24 22:31:11 I don't think so. It's up to the creator of the Ap
79
73 // Sets the default Loader to be used if not overridden by SetLoaderForURL() 80 // Sets the default Loader to be used if not overridden by SetLoaderForURL()
74 // or SetLoaderForScheme(). 81 // or SetLoaderForScheme().
75 void set_default_loader(scoped_ptr<ApplicationLoader> loader) { 82 void set_default_loader(scoped_ptr<ApplicationLoader> loader) {
76 default_loader_ = loader.Pass(); 83 default_loader_ = loader.Pass();
77 } 84 }
78 // Sets a Loader to be used for a specific url. 85 // Sets a Loader to be used for a specific url.
79 void SetLoaderForURL(scoped_ptr<ApplicationLoader> loader, const GURL& url); 86 void SetLoaderForURL(scoped_ptr<ApplicationLoader> loader, const GURL& url);
80 // Sets a Loader to be used for a specific url scheme. 87 // Sets a Loader to be used for a specific url scheme.
81 void SetLoaderForScheme(scoped_ptr<ApplicationLoader> loader, 88 void SetLoaderForScheme(scoped_ptr<ApplicationLoader> loader,
82 const std::string& scheme); 89 const std::string& scheme);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 ServiceProviderPtr service_provider); 122 ServiceProviderPtr service_provider);
116 123
117 // Returns the Loader to use for a url (using default if not overridden.) 124 // Returns the Loader to use for a url (using default if not overridden.)
118 // The preference is to use a loader that's been specified for an url first, 125 // The preference is to use a loader that's been specified for an url first,
119 // then one that's been specified for a scheme, then the default. 126 // then one that's been specified for a scheme, then the default.
120 ApplicationLoader* GetLoaderForURL(const GURL& url); 127 ApplicationLoader* GetLoaderForURL(const GURL& url);
121 128
122 // Removes a ShellImpl when it encounters an error. 129 // Removes a ShellImpl when it encounters an error.
123 void OnShellImplError(ShellImpl* shell_impl); 130 void OnShellImplError(ShellImpl* shell_impl);
124 131
132 Delegate* delegate_;
125 // Loader management. 133 // Loader management.
126 URLToLoaderMap url_to_loader_; 134 URLToLoaderMap url_to_loader_;
127 SchemeToLoaderMap scheme_to_loader_; 135 SchemeToLoaderMap scheme_to_loader_;
128 scoped_ptr<ApplicationLoader> default_loader_; 136 scoped_ptr<ApplicationLoader> default_loader_;
129 Interceptor* interceptor_; 137 Interceptor* interceptor_;
130 138
131 URLToShellImplMap url_to_shell_impl_; 139 URLToShellImplMap url_to_shell_impl_;
132 URLToContentHandlerMap url_to_content_handler_; 140 URLToContentHandlerMap url_to_content_handler_;
133 141
134 base::WeakPtrFactory<ApplicationManager> weak_ptr_factory_; 142 base::WeakPtrFactory<ApplicationManager> weak_ptr_factory_;
135 143
136 DISALLOW_COPY_AND_ASSIGN(ApplicationManager); 144 DISALLOW_COPY_AND_ASSIGN(ApplicationManager);
137 }; 145 };
138 146
139 } // namespace mojo 147 } // namespace mojo
140 148
141 #endif // MOJO_APPLICATION_MANAGER_APPLICATION_MANAGER_H_ 149 #endif // MOJO_APPLICATION_MANAGER_APPLICATION_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | mojo/application_manager/application_manager.cc » ('j') | mojo/shell/context.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698