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

Side by Side Diff: content/browser/android/ui_resource_provider_impl.cc

Issue 287593002: android: content::UIResourceProvider and content::UIResourceClientAndroid (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed dtrainor comments Created 6 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
(Empty)
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.
4
5 #include "content/browser/android/ui_resource_provider_impl.h"
6
7 #include "cc/resources/ui_resource_client.h"
8 #include "cc/trees/layer_tree_host.h"
9 #include "content/public/browser/android/ui_resource_client_android.h"
10
11 namespace content {
12
13 UIResourceProviderImpl::UIResourceProviderImpl() : host_(NULL) {
14 }
15
16 UIResourceProviderImpl::~UIResourceProviderImpl() {
17 SetLayerTreeHost(NULL);
18 }
19
20 void UIResourceProviderImpl::SetLayerTreeHost(cc::LayerTreeHost* host) {
21 if (host_ == host)
22 return;
23 host_ = host;
24 UIResourcesAreInvalid();
25 }
26
27 void UIResourceProviderImpl::UIResourcesAreInvalid() {
28 UIResourceClientMap client_map = ui_resource_client_map_;
29 ui_resource_client_map_.clear();
30 for (UIResourceClientMap::iterator iter = client_map.begin();
31 iter != client_map.end();
32 iter++) {
33 iter->second->UIResourceIsInvalid();
34 }
35 }
36
37 cc::UIResourceId UIResourceProviderImpl::CreateUIResource(
38 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());
43
44 ui_resource_client_map_[id] = client;
45 return id;
46 }
47
48 void UIResourceProviderImpl::DeleteUIResource(cc::UIResourceId ui_resource_id) {
49 UIResourceClientMap::iterator iter =
50 ui_resource_client_map_.find(ui_resource_id);
51 if (iter == ui_resource_client_map_.end())
no sievers 2014/06/11 23:00:09 This is a bit risky: If resources become invalid b
powei 2014/06/13 00:02:10 Done. Put this in a dcheck and added a comment in
52 return;
53
54 ui_resource_client_map_.erase(iter);
55
56 if (!host_)
57 return;
58 host_->DeleteUIResource(ui_resource_id);
59 }
60
61 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698