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 CHROME_BROWSER_CHROMEOS_DBUS_SMB_FS_SERVICE_PROVIDER_H_
6 #define CHROME_BROWSER_CHROMEOS_DBUS_SMB_FS_SERVICE_PROVIDER_H_
7 
8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/weak_ptr.h"
11 #include "chromeos/dbus/services/cros_dbus_service.h"
12 #include "dbus/exported_object.h"
13 
14 namespace dbus {
15 class MethodCall;
16 }
17 
18 namespace chromeos {
19 
20 // SmbFsServiceProvider exposes a D-Bus method which is used by instances of
21 // SmbFs to bootstrap a Mojo IPC connection. The method by which SmbFs is
22 // started cannot be passed a file descriptor, therefore this D-Bus method is
23 // used to asynchronously associate a FD with an identified SmbFs instance.
24 class SmbFsServiceProvider : public CrosDBusService::ServiceProviderInterface {
25  public:
26   SmbFsServiceProvider();
27   ~SmbFsServiceProvider() override;
28 
29   // CrosDBusService::ServiceProviderInterface overrides:
30   void Start(scoped_refptr<dbus::ExportedObject> exported_object) override;
31 
32  private:
33   // Handler for the OpenIpcChannel() D-Bus method.
34   void HandleOpenIpcChannel(
35       dbus::MethodCall* method_call,
36       dbus::ExportedObject::ResponseSender response_sender);
37 
38   base::WeakPtrFactory<SmbFsServiceProvider> weak_ptr_factory_{this};
39 
40   DISALLOW_COPY_AND_ASSIGN(SmbFsServiceProvider);
41 };
42 
43 }  // namespace chromeos
44 
45 #endif  // CHROME_BROWSER_CHROMEOS_DBUS_SMB_FS_SERVICE_PROVIDER_H_
46