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

Side by Side Diff: mojo/shell/service_connector.h

Issue 164313002: Rename ServiceConnector back to ServiceManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Bad upload Created 6 years, 10 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 | « mojo/shell/run.cc ('k') | mojo/shell/service_connector.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 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_SHELL_SERVICE_CONNECTOR_H_
6 #define MOJO_SHELL_SERVICE_CONNECTOR_H_
7
8 #include <map>
9
10 #include "base/basictypes.h"
11 #include "base/callback.h"
12 #include "mojo/public/system/core_cpp.h"
13 #include "mojom/shell.h"
14 #include "url/gurl.h"
15
16 namespace mojo {
17 namespace shell {
18
19 class ServiceConnector {
20 public:
21 // Interface to allowing default loading behavior to be overridden for a
22 // specific url.
23 class Loader {
24 public:
25 virtual ~Loader();
26 virtual void Load(const GURL& url,
27 ScopedShellHandle service_handle) = 0;
28 protected:
29 Loader();
30 };
31
32 // API for testing.
33 class TestAPI {
34 private:
35 friend class ServiceConnectorTest;
36 explicit TestAPI(ServiceConnector* connector) : connector_(connector) {}
37 // Returns true if there is a ServiceFactory for this URL.
38 bool HasFactoryForURL(const GURL& url) const;
39
40 ServiceConnector* connector_;
41 };
42
43 ServiceConnector();
44 ~ServiceConnector();
45
46 // Sets the default Loader to be used if not overridden by SetLoaderForURL().
47 // Does not take ownership of |loader|.
48 void set_default_loader(Loader* loader) { default_loader_ = loader; }
49 // Sets a Loader to be used for a specific url.
50 // Does not take ownership of |loader|.
51 void SetLoaderForURL(Loader* loader, const GURL& gurl);
52 // Returns the Loader to use for a url (using default if not overridden.)
53 Loader* GetLoaderForURL(const GURL& gurl);
54 // Loads a service if necessary and establishes a new client connection.
55 void Connect(const GURL& url, ScopedMessagePipeHandle client_handle);
56
57 private:
58 class ServiceFactory;
59
60 // Removes a ServiceFactory when it no longer has any connections.
61 void RemoveServiceFactory(ServiceFactory* service_factory);
62
63 Loader* default_loader_;
64 typedef std::map<GURL, ServiceFactory*> ServiceFactoryMap;
65 ServiceFactoryMap url_to_service_factory_;
66 typedef std::map<GURL, Loader*> LoaderMap;
67 LoaderMap url_to_loader_;
68 DISALLOW_COPY_AND_ASSIGN(ServiceConnector);
69 };
70
71 } // namespace shell
72 } // namespace mojo
73
74 #endif // MOJO_SHELL_SERVICE_CONNECTOR_H_
OLDNEW
« no previous file with comments | « mojo/shell/run.cc ('k') | mojo/shell/service_connector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698