Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / ui / android / resources / ui_resource_provider.cc
blobf9776b890148d7d63f0bcdaa0e886a58e77576c1
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
3 // found in the LICENSE file.
5 #include "ui/android/resources/ui_resource_provider.h"
7 #include "cc/resources/ui_resource_client.h"
8 #include "cc/trees/layer_tree_host.h"
9 #include "ui/android/resources/ui_resource_client_android.h"
11 namespace ui {
13 UIResourceProvider::UIResourceProvider()
14 : host_(NULL), supports_etc1_npot_(false) {
17 UIResourceProvider::~UIResourceProvider() {
18 SetLayerTreeHost(NULL);
21 void UIResourceProvider::SetLayerTreeHost(cc::LayerTreeHost* host) {
22 if (host_ == host)
23 return;
24 host_ = host;
25 UIResourcesAreInvalid();
28 void UIResourceProvider::UIResourcesAreInvalid() {
29 UIResourceClientMap client_map;
30 client_map.swap(ui_resource_client_map_);
31 for (UIResourceClientMap::iterator iter = client_map.begin();
32 iter != client_map.end(); iter++) {
33 iter->second->UIResourceIsInvalid();
37 cc::UIResourceId UIResourceProvider::CreateUIResource(
38 ui::UIResourceClientAndroid* client) {
39 if (!host_)
40 return 0;
41 cc::UIResourceId id = host_->CreateUIResource(client);
42 DCHECK(ui_resource_client_map_.find(id) == ui_resource_client_map_.end());
44 ui_resource_client_map_[id] = client;
45 return id;
48 void UIResourceProvider::DeleteUIResource(cc::UIResourceId ui_resource_id) {
49 UIResourceClientMap::iterator iter =
50 ui_resource_client_map_.find(ui_resource_id);
51 DCHECK(iter != ui_resource_client_map_.end());
53 ui_resource_client_map_.erase(iter);
55 if (!host_)
56 return;
57 host_->DeleteUIResource(ui_resource_id);
60 bool UIResourceProvider::SupportsETC1NonPowerOfTwo() const {
61 return supports_etc1_npot_;
64 } // namespace ui