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.
5 #ifndef BASE_FUCHSIA_STARTUP_CONTEXT_H_
6 #define BASE_FUCHSIA_STARTUP_CONTEXT_H_
8 #include <fuchsia/sys/cpp/fidl.h>
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"
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 {
26 explicit StartupContext(::fuchsia::sys::StartupInfo startup_info);
27 virtual ~StartupContext();
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();
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();
42 ::fuchsia::sys::StartupInfo startup_info_;
44 std::unique_ptr<ServiceDirectoryClient> incoming_services_;
45 std::unique_ptr<ServiceDirectory> public_services_;
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_;
52 DISALLOW_COPY_AND_ASSIGN(StartupContext);
55 } // namespace fuchsia
58 #endif // BASE_FUCHSIA_STARTUP_CONTEXT_H_