OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "cc/resources/scoped_ui_resource.h" | 5 #include "cc/resources/scoped_ui_resource.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/ptr_util.h" |
8 #include "cc/trees/layer_tree_host.h" | 9 #include "cc/trees/layer_tree_host.h" |
9 | 10 |
10 namespace cc { | 11 namespace cc { |
11 | 12 |
12 scoped_ptr<ScopedUIResource> ScopedUIResource::Create( | 13 std::unique_ptr<ScopedUIResource> ScopedUIResource::Create( |
13 LayerTreeHost* host, | 14 LayerTreeHost* host, |
14 const UIResourceBitmap& bitmap) { | 15 const UIResourceBitmap& bitmap) { |
15 return make_scoped_ptr(new ScopedUIResource(host, bitmap)); | 16 return base::WrapUnique(new ScopedUIResource(host, bitmap)); |
16 } | 17 } |
17 | 18 |
18 ScopedUIResource::ScopedUIResource(LayerTreeHost* host, | 19 ScopedUIResource::ScopedUIResource(LayerTreeHost* host, |
19 const UIResourceBitmap& bitmap) | 20 const UIResourceBitmap& bitmap) |
20 : bitmap_(bitmap), host_(host) { | 21 : bitmap_(bitmap), host_(host) { |
21 DCHECK(host_); | 22 DCHECK(host_); |
22 id_ = host_->CreateUIResource(this); | 23 id_ = host_->CreateUIResource(this); |
23 } | 24 } |
24 | 25 |
25 // User must make sure that host is still valid before this object goes out of | 26 // User must make sure that host is still valid before this object goes out of |
26 // scope. | 27 // scope. |
27 ScopedUIResource::~ScopedUIResource() { | 28 ScopedUIResource::~ScopedUIResource() { |
28 if (id_) { | 29 if (id_) { |
29 DCHECK(host_); | 30 DCHECK(host_); |
30 host_->DeleteUIResource(id_); | 31 host_->DeleteUIResource(id_); |
31 } | 32 } |
32 } | 33 } |
33 | 34 |
34 UIResourceBitmap ScopedUIResource::GetBitmap(UIResourceId uid, | 35 UIResourceBitmap ScopedUIResource::GetBitmap(UIResourceId uid, |
35 bool resource_lost) { | 36 bool resource_lost) { |
36 return bitmap_; | 37 return bitmap_; |
37 } | 38 } |
38 | 39 |
39 } // namespace cc | 40 } // namespace cc |
OLD | NEW |