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 #include "chromecast/external_mojo/public/cpp/common.h"
6 
7 #include "base/command_line.h"
8 #include "base/strings/string_piece.h"
9 
10 namespace chromecast {
11 namespace external_mojo {
12 
13 namespace {
14 // Default path for Unix domain socket used by external Mojo services to connect
15 // to Mojo services within cast_shell.
16 constexpr base::StringPiece kDefaultBrokerPath("/tmp/cast_mojo_broker");
17 
18 // Command-line arg to change the Unix domain socket path to connect to the
19 // Cast Mojo broker.
20 constexpr base::StringPiece kCastMojoBrokerPathSwitch("cast-mojo-broker-path");
21 }  // namespace
22 
GetBrokerPath()23 std::string GetBrokerPath() {
24   std::string broker_path;
25   base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
26   if (command_line->HasSwitch(kCastMojoBrokerPathSwitch)) {
27     broker_path = command_line->GetSwitchValueASCII(kCastMojoBrokerPathSwitch);
28   } else {
29     broker_path = std::string(kDefaultBrokerPath);
30   }
31   return broker_path;
32 }
33 
34 }  // namespace external_mojo
35 }  // namespace chromecast
36