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

Side by Side Diff: content/common/service_manager/embedded_service_runner.h

Issue 2398783002: Rename a bunch of Mojo Application stuff to reference Services. (Closed)
Patch Set: . 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
OLDNEW
(Empty)
1 // Copyright 2016 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 CONTENT_COMMON_SERVICE_MANAGER_EMBEDDED_SERVICE_RUNNER_H_
6 #define CONTENT_COMMON_SERVICE_MANAGER_EMBEDDED_SERVICE_RUNNER_H_
7
8 #include <memory>
9
10 #include "base/callback.h"
11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/weak_ptr.h"
14 #include "base/single_thread_task_runner.h"
15 #include "base/strings/string_piece.h"
16 #include "content/public/common/service_info.h"
17 #include "services/shell/public/cpp/service.h"
18 #include "services/shell/public/interfaces/service.mojom.h"
19
20 namespace content {
21
22 // Hosts an in-process service instance that supports multiple Service
23 // connections. The first incoming connection will invoke a provided factory
24 // function to instantiate the service, and the service will automatically be
25 // torn down when its last connection is lost. The service may be launched and
26 // torn down multiple times by a single EmbeddedServiceRunner instance.
27 class EmbeddedServiceRunner {
28 public:
29 // Constructs a runner which hosts a service. If an existing instance of the
30 // service is not running when an incoming connection is made, details from
31 // |info| will be used to construct a new instance.
32 EmbeddedServiceRunner(const base::StringPiece& name,
33 const ServiceInfo& info);
34 ~EmbeddedServiceRunner();
35
36 // Binds an incoming ServiceRequest for this service. If the service isn't
37 // already running, it is started. Otherwise the request is bound to the
38 // running instance.
39 void BindServiceRequest(shell::mojom::ServiceRequest request);
40
41 // Sets a callback to run after the service loses its last connection and is
42 // torn down.
43 void SetQuitClosure(const base::Closure& quit_closure);
44
45 private:
46 class Instance;
47
48 void OnQuit();
49
50 // A reference to the service instance which may operate on the
51 // |task_runner_|'s thread.
52 scoped_refptr<Instance> instance_;
53
54 base::Closure quit_closure_;
55
56 base::WeakPtrFactory<EmbeddedServiceRunner> weak_factory_;
57
58 DISALLOW_COPY_AND_ASSIGN(EmbeddedServiceRunner);
59 };
60
61 } // namespace content
62
63 #endif // CONTENT_COMMON_SERVICE_MANAGER_EMBEDDED_SERVICE_RUNNER_H_
OLDNEW
« no previous file with comments | « content/common/service_manager/child_connection.cc ('k') | content/common/service_manager/embedded_service_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698