OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/android/ui_resource_provider_impl.h" | 5 #include "content/browser/android/ui_resource_provider_impl.h" |
6 | 6 |
7 #include "cc/resources/ui_resource_client.h" | 7 #include "cc/resources/ui_resource_client.h" |
8 #include "cc/trees/layer_tree_host.h" | 8 #include "cc/trees/layer_tree_host.h" |
9 #include "content/public/browser/android/ui_resource_client_android.h" | 9 #include "ui/base/android/ui_resource_client_android.h" |
10 | 10 |
11 namespace content { | 11 namespace content { |
12 | 12 |
13 UIResourceProviderImpl::UIResourceProviderImpl() : host_(NULL) { | 13 UIResourceProviderImpl::UIResourceProviderImpl() : host_(NULL) { |
14 } | 14 } |
15 | 15 |
16 UIResourceProviderImpl::~UIResourceProviderImpl() { | 16 UIResourceProviderImpl::~UIResourceProviderImpl() { |
17 SetLayerTreeHost(NULL); | 17 SetLayerTreeHost(NULL); |
18 } | 18 } |
19 | 19 |
20 void UIResourceProviderImpl::SetLayerTreeHost(cc::LayerTreeHost* host) { | 20 void UIResourceProviderImpl::SetLayerTreeHost(cc::LayerTreeHost* host) { |
21 if (host_ == host) | 21 if (host_ == host) |
22 return; | 22 return; |
23 host_ = host; | 23 host_ = host; |
24 UIResourcesAreInvalid(); | 24 UIResourcesAreInvalid(); |
25 } | 25 } |
26 | 26 |
27 void UIResourceProviderImpl::UIResourcesAreInvalid() { | 27 void UIResourceProviderImpl::UIResourcesAreInvalid() { |
28 UIResourceClientMap client_map = ui_resource_client_map_; | 28 UIResourceClientMap client_map = ui_resource_client_map_; |
29 ui_resource_client_map_.clear(); | 29 ui_resource_client_map_.clear(); |
30 for (UIResourceClientMap::iterator iter = client_map.begin(); | 30 for (UIResourceClientMap::iterator iter = client_map.begin(); |
31 iter != client_map.end(); | 31 iter != client_map.end(); |
32 iter++) { | 32 iter++) { |
33 iter->second->UIResourceIsInvalid(); | 33 iter->second->UIResourceIsInvalid(); |
34 } | 34 } |
35 } | 35 } |
36 | 36 |
37 cc::UIResourceId UIResourceProviderImpl::CreateUIResource( | 37 cc::UIResourceId UIResourceProviderImpl::CreateUIResource( |
38 UIResourceClientAndroid* client) { | 38 ui::UIResourceClientAndroid* client) { |
39 if (!host_) | 39 if (!host_) |
40 return 0; | 40 return 0; |
41 cc::UIResourceId id = host_->CreateUIResource(client); | 41 cc::UIResourceId id = host_->CreateUIResource(client); |
42 DCHECK(ui_resource_client_map_.find(id) == ui_resource_client_map_.end()); | 42 DCHECK(ui_resource_client_map_.find(id) == ui_resource_client_map_.end()); |
43 | 43 |
44 ui_resource_client_map_[id] = client; | 44 ui_resource_client_map_[id] = client; |
45 return id; | 45 return id; |
46 } | 46 } |
47 | 47 |
48 void UIResourceProviderImpl::DeleteUIResource(cc::UIResourceId ui_resource_id) { | 48 void UIResourceProviderImpl::DeleteUIResource(cc::UIResourceId ui_resource_id) { |
49 UIResourceClientMap::iterator iter = | 49 UIResourceClientMap::iterator iter = |
50 ui_resource_client_map_.find(ui_resource_id); | 50 ui_resource_client_map_.find(ui_resource_id); |
51 DCHECK(iter != ui_resource_client_map_.end()); | 51 DCHECK(iter != ui_resource_client_map_.end()); |
52 | 52 |
53 ui_resource_client_map_.erase(iter); | 53 ui_resource_client_map_.erase(iter); |
54 | 54 |
55 if (!host_) | 55 if (!host_) |
56 return; | 56 return; |
57 host_->DeleteUIResource(ui_resource_id); | 57 host_->DeleteUIResource(ui_resource_id); |
58 } | 58 } |
59 | 59 |
60 } // namespace content | 60 } // namespace content |
OLD | NEW |