OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/web_contents/web_contents_impl.h" | 5 #include "content/browser/web_contents/web_contents_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 base::Unretained(this))); | 411 base::Unretained(this))); |
412 media_web_contents_observer_.reset(new MediaWebContentsObserver(this)); | 412 media_web_contents_observer_.reset(new MediaWebContentsObserver(this)); |
413 wake_lock_service_context_.reset(new WakeLockServiceContext(this)); | 413 wake_lock_service_context_.reset(new WakeLockServiceContext(this)); |
414 } | 414 } |
415 | 415 |
416 WebContentsImpl::~WebContentsImpl() { | 416 WebContentsImpl::~WebContentsImpl() { |
417 is_being_destroyed_ = true; | 417 is_being_destroyed_ = true; |
418 | 418 |
419 rwh_input_event_router_.reset(); | 419 rwh_input_event_router_.reset(); |
420 | 420 |
| 421 // If this WebContents is a guest and goes away before its view has |
| 422 // de-registered its surface id namespace with the outermost WebContent's |
| 423 // input event router (IER), we will lose the ability to ever deregister it, |
| 424 // potentially resulting in a stale pointer in the IER's owner_map_. |
| 425 // Speculative fix for https://crbug.com/570646. |
| 426 auto input_event_router = GetOuterWebContents() |
| 427 ? GetOuterWebContents()->GetInputEventRouter() |
| 428 : nullptr; |
| 429 auto render_widget_host_view = |
| 430 static_cast<RenderWidgetHostViewBase*>(GetRenderWidgetHostView()); |
| 431 if (input_event_router && render_widget_host_view) |
| 432 input_event_router->RemoveSurfaceIdNamespaceOwner( |
| 433 render_widget_host_view->GetSurfaceIdNamespace()); |
| 434 |
421 // Delete all RFH pending shutdown, which will lead the corresponding RVH to | 435 // Delete all RFH pending shutdown, which will lead the corresponding RVH to |
422 // shutdown and be deleted as well. | 436 // shutdown and be deleted as well. |
423 frame_tree_.ForEach( | 437 frame_tree_.ForEach( |
424 base::Bind(&RenderFrameHostManager::ClearRFHsPendingShutdown)); | 438 base::Bind(&RenderFrameHostManager::ClearRFHsPendingShutdown)); |
425 | 439 |
426 // Destroy all WebUI instances. | 440 // Destroy all WebUI instances. |
427 frame_tree_.ForEach(base::Bind(&RenderFrameHostManager::ClearWebUIInstances)); | 441 frame_tree_.ForEach(base::Bind(&RenderFrameHostManager::ClearWebUIInstances)); |
428 | 442 |
429 for (std::set<RenderWidgetHostImpl*>::iterator iter = | 443 for (std::set<RenderWidgetHostImpl*>::iterator iter = |
430 created_widgets_.begin(); iter != created_widgets_.end(); ++iter) { | 444 created_widgets_.begin(); iter != created_widgets_.end(); ++iter) { |
(...skipping 4284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4715 const WebContentsObserver::MediaPlayerId& id) { | 4729 const WebContentsObserver::MediaPlayerId& id) { |
4716 FOR_EACH_OBSERVER(WebContentsObserver, observers_, MediaStartedPlaying(id)); | 4730 FOR_EACH_OBSERVER(WebContentsObserver, observers_, MediaStartedPlaying(id)); |
4717 } | 4731 } |
4718 | 4732 |
4719 void WebContentsImpl::MediaStoppedPlaying( | 4733 void WebContentsImpl::MediaStoppedPlaying( |
4720 const WebContentsObserver::MediaPlayerId& id) { | 4734 const WebContentsObserver::MediaPlayerId& id) { |
4721 FOR_EACH_OBSERVER(WebContentsObserver, observers_, MediaStoppedPlaying(id)); | 4735 FOR_EACH_OBSERVER(WebContentsObserver, observers_, MediaStoppedPlaying(id)); |
4722 } | 4736 } |
4723 | 4737 |
4724 } // namespace content | 4738 } // namespace content |
OLD | NEW |