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
#3950)

Refer to the original PR: #3554

b/330364592

Co-authored-by: aee <[email protected]>
  • Loading branch information
cobalt-github-releaser-bot and aee-google authored Aug 8, 2024
1 parent 1a292f7 commit f445564
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 @@ -254,8 +254,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 @@ -265,6 +274,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 f445564

Please sign in to comment.