Make sure window is closed before WebContents is destroyed.

Otherwise we would get "RawChannel fatal error".
This commit is contained in:
Cheng Zhao 2014-07-28 17:34:21 +08:00
parent 143bde007a
commit ec4275ca13
3 changed files with 2 additions and 7 deletions

View file

@ -104,10 +104,6 @@ NativeWindow::NativeWindow(content::WebContents* web_contents,
} }
NativeWindow::~NativeWindow() { NativeWindow::~NativeWindow() {
// Make sure we have the OnRenderViewDeleted message sent even when the window
// is destroyed directly.
DestroyWebContents();
// It's possible that the windows gets destroyed before it's closed, in that // It's possible that the windows gets destroyed before it's closed, in that
// case we need to ensure the OnWindowClosed message is still notified. // case we need to ensure the OnWindowClosed message is still notified.
NotifyWindowClosed(); NotifyWindowClosed();
@ -453,9 +449,6 @@ void NativeWindow::MoveContents(content::WebContents* source,
} }
void NativeWindow::CloseContents(content::WebContents* source) { void NativeWindow::CloseContents(content::WebContents* source) {
// Destroy the WebContents before we close the window.
DestroyWebContents();
// When the web contents is gone, close the window immediately, but the // When the web contents is gone, close the window immediately, but the
// memory will not be freed until you call delete. // memory will not be freed until you call delete.
// In this way, it would be safe to manage windows via smart pointers. If you // In this way, it would be safe to manage windows via smart pointers. If you

View file

@ -241,6 +241,7 @@ void NativeWindowMac::Close() {
void NativeWindowMac::CloseImmediately() { void NativeWindowMac::CloseImmediately() {
[window_ close]; [window_ close];
window_.reset();
} }
void NativeWindowMac::Move(const gfx::Rect& pos) { void NativeWindowMac::Move(const gfx::Rect& pos) {

View file

@ -137,6 +137,7 @@ void NativeWindowViews::Close() {
void NativeWindowViews::CloseImmediately() { void NativeWindowViews::CloseImmediately() {
window_->CloseNow(); window_->CloseNow();
window_.reset();
} }
void NativeWindowViews::Move(const gfx::Rect& bounds) { void NativeWindowViews::Move(const gfx::Rect& bounds) {