Update brightray for electron/brightray#212
authorCheng Zhao <zcbenz@gmail.com>
Mon, 18 Apr 2016 04:59:15 +0000 (13:59 +0900)
committerCheng Zhao <zcbenz@gmail.com>
Mon, 18 Apr 2016 04:59:15 +0000 (13:59 +0900)
atom/browser/api/atom_api_session.cc
atom/browser/api/atom_api_session.h
vendor/brightray

index 0f104c7..2b352e5 100644 (file)
 #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<brightray::DevToolsNetworkConditions> 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<brightray::DevToolsNetworkConditions> conditions;
+  browser_context_->network_controller_handle()->SetNetworkState(
+      devtools_network_emulation_client_id_, std::move(conditions));
 }
 
 void Session::SetCertVerifyProc(v8::Local<v8::Value> val,
index 02d8ba5..7da01ac 100644 (file)
@@ -86,6 +86,9 @@ class Session: public mate::TrackableObject<Session>,
   v8::Global<v8::Value> cookies_;
   v8::Global<v8::Value> web_request_;
 
+  // The X-DevTools-Emulate-Network-Conditions-Client-Id.
+  std::string devtools_network_emulation_client_id_;
+
   scoped_refptr<AtomBrowserContext> browser_context_;
 
   DISALLOW_COPY_AND_ASSIGN(Session);
index 79b80e8..bc9c496 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 79b80e83f4a64790e51ad2fc44b0a56bdb3d7ef3
+Subproject commit bc9c496a6185e37e792c10bfc5b49ea779b27cd3