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

Side by Side Diff: services/shell/public/cpp/service.h

Issue 2419723002: Move services/shell to services/service_manager (Closed)
Patch Set: rebase Created 4 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
« no previous file with comments | « services/shell/public/cpp/names.h ('k') | services/shell/public/cpp/service.gni » ('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 2014 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 SERVICES_SHELL_PUBLIC_CPP_SERVICE_H_
6 #define SERVICES_SHELL_PUBLIC_CPP_SERVICE_H_
7
8 #include <stdint.h>
9 #include <string>
10
11 #include "base/macros.h"
12 #include "services/shell/public/cpp/interface_registry.h"
13
14 namespace shell {
15
16 class Connector;
17 class Identity;
18 class InterfaceRegistry;
19 class ServiceContext;
20
21 // The primary contract between a Service and the Service Manager, receiving
22 // lifecycle notifications and connection requests.
23 class Service {
24 public:
25 Service();
26 virtual ~Service();
27
28 // Called once a bidirectional connection with the Service Manager has been
29 // established.
30 // |identity| is the identity of the service instance.
31 // Called exactly once before any calls to OnConnect().
32 virtual void OnStart(const Identity& identity);
33
34 // Called when a connection to this service is brokered by the Service
35 // Manager. Override to expose interfaces to the remote service. Return true
36 // if the connection should succeed. Return false if the connection should
37 // be rejected and the underlying pipe closed. The default implementation
38 // returns false.
39 virtual bool OnConnect(const Identity& remote_identity,
40 InterfaceRegistry* registry);
41
42 // Called when the Service Manager has stopped tracking this instance. The
43 // service should use this as a signal to exit, and in fact its process may
44 // be reaped shortly afterward.
45 // Return true from this method to tell the ServiceContext to run its
46 // connection lost closure if it has one, false to prevent it from being run.
47 // The default implementation returns true.
48 // When used in conjunction with ApplicationRunner, returning true here quits
49 // the message loop created by ApplicationRunner, which results in the service
50 // quitting.
51 // No calls to either OnStart() nor OnConnect() may be received after this is
52 // called. It is however possible for this to be called without OnStart() ever
53 // having been called.
54 virtual bool OnStop();
55
56 Connector* connector();
57 ServiceContext* context();
58 void set_context(std::unique_ptr<ServiceContext> context);
59
60 private:
61 std::unique_ptr<ServiceContext> context_;
62
63 DISALLOW_COPY_AND_ASSIGN(Service);
64 };
65
66 } // namespace shell
67
68 #endif // SERVICES_SHELL_PUBLIC_CPP_SERVICE_H_
OLDNEW
« no previous file with comments | « services/shell/public/cpp/names.h ('k') | services/shell/public/cpp/service.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698