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

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: update wrt to offline discussion 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 UIResourcesAreInvalid();
David Trainor- moved to gerrit 2014/06/04 07:22:41 Do we have to worry about this calling back into t
powei 2014/06/04 21:29:57 Maybe this line should come after next line. That
24 host_ = host;
25 }
26
27 void UIResourceProviderImpl::UIResourcesAreInvalid() {
28 for (UIResourceClientMap::iterator iter = ui_resource_client_map_.begin();
29 iter != ui_resource_client_map_.end();
30 iter++) {
31 iter->second->UIResourceIsInvalid();
32 }
33 ui_resource_client_map_.clear();
David Trainor- moved to gerrit 2014/06/04 07:22:41 Same thing, what if the client tries to recreate a
powei 2014/06/04 21:29:57 Essentially I was thinking that we should not recr
34 }
35
36 cc::UIResourceId UIResourceProviderImpl::CreateUIResource(
37 UIResourceClientAndroid* client) {
38 if (!host_)
39 return 0;
40 cc::UIResourceId id = host_->CreateUIResource(client);
41 DCHECK(ui_resource_client_map_.find(id) == ui_resource_client_map_.end());
42
43 ui_resource_client_map_[id] = client;
44 return id;
45 }
46
47 void UIResourceProviderImpl::DeleteUIResource(cc::UIResourceId ui_resource_id) {
48 UIResourceClientMap::iterator iter =
49 ui_resource_client_map_.find(ui_resource_id);
50 if (iter == ui_resource_client_map_.end())
51 return;
52
53 ui_resource_client_map_.erase(iter);
54
55 if (!host_)
56 return;
57 host_->DeleteUIResource(ui_resource_id);
58 }
59
60 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/android/ui_resource_provider_impl.h ('k') | content/browser/renderer_host/compositor_impl_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698