• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 The Chromium Authors
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_PROCESS_CONTEXT_H_
6 #define BASE_FUCHSIA_PROCESS_CONTEXT_H_
7 
8 #include <fidl/fuchsia.io/cpp/fidl.h>
9 
10 #include <memory>
11 
12 #include "base/base_export.h"
13 
14 namespace sys {
15 class ComponentContext;
16 }  // namespace sys
17 
18 namespace base {
19 
20 // Returns default sys::ComponentContext for the current process.
21 BASE_EXPORT sys::ComponentContext* ComponentContextForProcess();
22 
23 // Returns the ClientEnd for the default service directory in this process
24 // `ComponentContextForProcess()->svc()`. This can be passed to
25 // `component::ConnectAt` in order to connect a client to a service in this
26 // directory.
27 BASE_EXPORT fidl::UnownedClientEnd<fuchsia_io::Directory>
28 BorrowIncomingServiceDirectoryForProcess();
29 
30 // Replaces the default sys::ComponentContext for the current process, and
31 // returns the previously-active one.
32 // Use the base::TestComponentContextForProcess rather than calling this
33 // directly.
34 BASE_EXPORT std::unique_ptr<sys::ComponentContext>
35 ReplaceComponentContextForProcessForTest(
36     std::unique_ptr<sys::ComponentContext> context);
37 
38 }  // namespace base
39 
40 #endif  // BASE_FUCHSIA_PROCESS_CONTEXT_H_
41