Skip to content

Commit

Permalink
Cherry pick PR #3554: Add command line switch to disable Dial Service. (
Browse files Browse the repository at this point in the history
#3951)

Refer to the original PR: #3554

b/330364592

Co-authored-by: aee <aee@google.com>
Co-authored-by: Jelle Foks <jfoks@google.com>
  • Loading branch information
3 people authored Aug 15, 2024
1 parent babdc61 commit dfb5b3c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
17 changes: 15 additions & 2 deletions cobalt/network/network_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,17 @@ void NetworkModule::OnCreate(base::WaitableEvent* creation_event) {
cookie_jar_.reset(new CookieJarImpl(url_request_context_->cookie_store(),
task_runner().get()));
#if defined(DIAL_SERVER)
dial_service_.reset(new DialService());
dial_service_proxy_ = new DialServiceProxy(dial_service_->AsWeakPtr());
#if defined(ENABLE_DEBUG_COMMAND_LINE_SWITCHES)
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
bool enable_dial_service =
!command_line->HasSwitch(switches::kDisableInAppDial);
#else
bool enable_dial_service = true;
#endif
if (enable_dial_service) {
dial_service_.reset(new DialService());
dial_service_proxy_ = new DialServiceProxy(dial_service_->AsWeakPtr());
}
#endif

net_poster_.reset(new NetPoster(this));
Expand All @@ -248,6 +257,10 @@ void NetworkModule::OnCreate(base::WaitableEvent* creation_event) {

#if defined(DIAL_SERVER)
void NetworkModule::RestartDialService() {
#if defined(ENABLE_DEBUG_COMMAND_LINE_SWITCHES)
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(switches::kDisableInAppDial)) return;
#endif
base::WaitableEvent creation_event(
base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED);
Expand Down
2 changes: 2 additions & 0 deletions cobalt/network/switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ const char kMaxNetworkDelayHelp[] =
"Add an artificial random delay (up to the value specified) before the "
"start of network requests to simulate low-latency networks. The value "
"is specified in microseconds.";

const char kDisableInAppDial[] = "disable_in_app_dial";
#endif // ENABLE_DEBUG_COMMAND_LINE_SWITCHES

// Switch to disable use of the Quic network protocol.
Expand Down
1 change: 1 addition & 0 deletions cobalt/network/switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ extern const char kNetLogCaptureMode[];
extern const char kUserAgent[];
extern const char kMaxNetworkDelay[];
extern const char kMaxNetworkDelayHelp[];
extern const char kDisableInAppDial[];
#endif // ENABLE_DEBUG_COMMAND_LINE_SWITCHES
extern const char kDisableQuic[];
extern const char kDisableHttp2[];
Expand Down

0 comments on commit dfb5b3c

Please sign in to comment.