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.
This commit is contained in:
Cheng Zhao 2015-06-09 10:41:25 +08:00
parent 418264d42a
commit 64c4a34507
2 changed files with 8 additions and 8 deletions

View file

@ -159,10 +159,10 @@ void InspectableWebContentsImpl::RegisterPrefs(PrefRegistrySimple* registry) {
InspectableWebContentsImpl::InspectableWebContentsImpl( InspectableWebContentsImpl::InspectableWebContentsImpl(
content::WebContents* web_contents) content::WebContents* web_contents)
: web_contents_(web_contents), : frontend_loaded_(false),
frontend_loaded_(false),
can_dock_(true), can_dock_(true),
delegate_(nullptr), delegate_(nullptr),
web_contents_(web_contents),
weak_factory_(this) { weak_factory_(this) {
auto context = static_cast<BrowserContext*>(web_contents_->GetBrowserContext()); auto context = static_cast<BrowserContext*>(web_contents_->GetBrowserContext());
auto bounds_dict = context->prefs()->GetDictionary(kDevToolsBoundsPref); auto bounds_dict = context->prefs()->GetDictionary(kDevToolsBoundsPref);

View file

@ -147,10 +147,6 @@ class InspectableWebContentsImpl :
void SendMessageAck(int request_id, void SendMessageAck(int request_id,
const base::Value* arg1); const base::Value* arg1);
scoped_ptr<content::WebContents> web_contents_;
scoped_ptr<content::WebContents> devtools_web_contents_;
scoped_ptr<InspectableWebContentsView> view_;
bool frontend_loaded_; bool frontend_loaded_;
scoped_refptr<content::DevToolsAgentHost> agent_host_; scoped_refptr<content::DevToolsAgentHost> agent_host_;
scoped_ptr<content::DevToolsFrontendHost> frontend_host_; scoped_ptr<content::DevToolsFrontendHost> frontend_host_;
@ -160,10 +156,14 @@ class InspectableWebContentsImpl :
gfx::Rect devtools_bounds_; gfx::Rect devtools_bounds_;
bool can_dock_; bool can_dock_;
InspectableWebContentsDelegate* delegate_; // weak references.
using PendingRequestsMap = std::map<const net::URLFetcher*, DispatchCallback>; using PendingRequestsMap = std::map<const net::URLFetcher*, DispatchCallback>;
PendingRequestsMap pending_requests_; PendingRequestsMap pending_requests_;
InspectableWebContentsDelegate* delegate_; // weak references.
scoped_ptr<InspectableWebContentsView> view_;
scoped_ptr<content::WebContents> web_contents_;
scoped_ptr<content::WebContents> devtools_web_contents_;
base::WeakPtrFactory<InspectableWebContentsImpl> weak_factory_; base::WeakPtrFactory<InspectableWebContentsImpl> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(InspectableWebContentsImpl); DISALLOW_COPY_AND_ASSIGN(InspectableWebContentsImpl);