Skip to content

Commit

Permalink
Add command line switch to disable Dial Service.
Browse files Browse the repository at this point in the history
  • Loading branch information
aee-google committed Jun 14, 2024
1 parent 6424e50 commit 442d432
Show file tree
Hide file tree
Showing 3 changed files with 19 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 @@ -227,8 +227,17 @@ void NetworkModule::OnCreate(
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 @@ -238,6 +247,10 @@ void NetworkModule::OnCreate(

#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
3 changes: 3 additions & 0 deletions cobalt/network/switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,14 @@ 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.
const char kDisableQuic[] = "disable_quic";


} // namespace switches
} // namespace network
} // namespace cobalt
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[];

Expand Down

0 comments on commit 442d432

Please sign in to comment.