From ad3dc3766e1f9d8bb5700c707019d975cf345f6e Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 22 Aug 2016 14:19:09 -0700 Subject: [PATCH 1/3] Default network values to 0.0 --- atom/browser/api/atom_api_session.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/atom/browser/api/atom_api_session.cc b/atom/browser/api/atom_api_session.cc index 58de02f2ff63..bf950c4bb20a 100644 --- a/atom/browser/api/atom_api_session.cc +++ b/atom/browser/api/atom_api_session.cc @@ -416,7 +416,9 @@ void Session::SetDownloadPath(const base::FilePath& path) { void Session::EnableNetworkEmulation(const mate::Dictionary& options) { std::unique_ptr conditions; bool offline = false; - double latency, download_throughput, upload_throughput; + double latency = 0.0; + double download_throughput = 0.0; + double upload_throughput = 0.0; if (options.Get("offline", &offline) && offline) { conditions.reset(new brightray::DevToolsNetworkConditions(offline)); } else { From 4fc6cf48b07a2466c6719ae1cd03eaed633f53fa Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 22 Aug 2016 14:25:42 -0700 Subject: [PATCH 2/3] Document enableNetworkEmulation defaults --- docs/api/session.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/api/session.md b/docs/api/session.md index 5f0248ee3372..face8ed63da2 100644 --- a/docs/api/session.md +++ b/docs/api/session.md @@ -212,10 +212,14 @@ Sets download saving directory. By default, the download directory will be the #### `ses.enableNetworkEmulation(options)` * `options` Object - * `offline` Boolean - Whether to emulate network outage. - * `latency` Double - RTT in ms - * `downloadThroughput` Double - Download rate in Bps - * `uploadThroughput` Double - Upload rate in Bps + * `offline` Boolean (optional) - Whether to emulate network outage. Defaults + to false. + * `latency` Double (optional) - RTT in ms. Defaults to 0 which will disable + latency throttling. + * `downloadThroughput` Double (optional) - Download rate in Bps. Defaults to 0 + which will disable download throttling. + * `uploadThroughput` Double (optional) - Upload rate in Bps. Defaults to 0 + which will disable upload throttling. Emulates network with the given configuration for the `session`. From 0485e9eb36cb093d79270330642f8fb8c952aead Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 22 Aug 2016 16:26:31 -0700 Subject: [PATCH 3/3] :art: Go back to single line declaration --- atom/browser/api/atom_api_session.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/atom/browser/api/atom_api_session.cc b/atom/browser/api/atom_api_session.cc index bf950c4bb20a..dd98db843c40 100644 --- a/atom/browser/api/atom_api_session.cc +++ b/atom/browser/api/atom_api_session.cc @@ -416,9 +416,7 @@ void Session::SetDownloadPath(const base::FilePath& path) { void Session::EnableNetworkEmulation(const mate::Dictionary& options) { std::unique_ptr conditions; bool offline = false; - double latency = 0.0; - double download_throughput = 0.0; - double upload_throughput = 0.0; + double latency = 0.0, download_throughput = 0.0, upload_throughput = 0.0; if (options.Get("offline", &offline) && offline) { conditions.reset(new brightray::DevToolsNetworkConditions(offline)); } else {