Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Side by Side Diff: content/browser/renderer_host/offscreen_canvas_surface_impl.cc

Issue 2087383002: Fix destruction order between SurfaceManger and OffscreenCanvasSurfaceImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix SurfaceIdAllocator's destructor Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/renderer_host/offscreen_canvas_surface_impl.h" 5 #include "content/browser/renderer_host/offscreen_canvas_surface_impl.h"
6 6
7 #include "base/bind_helpers.h" 7 #include "base/bind_helpers.h"
8 #include "cc/surfaces/surface.h" 8 #include "cc/surfaces/surface.h"
9 #include "cc/surfaces/surface_manager.h" 9 #include "cc/surfaces/surface_manager.h"
10 #include "content/browser/compositor/surface_utils.h" 10 #include "content/browser/compositor/surface_utils.h"
11 #include "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
12 12
13 namespace content { 13 namespace content {
14 14
15 // static 15 // static
16 void OffscreenCanvasSurfaceImpl::Create( 16 void OffscreenCanvasSurfaceImpl::Create(
17 mojo::InterfaceRequest<blink::mojom::OffscreenCanvasSurface> request) { 17 mojo::InterfaceRequest<blink::mojom::OffscreenCanvasSurface> request) {
18 // |binding_| will take ownership of OffscreenCanvasSurfaceImpl 18 // |binding_| will take ownership of OffscreenCanvasSurfaceImpl
19 new OffscreenCanvasSurfaceImpl(std::move(request)); 19 new OffscreenCanvasSurfaceImpl(std::move(request));
20 } 20 }
21 21
22 OffscreenCanvasSurfaceImpl::OffscreenCanvasSurfaceImpl( 22 OffscreenCanvasSurfaceImpl::OffscreenCanvasSurfaceImpl(
23 mojo::InterfaceRequest<blink::mojom::OffscreenCanvasSurface> request) 23 mojo::InterfaceRequest<blink::mojom::OffscreenCanvasSurface> request)
24 : id_allocator_(CreateSurfaceIdAllocator()), 24 : id_allocator_(CreateSurfaceIdAllocator()),
25 binding_(this, std::move(request)) {} 25 binding_(this, std::move(request)) {}
26 26
27 OffscreenCanvasSurfaceImpl::~OffscreenCanvasSurfaceImpl() { 27 OffscreenCanvasSurfaceImpl::~OffscreenCanvasSurfaceImpl() {
28 if (!GetSurfaceManager()) {
29 // Inform both members that SurfaceManager's no longer alive to
30 // avoid their destruction errors.
31 surface_factory_->didDestroySurfaceManager();
32 id_allocator_->didDestroySurfaceManager();
33 }
34 surface_factory_->Destroy(surface_id_);
28 } 35 }
29 36
30 void OffscreenCanvasSurfaceImpl::GetSurfaceId( 37 void OffscreenCanvasSurfaceImpl::GetSurfaceId(
31 const GetSurfaceIdCallback& callback) { 38 const GetSurfaceIdCallback& callback) {
32 DCHECK_CURRENTLY_ON(BrowserThread::UI); 39 DCHECK_CURRENTLY_ON(BrowserThread::UI);
33 40
34 cc::SurfaceId surface_id = id_allocator_->GenerateId(); 41 surface_id_ = id_allocator_->GenerateId();
35 42
36 callback.Run(surface_id); 43 callback.Run(surface_id_);
37 } 44 }
38 45
39 void OffscreenCanvasSurfaceImpl::RequestSurfaceCreation( 46 void OffscreenCanvasSurfaceImpl::RequestSurfaceCreation(
40 const cc::SurfaceId& surface_id) { 47 const cc::SurfaceId& surface_id) {
41 cc::SurfaceManager* manager = GetSurfaceManager(); 48 cc::SurfaceManager* manager = GetSurfaceManager();
42 if (!surface_factory_) { 49 if (!surface_factory_) {
43 surface_factory_ = base::MakeUnique<cc::SurfaceFactory>(manager, this); 50 surface_factory_ = base::MakeUnique<cc::SurfaceFactory>(manager, this);
44 } 51 }
45 surface_factory_->Create(surface_id); 52 surface_factory_->Create(surface_id);
46 } 53 }
(...skipping 22 matching lines...) Expand all
69 const cc::ReturnedResourceArray& resources) {} 76 const cc::ReturnedResourceArray& resources) {}
70 77
71 void OffscreenCanvasSurfaceImpl::WillDrawSurface(cc::SurfaceId id, 78 void OffscreenCanvasSurfaceImpl::WillDrawSurface(cc::SurfaceId id,
72 const gfx::Rect& damage_rect) { 79 const gfx::Rect& damage_rect) {
73 } 80 }
74 81
75 void OffscreenCanvasSurfaceImpl::SetBeginFrameSource( 82 void OffscreenCanvasSurfaceImpl::SetBeginFrameSource(
76 cc::BeginFrameSource* begin_frame_source) {} 83 cc::BeginFrameSource* begin_frame_source) {}
77 84
78 } // namespace content 85 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698