From 64c4a3450762c9986c1604f62f52f92cf2b29ed7 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 9 Jun 2015 10:41:25 +0800 Subject: [PATCH] Make devtools_web_contents_ is destroyed before everything The WebContentsDestroyed still access the other members, so if they are destroyed before the devtools_web_contents_ in the destructor, we will crash there. --- brightray/browser/inspectable_web_contents_impl.cc | 4 ++-- brightray/browser/inspectable_web_contents_impl.h | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/brightray/browser/inspectable_web_contents_impl.cc b/brightray/browser/inspectable_web_contents_impl.cc index c30c6f1becbd..f196efa0248c 100644 --- a/brightray/browser/inspectable_web_contents_impl.cc +++ b/brightray/browser/inspectable_web_contents_impl.cc @@ -159,10 +159,10 @@ void InspectableWebContentsImpl::RegisterPrefs(PrefRegistrySimple* registry) { InspectableWebContentsImpl::InspectableWebContentsImpl( content::WebContents* web_contents) - : web_contents_(web_contents), - frontend_loaded_(false), + : frontend_loaded_(false), can_dock_(true), delegate_(nullptr), + web_contents_(web_contents), weak_factory_(this) { auto context = static_cast(web_contents_->GetBrowserContext()); auto bounds_dict = context->prefs()->GetDictionary(kDevToolsBoundsPref); diff --git a/brightray/browser/inspectable_web_contents_impl.h b/brightray/browser/inspectable_web_contents_impl.h index d9af6cf12304..5df435b15e7b 100644 --- a/brightray/browser/inspectable_web_contents_impl.h +++ b/brightray/browser/inspectable_web_contents_impl.h @@ -147,10 +147,6 @@ class InspectableWebContentsImpl : void SendMessageAck(int request_id, const base::Value* arg1); - scoped_ptr web_contents_; - scoped_ptr devtools_web_contents_; - scoped_ptr view_; - bool frontend_loaded_; scoped_refptr agent_host_; scoped_ptr frontend_host_; @@ -160,10 +156,14 @@ class InspectableWebContentsImpl : gfx::Rect devtools_bounds_; bool can_dock_; - InspectableWebContentsDelegate* delegate_; // weak references. - using PendingRequestsMap = std::map; PendingRequestsMap pending_requests_; + InspectableWebContentsDelegate* delegate_; // weak references. + + scoped_ptr view_; + scoped_ptr web_contents_; + scoped_ptr devtools_web_contents_; + base::WeakPtrFactory weak_factory_; DISALLOW_COPY_AND_ASSIGN(InspectableWebContentsImpl);