ipc_constants.cc 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // Copyright (c) 2012 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. #include "remoting/host/ipc_constants.h"
  5. #include "base/compiler_specific.h"
  6. #include "base/logging.h"
  7. #include "base/no_destructor.h"
  8. #include "base/path_service.h"
  9. #include "build/build_config.h"
  10. #include "mojo/public/cpp/platform/named_platform_channel.h"
  11. #include "remoting/host/mojo_ipc/mojo_ipc_util.h"
  12. namespace remoting {
  13. namespace {
  14. #if !defined(NDEBUG) && BUILDFLAG(IS_LINUX)
  15. // Use a different IPC name for Linux debug builds so that we can run the host
  16. // directly from out/Debug without interfering with the production host that
  17. // might also be running.
  18. constexpr char kChromotingHostServicesIpcName[] =
  19. "chromoting_host_services_debug_mojo_ipc";
  20. #else
  21. constexpr char kChromotingHostServicesIpcName[] =
  22. "chromoting_host_services_mojo_ipc";
  23. #endif
  24. } // namespace
  25. const base::FilePath::CharType kHostBinaryName[] =
  26. FILE_PATH_LITERAL("remoting_host");
  27. const base::FilePath::CharType kDesktopBinaryName[] =
  28. FILE_PATH_LITERAL("remoting_desktop");
  29. bool GetInstalledBinaryPath(const base::FilePath::StringType& binary,
  30. base::FilePath* full_path) {
  31. base::FilePath dir_path;
  32. if (!base::PathService::Get(base::DIR_EXE, &dir_path)) {
  33. LOG(ERROR) << "Failed to get the executable file name.";
  34. return false;
  35. }
  36. base::FilePath path = dir_path.Append(binary);
  37. #if BUILDFLAG(IS_WIN)
  38. path = path.ReplaceExtension(FILE_PATH_LITERAL("exe"));
  39. #endif // BUILDFLAG(IS_WIN)
  40. *full_path = path;
  41. return true;
  42. }
  43. const mojo::NamedPlatformChannel::ServerName&
  44. GetChromotingHostServicesServerName() {
  45. static const base::NoDestructor<mojo::NamedPlatformChannel::ServerName>
  46. server_name(WorkingDirectoryIndependentServerNameFromUTF8(
  47. kChromotingHostServicesIpcName));
  48. return *server_name;
  49. }
  50. } // namespace remoting