Upload upstream chromium 76.0.3809.146
[platform/framework/web/chromium-efl.git] / base / fuchsia / startup_context.h
1 // Copyright 2019 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 BASE_FUCHSIA_STARTUP_CONTEXT_H_
6 #define BASE_FUCHSIA_STARTUP_CONTEXT_H_
7
8 #include <fuchsia/sys/cpp/fidl.h>
9 #include <memory>
10
11 #include "base/base_export.h"
12 #include "base/fuchsia/service_directory.h"
13 #include "base/fuchsia/service_directory_client.h"
14 #include "base/macros.h"
15
16 namespace base {
17 namespace fuchsia {
18
19 // Helper for unpacking a fuchsia.sys.StartupInfo and creating convenience
20 // wrappers for the various fields (e.g. the incoming & outgoing service
21 // directories, resolve launch URL etc).
22 // Embedders may derived from StartupContext to e.g. add bound pointers to
23 // embedder-specific services, as required.
24 class BASE_EXPORT StartupContext {
25  public:
26   explicit StartupContext(::fuchsia::sys::StartupInfo startup_info);
27   virtual ~StartupContext();
28
29   // Returns the namespace of services published for use by the component.
30   const ServiceDirectoryClient* incoming_services() const {
31     DCHECK(incoming_services_);
32     return incoming_services_.get();
33   }
34
35   // Returns the outgoing directory into which this component binds services.
36   // Note that all services should be bound immediately after the first call to
37   // this API, before returning control to the message loop, at which point we
38   // will start processing service connection requests.
39   ServiceDirectory* public_services();
40
41  private:
42   ::fuchsia::sys::StartupInfo startup_info_;
43
44   std::unique_ptr<ServiceDirectoryClient> incoming_services_;
45   std::unique_ptr<ServiceDirectory> public_services_;
46
47   // TODO(https://crbug.com/933834): Remove these when we migrate to the new
48   // component manager APIs.
49   ::fuchsia::sys::ServiceProviderPtr additional_services_;
50   std::unique_ptr<ServiceDirectory> additional_services_directory_;
51
52   DISALLOW_COPY_AND_ASSIGN(StartupContext);
53 };
54
55 }  // namespace fuchsia
56 }  // namespace base
57
58 #endif  // BASE_FUCHSIA_STARTUP_CONTEXT_H_