From 0bf1e561561d87fb1ba9a4af418a1f74306e353a Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 18 Apr 2016 13:59:15 +0900 Subject: [PATCH] Update brightray for electron/brightray#212 --- atom/browser/api/atom_api_session.cc | 26 +++++++++----------------- atom/browser/api/atom_api_session.h | 3 +++ vendor/brightray | 2 +- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/atom/browser/api/atom_api_session.cc b/atom/browser/api/atom_api_session.cc index 0f104c760724..2b352e52f7c5 100644 --- a/atom/browser/api/atom_api_session.cc +++ b/atom/browser/api/atom_api_session.cc @@ -23,12 +23,13 @@ #include "atom/common/native_mate_converters/net_converter.h" #include "atom/common/node_includes.h" #include "base/files/file_path.h" +#include "base/guid.h" #include "base/prefs/pref_service.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "base/thread_task_runner_handle.h" #include "brightray/browser/net/devtools_network_conditions.h" -#include "brightray/browser/net/devtools_network_controller.h" +#include "brightray/browser/net/devtools_network_controller_handle.h" #include "chrome/common/pref_names.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/storage_partition.h" @@ -288,7 +289,8 @@ void ClearHostResolverCacheInIO( } // namespace Session::Session(AtomBrowserContext* browser_context) - : browser_context_(browser_context) { + : devtools_network_emulation_client_id_(base::GenerateGUID()), + browser_context_(browser_context) { AttachAsUserData(browser_context); // Observe DownloadManger to get download notifications. @@ -381,25 +383,15 @@ void Session::EnableNetworkEmulation(const mate::Dictionary& options) { download_throughput, upload_throughput)); } - auto controller = browser_context_->GetDevToolsNetworkController(); - BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, - base::Bind(&brightray::DevToolsNetworkController::SetNetworkState, - base::Unretained(controller), - std::string(), - base::Passed(&conditions))); + browser_context_->network_controller_handle()->SetNetworkState( + devtools_network_emulation_client_id_, std::move(conditions)); } void Session::DisableNetworkEmulation() { - scoped_ptr conditions( - new brightray::DevToolsNetworkConditions(false)); - auto controller = browser_context_->GetDevToolsNetworkController(); - - BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, - base::Bind(&brightray::DevToolsNetworkController::SetNetworkState, - base::Unretained(controller), - std::string(), - base::Passed(&conditions))); + scoped_ptr conditions; + browser_context_->network_controller_handle()->SetNetworkState( + devtools_network_emulation_client_id_, std::move(conditions)); } void Session::SetCertVerifyProc(v8::Local val, diff --git a/atom/browser/api/atom_api_session.h b/atom/browser/api/atom_api_session.h index 02d8ba5cdec0..7da01acdaaa6 100644 --- a/atom/browser/api/atom_api_session.h +++ b/atom/browser/api/atom_api_session.h @@ -86,6 +86,9 @@ class Session: public mate::TrackableObject, v8::Global cookies_; v8::Global web_request_; + // The X-DevTools-Emulate-Network-Conditions-Client-Id. + std::string devtools_network_emulation_client_id_; + scoped_refptr browser_context_; DISALLOW_COPY_AND_ASSIGN(Session); diff --git a/vendor/brightray b/vendor/brightray index 79b80e83f4a6..bc9c496a6185 160000 --- a/vendor/brightray +++ b/vendor/brightray @@ -1 +1 @@ -Subproject commit 79b80e83f4a64790e51ad2fc44b0a56bdb3d7ef3 +Subproject commit bc9c496a6185e37e792c10bfc5b49ea779b27cd3