service_urls.cc 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Copyright 2017 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/base/service_urls.h"
  5. #include "base/check.h"
  6. #include "base/command_line.h"
  7. #include "base/logging.h"
  8. // Configurable service data.
  9. // Debug builds should default to the autopush environment (can be configured
  10. // via cmd line switch). Release builds will point to the prod environment.
  11. #if defined(NDEBUG)
  12. constexpr char kFtlServerEndpoint[] = "instantmessaging-pa.googleapis.com";
  13. constexpr char kRemotingServerEndpoint[] = "remotedesktop-pa.googleapis.com";
  14. #else
  15. constexpr char kFtlServerEndpoint[] =
  16. "tachyon-playground-autopush-grpc.sandbox.googleapis.com";
  17. constexpr char kRemotingServerEndpoint[] =
  18. "autopush-remotedesktop-pa.sandbox.googleapis.com";
  19. #endif
  20. // Command line switches.
  21. #if !defined(NDEBUG)
  22. constexpr char kFtlServerEndpointSwitch[] = "ftl-server-endpoint";
  23. constexpr char kRemotingServerEndpointSwitch[] = "remoting-server-endpoint";
  24. #endif // !defined(NDEBUG)
  25. namespace remoting {
  26. ServiceUrls::ServiceUrls()
  27. : ftl_server_endpoint_(kFtlServerEndpoint),
  28. remoting_server_endpoint_(kRemotingServerEndpoint) {
  29. #if !defined(NDEBUG)
  30. // The command line may not be initialized when running as a PNaCl plugin.
  31. if (base::CommandLine::InitializedForCurrentProcess()) {
  32. // Allow debug builds to override urls via command line.
  33. base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
  34. CHECK(command_line);
  35. if (command_line->HasSwitch(kFtlServerEndpointSwitch)) {
  36. ftl_server_endpoint_ =
  37. command_line->GetSwitchValueASCII(kFtlServerEndpointSwitch);
  38. } else {
  39. LOG(WARNING) << "CRD: Using autopush (non prod) FTL server";
  40. }
  41. if (command_line->HasSwitch(kRemotingServerEndpointSwitch)) {
  42. remoting_server_endpoint_ =
  43. command_line->GetSwitchValueASCII(kRemotingServerEndpointSwitch);
  44. } else {
  45. LOG(WARNING) << "CRD: Using autopush (non prod) remoting server";
  46. }
  47. }
  48. #endif // !defined(NDEBUG)
  49. }
  50. ServiceUrls::~ServiceUrls() = default;
  51. ServiceUrls* remoting::ServiceUrls::GetInstance() {
  52. return base::Singleton<ServiceUrls>::get();
  53. }
  54. } // namespace remoting