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

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

Issue 2326913003: Privatize StrongBinding lifetime management (Closed)
Patch Set: rebase Created 4 years, 3 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 #include "mojo/public/cpp/bindings/strong_binding.h"
12 13
13 namespace content { 14 namespace content {
14 15
15 // static 16 OffscreenCanvasSurfaceImpl::OffscreenCanvasSurfaceImpl()
16 void OffscreenCanvasSurfaceImpl::Create( 17 : id_allocator_(new cc::SurfaceIdAllocator(AllocateSurfaceClientId())) {
17 mojo::InterfaceRequest<blink::mojom::OffscreenCanvasSurface> request) {
18 // |binding_| will take ownership of OffscreenCanvasSurfaceImpl
19 new OffscreenCanvasSurfaceImpl(std::move(request));
20 }
21
22 OffscreenCanvasSurfaceImpl::OffscreenCanvasSurfaceImpl(
23 mojo::InterfaceRequest<blink::mojom::OffscreenCanvasSurface> request)
24 : id_allocator_(new cc::SurfaceIdAllocator(AllocateSurfaceClientId())),
25 binding_(this, std::move(request)) {
26 GetSurfaceManager()->RegisterSurfaceClientId(id_allocator_->client_id()); 18 GetSurfaceManager()->RegisterSurfaceClientId(id_allocator_->client_id());
27 } 19 }
28 20
29 OffscreenCanvasSurfaceImpl::~OffscreenCanvasSurfaceImpl() { 21 OffscreenCanvasSurfaceImpl::~OffscreenCanvasSurfaceImpl() {
30 if (!GetSurfaceManager()) { 22 if (!GetSurfaceManager()) {
31 // Inform both members that SurfaceManager's no longer alive to 23 // Inform both members that SurfaceManager's no longer alive to
32 // avoid their destruction errors. 24 // avoid their destruction errors.
33 if (surface_factory_) 25 if (surface_factory_)
34 surface_factory_->DidDestroySurfaceManager(); 26 surface_factory_->DidDestroySurfaceManager();
35 } else { 27 } else {
36 GetSurfaceManager()->InvalidateSurfaceClientId(id_allocator_->client_id()); 28 GetSurfaceManager()->InvalidateSurfaceClientId(id_allocator_->client_id());
37 } 29 }
38 surface_factory_->Destroy(surface_id_); 30 surface_factory_->Destroy(surface_id_);
39 } 31 }
40 32
33 // static
34 void OffscreenCanvasSurfaceImpl::Create(
35 mojo::InterfaceRequest<blink::mojom::OffscreenCanvasSurface> request) {
36 mojo::MakeStrongBinding(base::MakeUnique<OffscreenCanvasSurfaceImpl>(),
37 std::move(request));
38 }
39
41 void OffscreenCanvasSurfaceImpl::GetSurfaceId( 40 void OffscreenCanvasSurfaceImpl::GetSurfaceId(
42 const GetSurfaceIdCallback& callback) { 41 const GetSurfaceIdCallback& callback) {
43 DCHECK_CURRENTLY_ON(BrowserThread::UI); 42 DCHECK_CURRENTLY_ON(BrowserThread::UI);
44 43
45 surface_id_ = id_allocator_->GenerateId(); 44 surface_id_ = id_allocator_->GenerateId();
46 45
47 callback.Run(surface_id_); 46 callback.Run(surface_id_);
48 } 47 }
49 48
50 void OffscreenCanvasSurfaceImpl::RequestSurfaceCreation( 49 void OffscreenCanvasSurfaceImpl::RequestSurfaceCreation(
(...skipping 29 matching lines...) Expand all
80 const cc::ReturnedResourceArray& resources) {} 79 const cc::ReturnedResourceArray& resources) {}
81 80
82 void OffscreenCanvasSurfaceImpl::WillDrawSurface(const cc::SurfaceId& id, 81 void OffscreenCanvasSurfaceImpl::WillDrawSurface(const cc::SurfaceId& id,
83 const gfx::Rect& damage_rect) { 82 const gfx::Rect& damage_rect) {
84 } 83 }
85 84
86 void OffscreenCanvasSurfaceImpl::SetBeginFrameSource( 85 void OffscreenCanvasSurfaceImpl::SetBeginFrameSource(
87 cc::BeginFrameSource* begin_frame_source) {} 86 cc::BeginFrameSource* begin_frame_source) {}
88 87
89 } // namespace content 88 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698