Set up a LayerTree class to split the LayerTreeHost.

The LayerTree class is the main thread counter-part to the LayerTreeImpl, which
will own the root layer and other tree state. Data and functionality will be
incrementally moved to this class as we eliminate dependencies of internal cc
class and the embedder to LayerTree from the host.

This patch moves the Registration/Unregistration logic for maintaining a map of
layers tied to a host and tracking of dirty layers that need to push properties
in the next commit, to the LayerTree.

BUG=628683
CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_precise_blink_rel

Review-Url: https://codereview.chromium.org/2159513003
Cr-Commit-Position: refs/heads/master@{#408518}
diff --git a/cc/BUILD.gn b/cc/BUILD.gn
index 8246ffc..4137362 100644
--- a/cc/BUILD.gn
+++ b/cc/BUILD.gn
@@ -497,6 +497,8 @@
     "trees/effect_node.h",
     "trees/latency_info_swap_promise_monitor.cc",
     "trees/latency_info_swap_promise_monitor.h",
+    "trees/layer_tree.cc",
+    "trees/layer_tree.h",
     "trees/layer_tree_host.cc",
     "trees/layer_tree_host.h",
     "trees/layer_tree_host_client.h",
diff --git a/cc/cc.gyp b/cc/cc.gyp
index 0e84877..ec0332022 100644
--- a/cc/cc.gyp
+++ b/cc/cc.gyp
@@ -558,6 +558,8 @@
         'trees/effect_node.h',
         'trees/latency_info_swap_promise_monitor.cc',
         'trees/latency_info_swap_promise_monitor.h',
+        'trees/layer_tree.cc',
+        'trees/layer_tree.h',
         'trees/layer_tree_host.cc',
         'trees/layer_tree_host.h',
         'trees/layer_tree_host_client.h',
@@ -634,6 +636,7 @@
         'proto/layer.proto',
         'proto/layer_position_constraint.proto',
         'proto/layer_tree_debug_state.proto',
+        'proto/layer_tree.proto',
         'proto/layer_tree_host.proto',
         'proto/layer_tree_settings.proto',
         'proto/layer_selection_bound.proto',
diff --git a/cc/layers/layer.cc b/cc/layers/layer.cc
index 4b2df1c..3352c1f 100644
--- a/cc/layers/layer.cc
+++ b/cc/layers/layer.cc
@@ -82,6 +82,7 @@
     : ignore_set_needs_commit_(false),
       parent_(nullptr),
       layer_tree_host_(nullptr),
+      layer_tree_(nullptr),
       num_descendants_that_draw_content_(0),
       transform_tree_index_(TransformTree::kInvalidNodeId),
       effect_tree_index_(EffectTree::kInvalidNodeId),
@@ -129,7 +130,7 @@
   if (layer_tree_host_) {
     layer_tree_host_->property_trees()->RemoveIdFromIdToIndexMaps(id());
     layer_tree_host_->property_trees()->needs_rebuild = true;
-    layer_tree_host_->UnregisterLayer(this);
+    layer_tree_->UnregisterLayer(this);
     if (inputs_.element_id) {
       layer_tree_host_->animation_host()->UnregisterElement(
           inputs_.element_id, ElementListType::ACTIVE);
@@ -138,7 +139,7 @@
   }
   if (host) {
     host->property_trees()->needs_rebuild = true;
-    host->RegisterLayer(this);
+    host->GetLayerTree()->RegisterLayer(this);
     if (inputs_.element_id) {
       host->AddToElementMap(this);
       host->animation_host()->RegisterElement(inputs_.element_id,
@@ -147,6 +148,7 @@
   }
 
   layer_tree_host_ = host;
+  layer_tree_ = host ? host->GetLayerTree() : nullptr;
   InvalidatePropertyTreesIndices();
 
   // When changing hosts, the layer needs to commit its properties to the impl
@@ -214,19 +216,20 @@
 }
 
 void Layer::SetNeedsPushProperties() {
-  if (layer_tree_host_)
-    layer_tree_host_->AddLayerShouldPushProperties(this);
+  if (layer_tree_)
+    layer_tree_->AddLayerShouldPushProperties(this);
 }
 
 void Layer::ResetNeedsPushPropertiesForTesting() {
-  layer_tree_host_->RemoveLayerShouldPushProperties(this);
+  if (layer_tree_)
+    layer_tree_->RemoveLayerShouldPushProperties(this);
 }
 
 bool Layer::IsPropertyChangeAllowed() const {
-  if (!layer_tree_host_)
+  if (!layer_tree_)
     return true;
 
-  return !layer_tree_host_->in_paint_layer_contents();
+  return !layer_tree_->in_paint_layer_contents();
 }
 
 sk_sp<SkPicture> Layer::GetPicture() const {
@@ -1201,7 +1204,7 @@
   layer_property_changed_ = false;
   inputs_.update_rect = gfx::Rect();
 
-  layer_tree_host()->RemoveLayerShouldPushProperties(this);
+  layer_tree_->RemoveLayerShouldPushProperties(this);
 }
 
 void Layer::TakeCopyRequests(
@@ -1252,10 +1255,12 @@
     LayerIdMap* layer_map) {
   (*layer_map)[inputs_.layer_id] = this;
 
-  if (layer_tree_host_)
-    layer_tree_host_->UnregisterLayer(this);
+  if (layer_tree_)
+    layer_tree_->UnregisterLayer(this);
 
   layer_tree_host_ = nullptr;
+  layer_tree_ = nullptr;
+
   parent_ = nullptr;
 
   // Clear these properties for all the children and add them to the map.
@@ -1291,7 +1296,8 @@
   inputs_.layer_id = proto.id();
 
   layer_tree_host_ = layer_tree_host;
-  layer_tree_host_->RegisterLayer(this);
+  layer_tree_ = layer_tree_host ? layer_tree_host->GetLayerTree() : nullptr;
+  layer_tree_->RegisterLayer(this);
 
   for (int i = 0; i < proto.children_size(); ++i) {
     const proto::LayerNode& child_proto = proto.children(i);
@@ -1774,7 +1780,7 @@
 }
 
 AnimationHost* Layer::GetAnimationHost() const {
-  return layer_tree_host_ ? layer_tree_host_->animation_host() : nullptr;
+  return layer_tree_ ? layer_tree_->animation_host() : nullptr;
 }
 
 ElementListType Layer::GetElementTypeForAnimation() const {
@@ -1876,4 +1882,8 @@
       this, layer_tree_host_->property_trees()->transform_tree);
 }
 
+LayerTree* Layer::GetLayerTree() const {
+  return layer_tree_;
+}
+
 }  // namespace cc
diff --git a/cc/layers/layer.h b/cc/layers/layer.h
index 6821f12..4e132b1 100644
--- a/cc/layers/layer.h
+++ b/cc/layers/layer.h
@@ -27,6 +27,7 @@
 #include "cc/layers/layer_position_constraint.h"
 #include "cc/layers/paint_properties.h"
 #include "cc/output/filter_operations.h"
+#include "cc/trees/layer_tree.h"
 #include "cc/trees/mutator_host_client.h"
 #include "cc/trees/property_tree.h"
 #include "third_party/skia/include/core/SkColor.h"
@@ -387,8 +388,11 @@
   // of |proto| is only read if |needs_push_properties_| is set.
   void FromLayerPropertiesProto(const proto::LayerProperties& proto);
 
+  // TODO(xingliu): Layer will hold LayerTree instead of LayerTreeHost.
+  // http://crbug.com/628683
   LayerTreeHost* layer_tree_host() { return layer_tree_host_; }
   const LayerTreeHost* layer_tree_host() const { return layer_tree_host_; }
+  LayerTree* GetLayerTree() const;
 
   virtual ScrollbarLayerInterface* ToScrollbarLayer();
 
@@ -691,6 +695,7 @@
   // This pointer value is nil when a Layer is not in a tree and is
   // updated via SetLayerTreeHost() if a layer moves between trees.
   LayerTreeHost* layer_tree_host_;
+  LayerTree* layer_tree_;
 
   Inputs inputs_;
 
diff --git a/cc/layers/layer_proto_converter.cc b/cc/layers/layer_proto_converter.cc
index ff1632c..281b5fb 100644
--- a/cc/layers/layer_proto_converter.cc
+++ b/cc/layers/layer_proto_converter.cc
@@ -57,9 +57,9 @@
     LayerTreeHost* host,
     proto::LayerUpdate* layer_update) {
   TRACE_EVENT0("cc.remote", "LayerProtoConverter::SerializeLayerProperties");
-  for (auto* layer : host->LayersThatShouldPushProperties())
+  for (auto* layer : host->GetLayerTree()->LayersThatShouldPushProperties())
     layer->ToLayerPropertiesProto(layer_update);
-  host->LayersThatShouldPushProperties().clear();
+  host->GetLayerTree()->LayersThatShouldPushProperties().clear();
 }
 
 // static
diff --git a/cc/layers/layer_proto_converter_unittest.cc b/cc/layers/layer_proto_converter_unittest.cc
index 5f88dc3..87a4a30 100644
--- a/cc/layers/layer_proto_converter_unittest.cc
+++ b/cc/layers/layer_proto_converter_unittest.cc
@@ -200,26 +200,22 @@
 
   // All flags for pushing properties should have been cleared.
   EXPECT_FALSE(
-      layer_src_root->layer_tree_host()->LayerNeedsPushPropertiesForTesting(
+      layer_src_root->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
           layer_src_root.get()));
+  EXPECT_FALSE(layer_src_a->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
+      layer_src_a.get()));
+  EXPECT_FALSE(layer_src_b->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
+      layer_src_b.get()));
   EXPECT_FALSE(
-      layer_src_a->layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-          layer_src_a.get()));
-  EXPECT_FALSE(
-      layer_src_b->layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-          layer_src_b.get()));
-  EXPECT_FALSE(
-      layer_src_b_mask->layer_tree_host()->LayerNeedsPushPropertiesForTesting(
+      layer_src_b_mask->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
           layer_src_b_mask.get()));
   EXPECT_FALSE(
-      layer_src_b_replica->layer_tree_host()
-          ->LayerNeedsPushPropertiesForTesting(layer_src_b_replica.get()));
-  EXPECT_FALSE(
-      layer_src_c->layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-          layer_src_c.get()));
-  EXPECT_FALSE(
-      layer_src_d->layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-          layer_src_d.get()));
+      layer_src_b_replica->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
+          layer_src_b_replica.get()));
+  EXPECT_FALSE(layer_src_c->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
+      layer_src_c.get()));
+  EXPECT_FALSE(layer_src_d->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
+      layer_src_d.get()));
 
   // All layers needs to push properties as their layer tree host changed.
   ASSERT_EQ(7, layer_update.layers_size());
@@ -240,26 +236,22 @@
 
   // All flags for pushing properties should have been cleared.
   EXPECT_FALSE(
-      layer_src_root->layer_tree_host()->LayerNeedsPushPropertiesForTesting(
+      layer_src_root->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
           layer_src_root.get()));
+  EXPECT_FALSE(layer_src_a->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
+      layer_src_a.get()));
+  EXPECT_FALSE(layer_src_b->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
+      layer_src_b.get()));
   EXPECT_FALSE(
-      layer_src_a->layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-          layer_src_a.get()));
-  EXPECT_FALSE(
-      layer_src_b->layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-          layer_src_b.get()));
-  EXPECT_FALSE(
-      layer_src_b_mask->layer_tree_host()->LayerNeedsPushPropertiesForTesting(
+      layer_src_b_mask->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
           layer_src_b_mask.get()));
   EXPECT_FALSE(
-      layer_src_b_replica->layer_tree_host()
-          ->LayerNeedsPushPropertiesForTesting(layer_src_b_replica.get()));
-  EXPECT_FALSE(
-      layer_src_c->layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-          layer_src_c.get()));
-  EXPECT_FALSE(
-      layer_src_d->layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-          layer_src_d.get()));
+      layer_src_b_replica->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
+          layer_src_b_replica.get()));
+  EXPECT_FALSE(layer_src_c->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
+      layer_src_c.get()));
+  EXPECT_FALSE(layer_src_d->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
+      layer_src_d.get()));
 
   // Only 4 of the layers should have been serialized.
   ASSERT_EQ(4, layer_update.layers_size());
@@ -307,17 +299,15 @@
 
   // All flags for pushing properties should have been cleared.
   EXPECT_FALSE(
-      layer_src_root->layer_tree_host()->LayerNeedsPushPropertiesForTesting(
+      layer_src_root->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
           layer_src_root.get()));
+  EXPECT_FALSE(layer_src_b->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
+      layer_src_b.get()));
   EXPECT_FALSE(
-      layer_src_b->layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-          layer_src_b.get()));
-  EXPECT_FALSE(
-      layer_src_b_mask->layer_tree_host()->LayerNeedsPushPropertiesForTesting(
+      layer_src_b_mask->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
           layer_src_b_mask.get()));
-  EXPECT_FALSE(
-      layer_src_c->layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-          layer_src_c.get()));
+  EXPECT_FALSE(layer_src_c->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
+      layer_src_c.get()));
 
   // Only 2 of the layers should have been serialized.
   ASSERT_EQ(2, layer_update.layers_size());
diff --git a/cc/layers/layer_unittest.cc b/cc/layers/layer_unittest.cc
index adc7894..cd9f0d0 100644
--- a/cc/layers/layer_unittest.cc
+++ b/cc/layers/layer_unittest.cc
@@ -56,48 +56,47 @@
     Mock::VerifyAndClearExpectations(layer_tree_host_.get());               \
   } while (false)
 
-#define EXECUTE_AND_VERIFY_SUBTREE_CHANGED(code_to_test)                    \
-  code_to_test;                                                             \
-  root->layer_tree_host()->BuildPropertyTreesForTesting();                  \
-  EXPECT_TRUE(root->subtree_property_changed());                            \
-  EXPECT_TRUE(root->layer_tree_host()->LayerNeedsPushPropertiesForTesting(  \
-      root.get()));                                                         \
-  EXPECT_TRUE(child->subtree_property_changed());                           \
-  EXPECT_TRUE(child->layer_tree_host()->LayerNeedsPushPropertiesForTesting( \
-      child.get()));                                                        \
-  EXPECT_TRUE(grand_child->subtree_property_changed());                     \
-  EXPECT_TRUE(                                                              \
-      grand_child->layer_tree_host()->LayerNeedsPushPropertiesForTesting(   \
+#define EXECUTE_AND_VERIFY_SUBTREE_CHANGED(code_to_test)                       \
+  code_to_test;                                                                \
+  root->layer_tree_host()->BuildPropertyTreesForTesting();                     \
+  EXPECT_TRUE(root->subtree_property_changed());                               \
+  EXPECT_TRUE(                                                                 \
+      root->GetLayerTree()->LayerNeedsPushPropertiesForTesting(root.get()));   \
+  EXPECT_TRUE(child->subtree_property_changed());                              \
+  EXPECT_TRUE(                                                                 \
+      child->GetLayerTree()->LayerNeedsPushPropertiesForTesting(child.get())); \
+  EXPECT_TRUE(grand_child->subtree_property_changed());                        \
+  EXPECT_TRUE(grand_child->GetLayerTree()->LayerNeedsPushPropertiesForTesting( \
+      grand_child.get()));
+
+#define EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET(code_to_test)                 \
+  code_to_test;                                                                \
+  EXPECT_FALSE(root->subtree_property_changed());                              \
+  EXPECT_FALSE(                                                                \
+      root->GetLayerTree()->LayerNeedsPushPropertiesForTesting(root.get()));   \
+  EXPECT_FALSE(child->subtree_property_changed());                             \
+  EXPECT_FALSE(                                                                \
+      child->GetLayerTree()->LayerNeedsPushPropertiesForTesting(child.get())); \
+  EXPECT_FALSE(grand_child->subtree_property_changed());                       \
+  EXPECT_FALSE(                                                                \
+      grand_child->GetLayerTree()->LayerNeedsPushPropertiesForTesting(         \
           grand_child.get()));
 
-#define EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET(code_to_test)               \
-  code_to_test;                                                              \
-  EXPECT_FALSE(root->subtree_property_changed());                            \
-  EXPECT_FALSE(root->layer_tree_host()->LayerNeedsPushPropertiesForTesting(  \
-      root.get()));                                                          \
-  EXPECT_FALSE(child->subtree_property_changed());                           \
-  EXPECT_FALSE(child->layer_tree_host()->LayerNeedsPushPropertiesForTesting( \
-      child.get()));                                                         \
-  EXPECT_FALSE(grand_child->subtree_property_changed());                     \
-  EXPECT_FALSE(                                                              \
-      grand_child->layer_tree_host()->LayerNeedsPushPropertiesForTesting(    \
-          grand_child.get()));
-
-#define EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(code_to_test)                  \
-  code_to_test;                                                              \
-  root->layer_tree_host()->BuildPropertyTreesForTesting();                   \
-  EXPECT_TRUE(root->layer_property_changed());                               \
-  EXPECT_FALSE(root->subtree_property_changed());                            \
-  EXPECT_TRUE(root->layer_tree_host()->LayerNeedsPushPropertiesForTesting(   \
-      root.get()));                                                          \
-  EXPECT_FALSE(child->layer_property_changed());                             \
-  EXPECT_FALSE(child->subtree_property_changed());                           \
-  EXPECT_FALSE(child->layer_tree_host()->LayerNeedsPushPropertiesForTesting( \
-      child.get()));                                                         \
-  EXPECT_FALSE(grand_child->layer_property_changed());                       \
-  EXPECT_FALSE(grand_child->subtree_property_changed());                     \
-  EXPECT_FALSE(                                                              \
-      grand_child->layer_tree_host()->LayerNeedsPushPropertiesForTesting(    \
+#define EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(code_to_test)                    \
+  code_to_test;                                                                \
+  root->layer_tree_host()->BuildPropertyTreesForTesting();                     \
+  EXPECT_TRUE(root->layer_property_changed());                                 \
+  EXPECT_FALSE(root->subtree_property_changed());                              \
+  EXPECT_TRUE(                                                                 \
+      root->GetLayerTree()->LayerNeedsPushPropertiesForTesting(root.get()));   \
+  EXPECT_FALSE(child->layer_property_changed());                               \
+  EXPECT_FALSE(child->subtree_property_changed());                             \
+  EXPECT_FALSE(                                                                \
+      child->GetLayerTree()->LayerNeedsPushPropertiesForTesting(child.get())); \
+  EXPECT_FALSE(grand_child->layer_property_changed());                         \
+  EXPECT_FALSE(grand_child->subtree_property_changed());                       \
+  EXPECT_FALSE(                                                                \
+      grand_child->GetLayerTree()->LayerNeedsPushPropertiesForTesting(         \
           grand_child.get()));
 
 namespace cc {
@@ -140,17 +139,18 @@
     proto::LayerProperties props = layer_update.layers(0);
 
     // The |dest| layer needs to be able to lookup the scroll and clip parents.
+    LayerTree* layer_tree = layer_tree_host_->GetLayerTree();
     if (src->inputs_.scroll_parent)
-      layer_tree_host_->RegisterLayer(src->inputs_.scroll_parent);
+      layer_tree->RegisterLayer(src->inputs_.scroll_parent);
     if (src->scroll_children_) {
       for (auto* child : *(src->scroll_children_))
-        layer_tree_host_->RegisterLayer(child);
+        layer_tree->RegisterLayer(child);
     }
     if (src->inputs_.clip_parent)
-      layer_tree_host_->RegisterLayer(src->inputs_.clip_parent);
+      layer_tree->RegisterLayer(src->inputs_.clip_parent);
     if (src->clip_children_) {
       for (auto* child : *(src->clip_children_))
-        layer_tree_host_->RegisterLayer(child);
+        layer_tree->RegisterLayer(child);
     }
     // Reset the LayerTreeHost registration for the |src| layer so
     // it can be re-used for the |dest| layer.
@@ -248,24 +248,24 @@
 
     // Cleanup scroll tree.
     if (src->inputs_.scroll_parent)
-      layer_tree_host_->UnregisterLayer(src->inputs_.scroll_parent);
+      layer_tree->UnregisterLayer(src->inputs_.scroll_parent);
     src->inputs_.scroll_parent = nullptr;
     dest->inputs_.scroll_parent = nullptr;
     if (src->scroll_children_) {
       for (auto* child : *(src->scroll_children_))
-        layer_tree_host_->UnregisterLayer(child);
+        layer_tree->UnregisterLayer(child);
       src->scroll_children_.reset();
       dest->scroll_children_.reset();
     }
 
     // Cleanup clip tree.
     if (src->inputs_.clip_parent)
-      layer_tree_host_->UnregisterLayer(src->inputs_.clip_parent);
+      layer_tree->UnregisterLayer(src->inputs_.clip_parent);
     src->inputs_.clip_parent = nullptr;
     dest->inputs_.clip_parent = nullptr;
     if (src->clip_children_) {
       for (auto* child : *(src->clip_children_))
-        layer_tree_host_->UnregisterLayer(child);
+        layer_tree->UnregisterLayer(child);
       src->clip_children_.reset();
       dest->clip_children_.reset();
     }
@@ -1409,7 +1409,8 @@
   EXPECT_SET_NEEDS_COMMIT(1, child2 = nullptr);
 
   EXPECT_TRUE(
-      layer_tree_host_->LayerNeedsPushPropertiesForTesting(child1.get()));
+      layer_tree_host_->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
+          child1.get()));
 
   EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(nullptr));
 }
@@ -1439,7 +1440,8 @@
   EXPECT_SET_NEEDS_COMMIT(1, child1 = nullptr);
 
   EXPECT_TRUE(
-      layer_tree_host_->LayerNeedsPushPropertiesForTesting(child2.get()));
+      layer_tree_host_->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
+          child2.get()));
 
   EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(nullptr));
 }
diff --git a/cc/layers/picture_layer.cc b/cc/layers/picture_layer.cc
index 081e315..0a3d976 100644
--- a/cc/layers/picture_layer.cc
+++ b/cc/layers/picture_layer.cc
@@ -82,7 +82,7 @@
 }
 
 void PictureLayer::SetNeedsDisplayRect(const gfx::Rect& layer_rect) {
-  DCHECK(!layer_tree_host() || !layer_tree_host()->in_paint_layer_contents());
+  DCHECK(!layer_tree_host() || !GetLayerTree()->in_paint_layer_contents());
   if (recording_source_)
     recording_source_->SetNeedsDisplayRect(layer_rect);
   Layer::SetNeedsDisplayRect(layer_rect);
diff --git a/cc/proto/BUILD.gn b/cc/proto/BUILD.gn
index b50d7252..456ca9a 100644
--- a/cc/proto/BUILD.gn
+++ b/cc/proto/BUILD.gn
@@ -39,6 +39,7 @@
     "layer.proto",
     "layer_position_constraint.proto",
     "layer_selection_bound.proto",
+    "layer_tree.proto",
     "layer_tree_debug_state.proto",
     "layer_tree_host.proto",
     "layer_tree_settings.proto",
diff --git a/cc/proto/layer_tree.proto b/cc/proto/layer_tree.proto
new file mode 100644
index 0000000..790f08e6
--- /dev/null
+++ b/cc/proto/layer_tree.proto
@@ -0,0 +1,14 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+syntax = "proto2";
+
+package cc.proto;
+
+option optimize_for = LITE_RUNTIME;
+
+message LayerTree {
+  repeated int32 layers_that_should_push_properties = 1;
+  optional bool in_paint_layer_contents = 2;
+}
diff --git a/cc/proto/layer_tree_host.proto b/cc/proto/layer_tree_host.proto
index 71bbcf5..7663995 100644
--- a/cc/proto/layer_tree_host.proto
+++ b/cc/proto/layer_tree_host.proto
@@ -7,6 +7,7 @@
 import "display_item.proto";
 import "layer.proto";
 import "layer_selection_bound.proto";
+import "layer_tree.proto";
 import "layer_tree_debug_state.proto";
 import "property_tree.proto";
 import "size.proto";
@@ -51,21 +52,20 @@
   optional bool content_is_suitable_for_gpu_rasterization = 20;
   optional uint32 background_color = 21; /* SkColor */
   optional bool has_transparent_background = 22;
-  optional bool in_paint_layer_contents = 23;
-  optional int32 id = 24;
-  optional bool next_commit_forces_redraw = 25;
-  optional int32 overscroll_elasticity_layer_id = 26;
-  optional int32 page_scale_layer_id = 27;
-  optional int32 inner_viewport_scroll_layer_id = 28;
-  optional int32 outer_viewport_scroll_layer_id = 29;
-  optional LayerSelection selection = 30;
-  optional PropertyTrees property_trees = 31;
-  optional uint32 surface_client_id = 32;
-  optional uint32 next_surface_sequence = 33;
-  optional uint32 wheel_event_listener_properties = 34;
-  optional bool have_scroll_event_handlers = 35;
-  optional uint32 touch_start_or_move_event_listener_properties = 36;
-  repeated int32 layers_that_should_push_properties = 37;
-  optional uint32 touch_end_or_cancel_event_listener_properties = 38;
-  optional SkPictures pictures = 39;
+  optional int32 id = 23;
+  optional bool next_commit_forces_redraw = 24;
+  optional int32 overscroll_elasticity_layer_id = 25;
+  optional int32 page_scale_layer_id = 26;
+  optional int32 inner_viewport_scroll_layer_id = 27;
+  optional int32 outer_viewport_scroll_layer_id = 28;
+  optional LayerSelection selection = 29;
+  optional PropertyTrees property_trees = 30;
+  optional uint32 surface_client_id = 31;
+  optional uint32 next_surface_sequence = 32;
+  optional uint32 wheel_event_listener_properties = 33;
+  optional bool have_scroll_event_handlers = 34;
+  optional uint32 touch_start_or_move_event_listener_properties = 35;
+  optional LayerTree layer_tree = 36;
+  optional uint32 touch_end_or_cancel_event_listener_properties = 37;
+  optional SkPictures pictures = 38;
 }
diff --git a/cc/test/fake_layer_tree_host.cc b/cc/test/fake_layer_tree_host.cc
index 9e68fa33..ac270c9b 100644
--- a/cc/test/fake_layer_tree_host.cc
+++ b/cc/test/fake_layer_tree_host.cc
@@ -89,7 +89,7 @@
 LayerImpl* FakeLayerTreeHost::CommitAndCreateLayerImplTree() {
   TreeSynchronizer::SynchronizeTrees(root_layer(), active_tree());
   active_tree()->SetPropertyTrees(property_trees());
-  TreeSynchronizer::PushLayerProperties(root_layer()->layer_tree_host(),
+  TreeSynchronizer::PushLayerProperties(root_layer()->GetLayerTree(),
                                         active_tree());
   animation_host()->PushPropertiesTo(host_impl_.animation_host());
 
@@ -111,7 +111,7 @@
 LayerImpl* FakeLayerTreeHost::CommitAndCreatePendingTree() {
   TreeSynchronizer::SynchronizeTrees(root_layer(), pending_tree());
   pending_tree()->SetPropertyTrees(property_trees());
-  TreeSynchronizer::PushLayerProperties(root_layer()->layer_tree_host(),
+  TreeSynchronizer::PushLayerProperties(root_layer()->GetLayerTree(),
                                         pending_tree());
   animation_host()->PushPropertiesTo(host_impl_.animation_host());
 
diff --git a/cc/trees/layer_tree.cc b/cc/trees/layer_tree.cc
new file mode 100644
index 0000000..83537d0
--- /dev/null
+++ b/cc/trees/layer_tree.cc
@@ -0,0 +1,89 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/auto_reset.h"
+#include "cc/animation/animation_host.h"
+#include "cc/layers/layer.h"
+#include "cc/proto/layer_tree.pb.h"
+#include "cc/trees/layer_tree.h"
+
+namespace cc {
+
+LayerTree::LayerTree(std::unique_ptr<AnimationHost> animation_host)
+    : in_paint_layer_contents_(false),
+      animation_host_(std::move(animation_host)) {
+  DCHECK(animation_host_);
+}
+
+LayerTree::~LayerTree() {}
+
+void LayerTree::RegisterLayer(Layer* layer) {
+  DCHECK(!LayerById(layer->id()));
+  DCHECK(!in_paint_layer_contents_);
+  layer_id_map_[layer->id()] = layer;
+  if (layer->element_id()) {
+    animation_host_->RegisterElement(layer->element_id(),
+                                     ElementListType::ACTIVE);
+  }
+}
+
+void LayerTree::UnregisterLayer(Layer* layer) {
+  DCHECK(LayerById(layer->id()));
+  DCHECK(!in_paint_layer_contents_);
+  if (layer->element_id()) {
+    animation_host_->UnregisterElement(layer->element_id(),
+                                       ElementListType::ACTIVE);
+  }
+  RemoveLayerShouldPushProperties(layer);
+  layer_id_map_.erase(layer->id());
+}
+
+Layer* LayerTree::LayerById(int id) const {
+  LayerIdMap::const_iterator iter = layer_id_map_.find(id);
+  return iter != layer_id_map_.end() ? iter->second : nullptr;
+}
+
+bool LayerTree::UpdateLayers(const LayerList& update_layer_list,
+                             bool* content_is_suitable_for_gpu) {
+  base::AutoReset<bool> painting(&in_paint_layer_contents_, true);
+  bool did_paint_content = false;
+  for (const auto& layer : update_layer_list) {
+    did_paint_content |= layer->Update();
+    *content_is_suitable_for_gpu &= layer->IsSuitableForGpuRasterization();
+  }
+  return did_paint_content;
+}
+
+void LayerTree::AddLayerShouldPushProperties(Layer* layer) {
+  layers_that_should_push_properties_.insert(layer);
+}
+
+void LayerTree::RemoveLayerShouldPushProperties(Layer* layer) {
+  layers_that_should_push_properties_.erase(layer);
+}
+
+std::unordered_set<Layer*>& LayerTree::LayersThatShouldPushProperties() {
+  return layers_that_should_push_properties_;
+}
+
+bool LayerTree::LayerNeedsPushPropertiesForTesting(Layer* layer) const {
+  return layers_that_should_push_properties_.find(layer) !=
+         layers_that_should_push_properties_.end();
+}
+
+void LayerTree::ToProtobuf(proto::LayerTree* proto) {
+  for (auto* layer : layers_that_should_push_properties_) {
+    proto->add_layers_that_should_push_properties(layer->id());
+  }
+  proto->set_in_paint_layer_contents(in_paint_layer_contents());
+}
+
+void LayerTree::FromProtobuf(const proto::LayerTree& proto) {
+  for (auto layer_id : proto.layers_that_should_push_properties()) {
+    AddLayerShouldPushProperties(layer_id_map_[layer_id]);
+  }
+  in_paint_layer_contents_ = proto.in_paint_layer_contents();
+}
+
+}  // namespace cc
diff --git a/cc/trees/layer_tree.h b/cc/trees/layer_tree.h
new file mode 100644
index 0000000..bb7e3d2
--- /dev/null
+++ b/cc/trees/layer_tree.h
@@ -0,0 +1,68 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CC_TREES_LAYER_TREE_H_
+#define CC_TREES_LAYER_TREE_H_
+
+#include <unordered_map>
+#include <unordered_set>
+
+#include "base/macros.h"
+#include "cc/base/cc_export.h"
+
+namespace cc {
+
+namespace proto {
+class LayerTree;
+class LayerUpdate;
+}
+
+class AnimationHost;
+class Layer;
+
+class CC_EXPORT LayerTree {
+ public:
+  using LayerSet = std::unordered_set<Layer*>;
+  using LayerIdMap = std::unordered_map<int, Layer*>;
+
+  explicit LayerTree(std::unique_ptr<AnimationHost> animation_host);
+  ~LayerTree();
+
+  void RegisterLayer(Layer* layer);
+  void UnregisterLayer(Layer* layer);
+  Layer* LayerById(int id) const;
+  bool UpdateLayers(const LayerList& update_layer_list,
+                    bool* content_is_suitable_for_gpu);
+
+  void AddLayerShouldPushProperties(Layer* layer);
+  void RemoveLayerShouldPushProperties(Layer* layer);
+  std::unordered_set<Layer*>& LayersThatShouldPushProperties();
+  bool LayerNeedsPushPropertiesForTesting(Layer* layer) const;
+
+  void ToProtobuf(proto::LayerTree* proto);
+  void FromProtobuf(const proto::LayerTree& proto);
+
+  AnimationHost* animation_host() const { return animation_host_.get(); }
+
+  bool in_paint_layer_contents() const { return in_paint_layer_contents_; }
+
+ private:
+  friend class LayerTreeHostSerializationTest;
+
+  // Set of layers that need to push properties.
+  LayerSet layers_that_should_push_properties_;
+
+  // Layer id to Layer map.
+  LayerIdMap layer_id_map_;
+
+  bool in_paint_layer_contents_;
+
+  std::unique_ptr<AnimationHost> animation_host_;
+
+  DISALLOW_COPY_AND_ASSIGN(LayerTree);
+};
+
+}  // namespace cc
+
+#endif  // CC_TREES_LAYER_TREE_H_
diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc
index f295efcf..ffab7dff 100644
--- a/cc/trees/layer_tree_host.cc
+++ b/cc/trees/layer_tree_host.cc
@@ -14,7 +14,6 @@
 #include <unordered_map>
 
 #include "base/atomic_sequence_num.h"
-#include "base/auto_reset.h"
 #include "base/bind.h"
 #include "base/command_line.h"
 #include "base/location.h"
@@ -45,6 +44,7 @@
 #include "cc/layers/layer_proto_converter.h"
 #include "cc/layers/painted_scrollbar_layer.h"
 #include "cc/proto/gfx_conversions.h"
+#include "cc/proto/layer_tree.pb.h"
 #include "cc/proto/layer_tree_host.pb.h"
 #include "cc/resources/ui_resource_request.h"
 #include "cc/scheduler/begin_frame_source.h"
@@ -70,20 +70,19 @@
 
 Layer* UpdateAndGetLayer(Layer* current_layer,
                          int layer_id,
-                         const std::unordered_map<int, Layer*>& layer_id_map) {
+                         LayerTree* layer_tree) {
   if (layer_id == Layer::INVALID_ID) {
     if (current_layer)
       current_layer->SetLayerTreeHost(nullptr);
 
     return nullptr;
   }
-
-  auto layer_it = layer_id_map.find(layer_id);
-  DCHECK(layer_it != layer_id_map.end());
-  if (current_layer && current_layer != layer_it->second)
+  Layer* layer = layer_tree->LayerById(layer_id);
+  DCHECK(layer);
+  if (current_layer && current_layer != layer)
     current_layer->SetLayerTreeHost(nullptr);
 
-  return layer_it->second;
+  return layer;
 }
 
 std::unique_ptr<base::trace_event::TracedValue>
@@ -242,9 +241,7 @@
       has_transparent_background_(false),
       have_scroll_event_handlers_(false),
       event_listener_properties_(),
-      animation_host_(std::move(params->animation_host)),
       did_complete_scale_animation_(false),
-      in_paint_layer_contents_(false),
       id_(s_layer_tree_host_sequence_number.GetNext() + 1),
       next_commit_forces_redraw_(false),
       shared_bitmap_manager_(params->shared_bitmap_manager),
@@ -252,11 +249,11 @@
       task_graph_runner_(params->task_graph_runner),
       image_serialization_processor_(params->image_serialization_processor),
       surface_client_id_(0u),
-      next_surface_sequence_(1u) {
+      next_surface_sequence_(1u),
+      layer_tree_(std::move(params->animation_host)) {
   DCHECK(task_graph_runner_);
 
-  DCHECK(animation_host_);
-  animation_host_->SetMutatorHostClient(this);
+  layer_tree_.animation_host()->SetMutatorHostClient(this);
 
   rendering_stats_instrumentation_->set_record_rendering_stats(
       debug_state_.RecordRenderingStats());
@@ -367,13 +364,14 @@
   proxy_ = std::move(proxy);
   proxy_->Start(std::move(external_begin_frame_source));
 
-  animation_host_->SetSupportsScrollAnimations(proxy_->SupportsImplScrolling());
+  layer_tree_.animation_host()->SetSupportsScrollAnimations(
+      proxy_->SupportsImplScrolling());
 }
 
 LayerTreeHost::~LayerTreeHost() {
   TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost");
 
-  animation_host_->SetMutatorHostClient(nullptr);
+  layer_tree_.animation_host()->SetMutatorHostClient(nullptr);
 
   if (root_layer_.get())
     root_layer_->SetLayerTreeHost(NULL);
@@ -551,7 +549,7 @@
   {
     TRACE_EVENT0("cc", "LayerTreeHost::PushProperties");
 
-    TreeSynchronizer::PushLayerProperties(this, sync_tree);
+    TreeSynchronizer::PushLayerProperties(&layer_tree_, sync_tree);
 
     // This must happen after synchronizing property trees and after push
     // properties, which updates property tree indices, but before animation
@@ -562,7 +560,7 @@
 
     TRACE_EVENT0("cc", "LayerTreeHost::AnimationHost::PushProperties");
     DCHECK(host_impl->animation_host());
-    animation_host_->PushPropertiesTo(host_impl->animation_host());
+    layer_tree_.animation_host()->PushPropertiesTo(host_impl->animation_host());
   }
 
   // This must happen after synchronizing property trees and after pushing
@@ -649,7 +647,7 @@
 
   const bool supports_impl_scrolling = task_runner_provider_->HasImplThread();
   std::unique_ptr<AnimationHost> animation_host_impl =
-      animation_host_->CreateImplInstance(supports_impl_scrolling);
+      layer_tree_.animation_host()->CreateImplInstance(supports_impl_scrolling);
 
   std::unique_ptr<LayerTreeHostImpl> host_impl = LayerTreeHostImpl::Create(
       settings_, client, task_runner_provider_.get(),
@@ -754,7 +752,7 @@
 void LayerTreeHost::SetAnimationEvents(
     std::unique_ptr<AnimationEvents> events) {
   DCHECK(task_runner_provider_->IsMainThread());
-  animation_host_->SetAnimationEvents(std::move(events));
+  layer_tree_.animation_host()->SetAnimationEvents(std::move(events));
 }
 
 void LayerTreeHost::SetRootLayer(scoped_refptr<Layer> root_layer) {
@@ -1049,13 +1047,9 @@
   for (const auto& layer : update_layer_list)
     layer->SavePaintProperties();
 
-  base::AutoReset<bool> painting(&in_paint_layer_contents_, true);
-  bool did_paint_content = false;
   bool content_is_suitable_for_gpu = true;
-  for (const auto& layer : update_layer_list) {
-    did_paint_content |= layer->Update();
-    content_is_suitable_for_gpu &= layer->IsSuitableForGpuRasterization();
-  }
+  bool did_paint_content =
+      layer_tree_.UpdateLayers(update_layer_list, &content_is_suitable_for_gpu);
 
   if (content_is_suitable_for_gpu) {
     ++num_consecutive_frames_suitable_for_gpu_;
@@ -1154,10 +1148,11 @@
 }
 
 void LayerTreeHost::AnimateLayers(base::TimeTicks monotonic_time) {
-  std::unique_ptr<AnimationEvents> events = animation_host_->CreateEvents();
+  AnimationHost* animation_host = layer_tree_.animation_host();
+  std::unique_ptr<AnimationEvents> events = animation_host->CreateEvents();
 
-  if (animation_host_->AnimateLayers(monotonic_time))
-    animation_host_->UpdateAnimationState(true, events.get());
+  if (animation_host->AnimateLayers(monotonic_time))
+    animation_host->UpdateAnimationState(true, events.get());
 
   if (!events->events_.empty())
     property_trees_.needs_rebuild = true;
@@ -1316,8 +1311,7 @@
 }
 
 Layer* LayerTreeHost::LayerById(int id) const {
-  LayerIdMap::const_iterator iter = layer_id_map_.find(id);
-  return iter != layer_id_map_.end() ? iter->second : nullptr;
+  return layer_tree_.LayerById(id);
 }
 
 Layer* LayerTreeHost::LayerByElementId(ElementId element_id) const {
@@ -1339,44 +1333,6 @@
   element_layers_map_.erase(layer->element_id());
 }
 
-void LayerTreeHost::AddLayerShouldPushProperties(Layer* layer) {
-  layers_that_should_push_properties_.insert(layer);
-}
-
-void LayerTreeHost::RemoveLayerShouldPushProperties(Layer* layer) {
-  layers_that_should_push_properties_.erase(layer);
-}
-
-std::unordered_set<Layer*>& LayerTreeHost::LayersThatShouldPushProperties() {
-  return layers_that_should_push_properties_;
-}
-
-bool LayerTreeHost::LayerNeedsPushPropertiesForTesting(Layer* layer) {
-  return layers_that_should_push_properties_.find(layer) !=
-         layers_that_should_push_properties_.end();
-}
-
-void LayerTreeHost::RegisterLayer(Layer* layer) {
-  DCHECK(!LayerById(layer->id()));
-  DCHECK(!in_paint_layer_contents_);
-  layer_id_map_[layer->id()] = layer;
-  if (layer->element_id()) {
-    animation_host_->RegisterElement(layer->element_id(),
-                                     ElementListType::ACTIVE);
-  }
-}
-
-void LayerTreeHost::UnregisterLayer(Layer* layer) {
-  DCHECK(LayerById(layer->id()));
-  DCHECK(!in_paint_layer_contents_);
-  if (layer->element_id()) {
-    animation_host_->UnregisterElement(layer->element_id(),
-                                       ElementListType::ACTIVE);
-  }
-  RemoveLayerShouldPushProperties(layer);
-  layer_id_map_.erase(layer->id());
-}
-
 bool LayerTreeHost::IsElementInList(ElementId element_id,
                                     ElementListType list_type) const {
   return list_type == ElementListType::ACTIVE && LayerByElementId(element_id);
@@ -1555,10 +1511,10 @@
   LayerProtoConverter::SerializeLayerHierarchy(root_layer_,
                                                proto->mutable_root_layer());
 
-  // layers_that_should_push_properties_ should be serialized before layer
-  // properties because it is cleared during the properties serialization.
-  for (auto* layer : layers_that_should_push_properties_)
-    proto->add_layers_that_should_push_properties(layer->id());
+  // Serialize the LayerTree before serializing the properties. During layer
+  // property serialization, we clear the list |layer_that_should_properties_|
+  // from the LayerTree.
+  layer_tree_.ToProtobuf(proto->mutable_layer_tree());
 
   LayerProtoConverter::SerializeLayerProperties(this,
                                                 proto->mutable_layer_updates());
@@ -1594,7 +1550,6 @@
   proto->set_touch_end_or_cancel_event_listener_properties(
       static_cast<uint32_t>(
           event_listener_properties(EventListenerClass::kTouchEndOrCancel)));
-  proto->set_in_paint_layer_contents(in_paint_layer_contents_);
   proto->set_id(id_);
   proto->set_next_commit_forces_redraw(next_commit_forces_redraw_);
 
@@ -1625,7 +1580,6 @@
 
 void LayerTreeHost::FromProtobufForCommit(const proto::LayerTreeHost& proto) {
   DCHECK(client_picture_cache_);
-
   needs_full_tree_sync_ = proto.needs_full_tree_sync();
   needs_meta_info_recomputation_ = proto.needs_meta_info_recomputation();
   source_frame_number_ = proto.source_frame_number();
@@ -1638,8 +1592,7 @@
     root_layer_ = new_root_layer;
   }
 
-  for (auto layer_id : proto.layers_that_should_push_properties())
-    layers_that_should_push_properties_.insert(layer_id_map_[layer_id]);
+  layer_tree_.FromProtobuf(proto.layer_tree());
 
   // Ensure ClientPictureCache contains all the necessary SkPictures before
   // deserializing the properties.
@@ -1683,23 +1636,22 @@
       EventListenerClass::kTouchEndOrCancel)] =
       static_cast<EventListenerProperties>(
           proto.touch_end_or_cancel_event_listener_properties());
-  in_paint_layer_contents_ = proto.in_paint_layer_contents();
   id_ = proto.id();
   next_commit_forces_redraw_ = proto.next_commit_forces_redraw();
 
   hud_layer_ = static_cast<HeadsUpDisplayLayer*>(
-      UpdateAndGetLayer(hud_layer_.get(), proto.hud_layer_id(), layer_id_map_));
+      UpdateAndGetLayer(hud_layer_.get(), proto.hud_layer_id(), &layer_tree_));
   overscroll_elasticity_layer_ =
       UpdateAndGetLayer(overscroll_elasticity_layer_.get(),
-                        proto.overscroll_elasticity_layer_id(), layer_id_map_);
+                        proto.overscroll_elasticity_layer_id(), &layer_tree_);
   page_scale_layer_ = UpdateAndGetLayer(
-      page_scale_layer_.get(), proto.page_scale_layer_id(), layer_id_map_);
+      page_scale_layer_.get(), proto.page_scale_layer_id(), &layer_tree_);
   inner_viewport_scroll_layer_ =
       UpdateAndGetLayer(inner_viewport_scroll_layer_.get(),
-                        proto.inner_viewport_scroll_layer_id(), layer_id_map_);
+                        proto.inner_viewport_scroll_layer_id(), &layer_tree_);
   outer_viewport_scroll_layer_ =
       UpdateAndGetLayer(outer_viewport_scroll_layer_.get(),
-                        proto.outer_viewport_scroll_layer_id(), layer_id_map_);
+                        proto.outer_viewport_scroll_layer_id(), &layer_tree_);
 
   LayerSelectionFromProtobuf(&selection_, proto.selection());
 
@@ -1721,4 +1673,8 @@
   next_surface_sequence_ = proto.next_surface_sequence();
 }
 
+AnimationHost* LayerTreeHost::animation_host() const {
+  return layer_tree_.animation_host();
+}
+
 }  // namespace cc
diff --git a/cc/trees/layer_tree_host.h b/cc/trees/layer_tree_host.h
index 9cdc06c3..5ca13ec 100644
--- a/cc/trees/layer_tree_host.h
+++ b/cc/trees/layer_tree_host.h
@@ -40,6 +40,7 @@
 #include "cc/resources/scoped_ui_resource.h"
 #include "cc/surfaces/surface_sequence.h"
 #include "cc/trees/compositor_mode.h"
+#include "cc/trees/layer_tree.h"
 #include "cc/trees/layer_tree_host_client.h"
 #include "cc/trees/layer_tree_settings.h"
 #include "cc/trees/mutator_host_client.h"
@@ -295,9 +296,7 @@
   TaskRunnerProvider* task_runner_provider() const {
     return task_runner_provider_.get();
   }
-  AnimationHost* animation_host() const { return animation_host_.get(); }
-
-  bool in_paint_layer_contents() const { return in_paint_layer_contents_; }
+  AnimationHost* animation_host() const;
 
   bool has_output_surface() const { return !!current_output_surface_; }
 
@@ -357,13 +356,6 @@
   void AddToElementMap(Layer* layer);
   void RemoveFromElementMap(Layer* layer);
 
-  void AddLayerShouldPushProperties(Layer* layer);
-  void RemoveLayerShouldPushProperties(Layer* layer);
-  std::unordered_set<Layer*>& LayersThatShouldPushProperties();
-  bool LayerNeedsPushPropertiesForTesting(Layer* layer);
-
-  void RegisterLayer(Layer* layer);
-  void UnregisterLayer(Layer* layer);
   // MutatorHostClient implementation.
   bool IsElementInList(ElementId element_id,
                        ElementListType list_type) const override;
@@ -432,6 +424,9 @@
     return client_picture_cache_ ? client_picture_cache_.get() : nullptr;
   }
 
+  LayerTree* GetLayerTree() { return &layer_tree_; }
+  const LayerTree* GetLayerTree() const { return &layer_tree_; }
+
  protected:
   LayerTreeHost(InitParams* params, CompositorMode mode);
   void InitializeThreaded(
@@ -567,16 +562,12 @@
   EventListenerProperties event_listener_properties_[static_cast<size_t>(
       EventListenerClass::kNumClasses)];
 
-  std::unique_ptr<AnimationHost> animation_host_;
-
   std::unique_ptr<PendingPageScaleAnimation> pending_page_scale_animation_;
 
   // If set, then page scale animation has completed, but the client hasn't been
   // notified about it yet.
   bool did_complete_scale_animation_;
 
-  bool in_paint_layer_contents_;
-
   int id_;
   bool next_commit_forces_redraw_;
 
@@ -600,19 +591,16 @@
 
   PropertyTrees property_trees_;
 
-  using LayerIdMap = std::unordered_map<int, Layer*>;
-  LayerIdMap layer_id_map_;
-
   using ElementLayersMap = std::unordered_map<ElementId, Layer*, ElementIdHash>;
   ElementLayersMap element_layers_map_;
 
-  // Set of layers that need to push properties.
-  std::unordered_set<Layer*> layers_that_should_push_properties_;
-
   uint32_t surface_client_id_;
   uint32_t next_surface_sequence_;
   uint32_t num_consecutive_frames_suitable_for_gpu_ = 0;
 
+  // Layer tree that hold layers.
+  LayerTree layer_tree_;
+
   DISALLOW_COPY_AND_ASSIGN(LayerTreeHost);
 };
 
diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc
index baa1618b..da17382 100644
--- a/cc/trees/layer_tree_host_unittest.cc
+++ b/cc/trees/layer_tree_host_unittest.cc
@@ -3055,7 +3055,7 @@
     Layer::PushPropertiesTo(layer);
     push_properties_count_++;
     if (persist_needs_push_properties_) {
-      layer_tree_host()->AddLayerShouldPushProperties(this);
+      GetLayerTree()->AddLayerShouldPushProperties(this);
     }
   }
 
@@ -3142,35 +3142,33 @@
 
     // The scrollbar layer always needs to be pushed.
     if (root_->layer_tree_host()) {
-      EXPECT_FALSE(root_->layer_tree_host()->LayerNeedsPushPropertiesForTesting(
+      EXPECT_FALSE(root_->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
           root_.get()));
     }
     if (child2_->layer_tree_host()) {
-      EXPECT_FALSE(
-          child2_->layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-              child2_.get()));
+      EXPECT_FALSE(child2_->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
+          child2_.get()));
     }
     if (leaf_always_pushing_layer_->layer_tree_host()) {
-      EXPECT_TRUE(leaf_always_pushing_layer_->layer_tree_host()
+      EXPECT_TRUE(leaf_always_pushing_layer_->GetLayerTree()
                       ->LayerNeedsPushPropertiesForTesting(
                           leaf_always_pushing_layer_.get()));
     }
 
     // child_ and grandchild_ don't persist their need to push properties.
     if (child_->layer_tree_host()) {
-      EXPECT_FALSE(
-          child_->layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-              child_.get()));
+      EXPECT_FALSE(child_->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
+          child_.get()));
     }
     if (grandchild_->layer_tree_host()) {
       EXPECT_FALSE(
-          grandchild_->layer_tree_host()->LayerNeedsPushPropertiesForTesting(
+          grandchild_->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
               grandchild_.get()));
     }
 
     if (other_root_->layer_tree_host()) {
       EXPECT_FALSE(
-          other_root_->layer_tree_host()->LayerNeedsPushPropertiesForTesting(
+          other_root_->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
               other_root_.get()));
     }
 
@@ -3522,8 +3520,10 @@
 
         scrollbar_layer_->SetBounds(gfx::Size(30, 30));
 
-        EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            scrollbar_layer_.get()));
+        EXPECT_TRUE(
+            layer_tree_host()
+                ->GetLayerTree()
+                ->LayerNeedsPushPropertiesForTesting(scrollbar_layer_.get()));
         layer_tree_host()->SetNeedsCommit();
 
         scrollbar_layer_->reset_push_properties_count();
@@ -3559,6 +3559,7 @@
   }
 
   void DidCommitAndDrawFrame() override {
+    LayerTree* layer_tree = layer_tree_host()->GetLayerTree();
     switch (layer_tree_host()->source_frame_number()) {
       case 0:
         break;
@@ -3568,9 +3569,9 @@
         // is made during this, however, it needs to be pushed in the upcoming
         // commit.
         EXPECT_FALSE(
-            layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get()));
-        EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            child_.get()));
+            layer_tree->LayerNeedsPushPropertiesForTesting(root_.get()));
+        EXPECT_FALSE(
+            layer_tree->LayerNeedsPushPropertiesForTesting(child_.get()));
         EXPECT_EQ(0, root_->NumDescendantsThatDrawContent());
         root_->reset_push_properties_count();
         child_->reset_push_properties_count();
@@ -3579,18 +3580,19 @@
         EXPECT_EQ(0u, root_->push_properties_count());
         EXPECT_EQ(0u, child_->push_properties_count());
         EXPECT_TRUE(
-            layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get()));
-        EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            child_.get()));
+            layer_tree->LayerNeedsPushPropertiesForTesting(root_.get()));
+        EXPECT_TRUE(
+
+            layer_tree->LayerNeedsPushPropertiesForTesting(child_.get()));
         break;
       }
       case 2:
         EXPECT_EQ(1u, root_->push_properties_count());
         EXPECT_EQ(1u, child_->push_properties_count());
         EXPECT_FALSE(
-            layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get()));
-        EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            child_.get()));
+            layer_tree->LayerNeedsPushPropertiesForTesting(root_.get()));
+        EXPECT_FALSE(
+            layer_tree->LayerNeedsPushPropertiesForTesting(child_.get()));
         EndTest();
         break;
     }
@@ -3657,16 +3659,24 @@
       case 0:
         // All layers will need push properties as we set their layer tree host
         layer_tree_host()->SetRootLayer(root_);
+        EXPECT_TRUE(layer_tree_host()
+                        ->GetLayerTree()
+                        ->LayerNeedsPushPropertiesForTesting(root_.get()));
+        EXPECT_TRUE(layer_tree_host()
+                        ->GetLayerTree()
+                        ->LayerNeedsPushPropertiesForTesting(child_.get()));
         EXPECT_TRUE(
-            layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get()));
-        EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            child_.get()));
-        EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            grandchild1_.get()));
-        EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            grandchild2_.get()));
-        EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            grandchild3_.get()));
+            layer_tree_host()
+                ->GetLayerTree()
+                ->LayerNeedsPushPropertiesForTesting(grandchild1_.get()));
+        EXPECT_TRUE(
+            layer_tree_host()
+                ->GetLayerTree()
+                ->LayerNeedsPushPropertiesForTesting(grandchild2_.get()));
+        EXPECT_TRUE(
+            layer_tree_host()
+                ->GetLayerTree()
+                ->LayerNeedsPushPropertiesForTesting(grandchild3_.get()));
         break;
       case 1:
         EndTest();
@@ -3687,71 +3697,105 @@
         layer_tree_host()->SetRootLayer(root_);
         break;
       case 1:
+        EXPECT_FALSE(layer_tree_host()
+                         ->GetLayerTree()
+                         ->LayerNeedsPushPropertiesForTesting(root_.get()));
+        EXPECT_FALSE(layer_tree_host()
+                         ->GetLayerTree()
+                         ->LayerNeedsPushPropertiesForTesting(child_.get()));
         EXPECT_FALSE(
-            layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get()));
-        EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            child_.get()));
-        EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            grandchild1_.get()));
-        EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            grandchild2_.get()));
-        EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            grandchild3_.get()));
+            layer_tree_host()
+                ->GetLayerTree()
+                ->LayerNeedsPushPropertiesForTesting(grandchild1_.get()));
+        EXPECT_FALSE(
+            layer_tree_host()
+                ->GetLayerTree()
+                ->LayerNeedsPushPropertiesForTesting(grandchild2_.get()));
+        EXPECT_FALSE(
+            layer_tree_host()
+                ->GetLayerTree()
+                ->LayerNeedsPushPropertiesForTesting(grandchild3_.get()));
 
         grandchild1_->RemoveFromParent();
         grandchild1_->SetPosition(gfx::PointF(1.f, 1.f));
 
+        EXPECT_FALSE(layer_tree_host()
+                         ->GetLayerTree()
+                         ->LayerNeedsPushPropertiesForTesting(root_.get()));
+        EXPECT_FALSE(layer_tree_host()
+                         ->GetLayerTree()
+                         ->LayerNeedsPushPropertiesForTesting(child_.get()));
         EXPECT_FALSE(
-            layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get()));
-        EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            child_.get()));
-        EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            grandchild2_.get()));
-        EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            grandchild3_.get()));
+            layer_tree_host()
+                ->GetLayerTree()
+                ->LayerNeedsPushPropertiesForTesting(grandchild2_.get()));
+        EXPECT_FALSE(
+            layer_tree_host()
+                ->GetLayerTree()
+                ->LayerNeedsPushPropertiesForTesting(grandchild3_.get()));
 
         child_->AddChild(grandchild1_);
 
+        EXPECT_FALSE(layer_tree_host()
+                         ->GetLayerTree()
+                         ->LayerNeedsPushPropertiesForTesting(root_.get()));
+        EXPECT_FALSE(layer_tree_host()
+                         ->GetLayerTree()
+                         ->LayerNeedsPushPropertiesForTesting(child_.get()));
+        EXPECT_TRUE(
+            layer_tree_host()
+                ->GetLayerTree()
+                ->LayerNeedsPushPropertiesForTesting(grandchild1_.get()));
         EXPECT_FALSE(
-            layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get()));
-        EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            child_.get()));
-        EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            grandchild1_.get()));
-        EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            grandchild2_.get()));
-        EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            grandchild3_.get()));
+            layer_tree_host()
+                ->GetLayerTree()
+                ->LayerNeedsPushPropertiesForTesting(grandchild2_.get()));
+        EXPECT_FALSE(
+            layer_tree_host()
+                ->GetLayerTree()
+                ->LayerNeedsPushPropertiesForTesting(grandchild3_.get()));
 
         grandchild2_->SetPosition(gfx::PointF(1.f, 1.f));
 
+        EXPECT_FALSE(layer_tree_host()
+                         ->GetLayerTree()
+                         ->LayerNeedsPushPropertiesForTesting(root_.get()));
+        EXPECT_FALSE(layer_tree_host()
+                         ->GetLayerTree()
+                         ->LayerNeedsPushPropertiesForTesting(child_.get()));
+        EXPECT_TRUE(
+            layer_tree_host()
+                ->GetLayerTree()
+                ->LayerNeedsPushPropertiesForTesting(grandchild1_.get()));
+        EXPECT_TRUE(
+            layer_tree_host()
+                ->GetLayerTree()
+                ->LayerNeedsPushPropertiesForTesting(grandchild2_.get()));
         EXPECT_FALSE(
-            layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get()));
-        EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            child_.get()));
-        EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            grandchild1_.get()));
-        EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            grandchild2_.get()));
-        EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            grandchild3_.get()));
+            layer_tree_host()
+                ->GetLayerTree()
+                ->LayerNeedsPushPropertiesForTesting(grandchild3_.get()));
 
         // grandchild2_ will still need a push properties.
         grandchild1_->RemoveFromParent();
 
-        EXPECT_FALSE(
-            layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get()));
-        EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            child_.get()));
+        EXPECT_FALSE(layer_tree_host()
+                         ->GetLayerTree()
+                         ->LayerNeedsPushPropertiesForTesting(root_.get()));
+        EXPECT_FALSE(layer_tree_host()
+                         ->GetLayerTree()
+                         ->LayerNeedsPushPropertiesForTesting(child_.get()));
 
         // grandchild3_ does not need a push properties, so recursing should
         // no longer be needed.
         grandchild2_->RemoveFromParent();
 
-        EXPECT_FALSE(
-            layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get()));
-        EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            child_.get()));
+        EXPECT_FALSE(layer_tree_host()
+                         ->GetLayerTree()
+                         ->LayerNeedsPushPropertiesForTesting(root_.get()));
+        EXPECT_FALSE(layer_tree_host()
+                         ->GetLayerTree()
+                         ->LayerNeedsPushPropertiesForTesting(child_.get()));
         EndTest();
         break;
     }
@@ -3764,6 +3808,7 @@
     : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren {
  protected:
   void DidCommitAndDrawFrame() override {
+    LayerTree* layer_tree = layer_tree_host()->GetLayerTree();
     int last_source_frame_number = layer_tree_host()->source_frame_number() - 1;
     switch (last_source_frame_number) {
       case 0:
@@ -3773,32 +3818,32 @@
         break;
       case 1:
         EXPECT_FALSE(
-            layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get()));
-        EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            child_.get()));
-        EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            grandchild1_.get()));
-        EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            grandchild2_.get()));
-        EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            grandchild3_.get()));
+            layer_tree->LayerNeedsPushPropertiesForTesting(root_.get()));
+        EXPECT_FALSE(
+            layer_tree->LayerNeedsPushPropertiesForTesting(child_.get()));
+        EXPECT_TRUE(
+            layer_tree->LayerNeedsPushPropertiesForTesting(grandchild1_.get()));
+        EXPECT_TRUE(
+            layer_tree->LayerNeedsPushPropertiesForTesting(grandchild2_.get()));
+        EXPECT_FALSE(
+            layer_tree->LayerNeedsPushPropertiesForTesting(grandchild3_.get()));
 
         // grandchild2_ will still need a push properties.
         grandchild1_->RemoveFromParent();
 
         EXPECT_FALSE(
-            layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get()));
-        EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            child_.get()));
+            layer_tree->LayerNeedsPushPropertiesForTesting(root_.get()));
+        EXPECT_FALSE(
+            layer_tree->LayerNeedsPushPropertiesForTesting(child_.get()));
 
         // grandchild3_ does not need a push properties, so recursing should
         // no longer be needed.
         grandchild2_->RemoveFromParent();
 
         EXPECT_FALSE(
-            layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get()));
-        EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            child_.get()));
+            layer_tree->LayerNeedsPushPropertiesForTesting(root_.get()));
+        EXPECT_FALSE(
+            layer_tree->LayerNeedsPushPropertiesForTesting(child_.get()));
         EndTest();
         break;
     }
@@ -3812,6 +3857,7 @@
     : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren {
  protected:
   void DidCommitAndDrawFrame() override {
+    LayerTree* layer_tree = layer_tree_host()->GetLayerTree();
     int last_source_frame_number = layer_tree_host()->source_frame_number() - 1;
     switch (last_source_frame_number) {
       case 0:
@@ -3819,15 +3865,15 @@
         break;
       case 1:
         EXPECT_FALSE(
-            layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get()));
-        EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            child_.get()));
-        EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            grandchild1_.get()));
-        EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            grandchild2_.get()));
-        EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            grandchild3_.get()));
+            layer_tree->LayerNeedsPushPropertiesForTesting(root_.get()));
+        EXPECT_FALSE(
+            layer_tree->LayerNeedsPushPropertiesForTesting(child_.get()));
+        EXPECT_FALSE(
+            layer_tree->LayerNeedsPushPropertiesForTesting(grandchild1_.get()));
+        EXPECT_FALSE(
+            layer_tree->LayerNeedsPushPropertiesForTesting(grandchild2_.get()));
+        EXPECT_FALSE(
+            layer_tree->LayerNeedsPushPropertiesForTesting(grandchild3_.get()));
 
         // Change grandchildren while their parent is not in the tree.
         child_->RemoveFromParent();
@@ -3836,36 +3882,36 @@
         root_->AddChild(child_);
 
         EXPECT_FALSE(
-            layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get()));
-        EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            child_.get()));
-        EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            grandchild1_.get()));
-        EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            grandchild2_.get()));
-        EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            grandchild3_.get()));
+            layer_tree->LayerNeedsPushPropertiesForTesting(root_.get()));
+        EXPECT_TRUE(
+            layer_tree->LayerNeedsPushPropertiesForTesting(child_.get()));
+        EXPECT_TRUE(
+            layer_tree->LayerNeedsPushPropertiesForTesting(grandchild1_.get()));
+        EXPECT_TRUE(
+            layer_tree->LayerNeedsPushPropertiesForTesting(grandchild2_.get()));
+        EXPECT_TRUE(
+            layer_tree->LayerNeedsPushPropertiesForTesting(grandchild3_.get()));
 
         grandchild1_->RemoveFromParent();
 
         EXPECT_FALSE(
-            layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get()));
-        EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            child_.get()));
+            layer_tree->LayerNeedsPushPropertiesForTesting(root_.get()));
+        EXPECT_TRUE(
+            layer_tree->LayerNeedsPushPropertiesForTesting(child_.get()));
 
         grandchild2_->RemoveFromParent();
 
         EXPECT_FALSE(
-            layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get()));
-        EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            child_.get()));
+            layer_tree->LayerNeedsPushPropertiesForTesting(root_.get()));
+        EXPECT_TRUE(
+            layer_tree->LayerNeedsPushPropertiesForTesting(child_.get()));
 
         grandchild3_->RemoveFromParent();
 
         EXPECT_FALSE(
-            layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get()));
-        EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            child_.get()));
+            layer_tree->LayerNeedsPushPropertiesForTesting(root_.get()));
+        EXPECT_TRUE(
+            layer_tree->LayerNeedsPushPropertiesForTesting(child_.get()));
 
         EndTest();
         break;
@@ -3880,6 +3926,7 @@
     : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren {
  protected:
   void DidCommitAndDrawFrame() override {
+    LayerTree* layer_tree = layer_tree_host()->GetLayerTree();
     int last_source_frame_number = layer_tree_host()->source_frame_number() - 1;
     switch (last_source_frame_number) {
       case 0:
@@ -3887,49 +3934,49 @@
         break;
       case 1:
         EXPECT_FALSE(
-            layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get()));
-        EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            child_.get()));
-        EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            grandchild1_.get()));
-        EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            grandchild2_.get()));
-        EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            grandchild3_.get()));
+            layer_tree->LayerNeedsPushPropertiesForTesting(root_.get()));
+        EXPECT_FALSE(
+            layer_tree->LayerNeedsPushPropertiesForTesting(child_.get()));
+        EXPECT_FALSE(
+            layer_tree->LayerNeedsPushPropertiesForTesting(grandchild1_.get()));
+        EXPECT_FALSE(
+            layer_tree->LayerNeedsPushPropertiesForTesting(grandchild2_.get()));
+        EXPECT_FALSE(
+            layer_tree->LayerNeedsPushPropertiesForTesting(grandchild3_.get()));
 
         child_->SetPosition(gfx::PointF(1.f, 1.f));
         grandchild1_->SetPosition(gfx::PointF(1.f, 1.f));
         grandchild2_->SetPosition(gfx::PointF(1.f, 1.f));
 
         EXPECT_FALSE(
-            layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get()));
-        EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            child_.get()));
-        EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            grandchild1_.get()));
-        EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            grandchild2_.get()));
-        EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            grandchild3_.get()));
+            layer_tree->LayerNeedsPushPropertiesForTesting(root_.get()));
+        EXPECT_TRUE(
+            layer_tree->LayerNeedsPushPropertiesForTesting(child_.get()));
+        EXPECT_TRUE(
+            layer_tree->LayerNeedsPushPropertiesForTesting(grandchild1_.get()));
+        EXPECT_TRUE(
+            layer_tree->LayerNeedsPushPropertiesForTesting(grandchild2_.get()));
+        EXPECT_FALSE(
+            layer_tree->LayerNeedsPushPropertiesForTesting(grandchild3_.get()));
 
         grandchild1_->RemoveFromParent();
 
         EXPECT_FALSE(
-            layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get()));
-        EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            child_.get()));
+            layer_tree->LayerNeedsPushPropertiesForTesting(root_.get()));
+        EXPECT_TRUE(
+            layer_tree->LayerNeedsPushPropertiesForTesting(child_.get()));
 
         grandchild2_->RemoveFromParent();
 
         EXPECT_FALSE(
-            layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get()));
-        EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            child_.get()));
+            layer_tree->LayerNeedsPushPropertiesForTesting(root_.get()));
+        EXPECT_TRUE(
+            layer_tree->LayerNeedsPushPropertiesForTesting(child_.get()));
 
         child_->RemoveFromParent();
 
         EXPECT_FALSE(
-            layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get()));
+            layer_tree->LayerNeedsPushPropertiesForTesting(root_.get()));
 
         EndTest();
         break;
@@ -3944,6 +3991,7 @@
     : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren {
  protected:
   void DidCommitAndDrawFrame() override {
+    LayerTree* layer_tree = layer_tree_host()->GetLayerTree();
     int last_source_frame_number = layer_tree_host()->source_frame_number() - 1;
     switch (last_source_frame_number) {
       case 0:
@@ -3951,49 +3999,49 @@
         break;
       case 1:
         EXPECT_FALSE(
-            layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get()));
-        EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            child_.get()));
-        EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            grandchild1_.get()));
-        EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            grandchild2_.get()));
-        EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            grandchild3_.get()));
+            layer_tree->LayerNeedsPushPropertiesForTesting(root_.get()));
+        EXPECT_FALSE(
+            layer_tree->LayerNeedsPushPropertiesForTesting(child_.get()));
+        EXPECT_FALSE(
+            layer_tree->LayerNeedsPushPropertiesForTesting(grandchild1_.get()));
+        EXPECT_FALSE(
+            layer_tree->LayerNeedsPushPropertiesForTesting(grandchild2_.get()));
+        EXPECT_FALSE(
+            layer_tree->LayerNeedsPushPropertiesForTesting(grandchild3_.get()));
 
         grandchild1_->SetPosition(gfx::PointF(1.f, 1.f));
         grandchild2_->SetPosition(gfx::PointF(1.f, 1.f));
         child_->SetPosition(gfx::PointF(1.f, 1.f));
 
         EXPECT_FALSE(
-            layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get()));
-        EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            child_.get()));
-        EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            grandchild1_.get()));
-        EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            grandchild2_.get()));
-        EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            grandchild3_.get()));
+            layer_tree->LayerNeedsPushPropertiesForTesting(root_.get()));
+        EXPECT_TRUE(
+            layer_tree->LayerNeedsPushPropertiesForTesting(child_.get()));
+        EXPECT_TRUE(
+            layer_tree->LayerNeedsPushPropertiesForTesting(grandchild1_.get()));
+        EXPECT_TRUE(
+            layer_tree->LayerNeedsPushPropertiesForTesting(grandchild2_.get()));
+        EXPECT_FALSE(
+            layer_tree->LayerNeedsPushPropertiesForTesting(grandchild3_.get()));
 
         grandchild1_->RemoveFromParent();
 
         EXPECT_FALSE(
-            layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get()));
-        EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            child_.get()));
+            layer_tree->LayerNeedsPushPropertiesForTesting(root_.get()));
+        EXPECT_TRUE(
+            layer_tree->LayerNeedsPushPropertiesForTesting(child_.get()));
 
         grandchild2_->RemoveFromParent();
 
         EXPECT_FALSE(
-            layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get()));
-        EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            child_.get()));
+            layer_tree->LayerNeedsPushPropertiesForTesting(root_.get()));
+        EXPECT_TRUE(
+            layer_tree->LayerNeedsPushPropertiesForTesting(child_.get()));
 
         child_->RemoveFromParent();
 
         EXPECT_FALSE(
-            layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get()));
+            layer_tree->LayerNeedsPushPropertiesForTesting(root_.get()));
 
         EndTest();
         break;
@@ -4153,11 +4201,12 @@
   void BeginTest() override { PostSetNeedsCommitToMainThread(); }
 
   void DidCommitAndDrawFrame() override {
+    LayerTree* layer_tree = layer_tree_host()->GetLayerTree();
     switch (layer_tree_host()->source_frame_number()) {
       case 1:
         // The layer type used does not need to push properties every frame.
-        EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            child_layer_.get()));
+        EXPECT_FALSE(
+            layer_tree->LayerNeedsPushPropertiesForTesting(child_layer_.get()));
 
         // Change the bounds of the child layer, but make it skipped
         // by CalculateDrawProperties.
@@ -4166,8 +4215,8 @@
         break;
       case 2:
         // The bounds of the child layer were pushed to the impl side.
-        EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
-            child_layer_.get()));
+        EXPECT_FALSE(
+            layer_tree->LayerNeedsPushPropertiesForTesting(child_layer_.get()));
 
         EndTest();
         break;
diff --git a/cc/trees/layer_tree_host_unittest_scroll.cc b/cc/trees/layer_tree_host_unittest_scroll.cc
index 03c34bbc..340c0f2 100644
--- a/cc/trees/layer_tree_host_unittest_scroll.cc
+++ b/cc/trees/layer_tree_host_unittest_scroll.cc
@@ -1003,7 +1003,7 @@
     switch (layer_tree_host()->source_frame_number()) {
       case 0:
         EXPECT_TRUE(
-            scroll_layer->layer_tree_host()->LayerNeedsPushPropertiesForTesting(
+            scroll_layer->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
                 scroll_layer));
         break;
       case 1:
@@ -1011,7 +1011,7 @@
         // still pick up scrolls that happen on the active layer during
         // commit.
         EXPECT_FALSE(
-            scroll_layer->layer_tree_host()->LayerNeedsPushPropertiesForTesting(
+            scroll_layer->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
                 scroll_layer));
         break;
     }
diff --git a/cc/trees/layer_tree_host_unittest_serialization.cc b/cc/trees/layer_tree_host_unittest_serialization.cc
index fbae1b82..5172c3e 100644
--- a/cc/trees/layer_tree_host_unittest_serialization.cc
+++ b/cc/trees/layer_tree_host_unittest_serialization.cc
@@ -20,6 +20,7 @@
 #include "cc/test/layer_tree_test.h"
 #include "cc/test/skia_common.h"
 #include "cc/test/test_task_graph_runner.h"
+#include "cc/trees/layer_tree.h"
 #include "cc/trees/layer_tree_host_common.h"
 #include "cc/trees/layer_tree_settings.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -80,8 +81,9 @@
 
   void TearDown() override {
     // Need to reset |in_paint_layer_contents_| to tear down.
-    layer_tree_host_src_->in_paint_layer_contents_ = false;
-    layer_tree_host_dst_->in_paint_layer_contents_ = false;
+
+    layer_tree_host_src_->GetLayerTree()->in_paint_layer_contents_ = false;
+    layer_tree_host_dst_->GetLayerTree()->in_paint_layer_contents_ = false;
 
     // Need to reset LayerTreeHost pointers before tear down.
     layer_tree_host_src_ = nullptr;
@@ -98,9 +100,11 @@
 
   void VerifySerializationAndDeserialization() {
     proto::LayerTreeHost proto;
+    LayerTree* layer_tree_src = layer_tree_host_src_->GetLayerTree();
+    LayerTree* layer_tree_dst = layer_tree_host_dst_->GetLayerTree();
 
     std::unordered_set<Layer*> layers_that_should_push_properties_src =
-        layer_tree_host_src_->LayersThatShouldPushProperties();
+        layer_tree_src->LayersThatShouldPushProperties();
     std::vector<std::unique_ptr<SwapPromise>> swap_promises;
     layer_tree_host_src_->ToProtobufForCommit(&proto, &swap_promises);
     layer_tree_host_dst_->FromProtobufForCommit(proto);
@@ -148,14 +152,14 @@
               layer_tree_host_dst_->background_color_);
     EXPECT_EQ(layer_tree_host_src_->has_transparent_background_,
               layer_tree_host_dst_->has_transparent_background_);
-    EXPECT_EQ(layer_tree_host_src_->in_paint_layer_contents_,
-              layer_tree_host_dst_->in_paint_layer_contents_);
+    EXPECT_EQ(layer_tree_src->in_paint_layer_contents(),
+              layer_tree_dst->in_paint_layer_contents());
     EXPECT_EQ(layer_tree_host_src_->id_, layer_tree_host_dst_->id_);
     EXPECT_EQ(layer_tree_host_src_->next_commit_forces_redraw_,
               layer_tree_host_dst_->next_commit_forces_redraw_);
     for (auto* layer : layers_that_should_push_properties_src) {
-      EXPECT_TRUE(layer_tree_host_dst_->LayerNeedsPushPropertiesForTesting(
-          layer_tree_host_dst_->LayerById(layer->id())));
+      EXPECT_TRUE(layer_tree_dst->LayerNeedsPushPropertiesForTesting(
+          layer_tree_dst->LayerById(layer->id())));
     }
 
     if (layer_tree_host_src_->hud_layer_) {
@@ -280,8 +284,9 @@
 
     // Set in_paint_layer_contents_ only after all calls to AddChild() have
     // finished to ensure it's allowed to do so at that time.
-    layer_tree_host_src_->in_paint_layer_contents_ =
-        !layer_tree_host_src_->in_paint_layer_contents_;
+    LayerTree* layer_tree_src = layer_tree_host_src_->GetLayerTree();
+    layer_tree_src->in_paint_layer_contents_ =
+        !layer_tree_src->in_paint_layer_contents();
 
     LayerSelectionBound sel_bound;
     sel_bound.edge_top = gfx::Point(14, 3);
diff --git a/cc/trees/tree_synchronizer.cc b/cc/trees/tree_synchronizer.cc
index 60177bf..6314afb 100644
--- a/cc/trees/tree_synchronizer.cc
+++ b/cc/trees/tree_synchronizer.cc
@@ -13,6 +13,7 @@
 #include "cc/layers/layer.h"
 #include "cc/layers/layer_collections.h"
 #include "cc/layers/layer_impl.h"
+#include "cc/trees/layer_tree.h"
 #include "cc/trees/layer_tree_host.h"
 #include "cc/trees/layer_tree_impl.h"
 
@@ -104,7 +105,7 @@
                               active_tree);
 }
 
-void TreeSynchronizer::PushLayerProperties(LayerTreeHost* host_tree,
+void TreeSynchronizer::PushLayerProperties(LayerTree* host_tree,
                                            LayerTreeImpl* impl_tree) {
   PushLayerPropertiesInternal(host_tree->LayersThatShouldPushProperties(),
                               impl_tree);
diff --git a/cc/trees/tree_synchronizer.h b/cc/trees/tree_synchronizer.h
index e5a0b62a..58688b7 100644
--- a/cc/trees/tree_synchronizer.h
+++ b/cc/trees/tree_synchronizer.h
@@ -13,6 +13,7 @@
 namespace cc {
 
 class LayerImpl;
+class LayerTree;
 class LayerTreeHost;
 class LayerTreeImpl;
 class Layer;
@@ -28,7 +29,7 @@
 
   static void PushLayerProperties(LayerTreeImpl* pending_tree,
                                   LayerTreeImpl* active_tree);
-  static void PushLayerProperties(LayerTreeHost* host_tree,
+  static void PushLayerProperties(LayerTree* host_tree,
                                   LayerTreeImpl* impl_tree);
 
  private:
diff --git a/cc/trees/tree_synchronizer_unittest.cc b/cc/trees/tree_synchronizer_unittest.cc
index 8090415..1041c79 100644
--- a/cc/trees/tree_synchronizer_unittest.cc
+++ b/cc/trees/tree_synchronizer_unittest.cc
@@ -217,7 +217,7 @@
                           host_->active_tree());
 
   // We have to push properties to pick up the destruction list pointer.
-  TreeSynchronizer::PushLayerProperties(layer_tree_root->layer_tree_host(),
+  TreeSynchronizer::PushLayerProperties(layer_tree_root->GetLayerTree(),
                                         host_->active_tree());
 
   // Add a new layer to the Layer side
@@ -266,7 +266,7 @@
                           host_->active_tree());
 
   // We have to push properties to pick up the destruction list pointer.
-  TreeSynchronizer::PushLayerProperties(layer_tree_root->layer_tree_host(),
+  TreeSynchronizer::PushLayerProperties(layer_tree_root->GetLayerTree(),
                                         host_->active_tree());
 
   host_->active_tree()->ResetAllChangeTracking();
@@ -280,7 +280,7 @@
   ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root,
                           host_->active_tree());
 
-  TreeSynchronizer::PushLayerProperties(layer_tree_root->layer_tree_host(),
+  TreeSynchronizer::PushLayerProperties(layer_tree_root->GetLayerTree(),
                                         host_->active_tree());
 
   // Check that the impl thread properly tracked the change.
@@ -316,7 +316,7 @@
   ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root,
                           host_->active_tree());
 
-  TreeSynchronizer::PushLayerProperties(layer_tree_root->layer_tree_host(),
+  TreeSynchronizer::PushLayerProperties(layer_tree_root->GetLayerTree(),
                                         host_->active_tree());
 
   // Check that the property values we set on the Layer tree are reflected in
@@ -366,7 +366,7 @@
                           host_->active_tree());
 
   // We have to push properties to pick up the destruction list pointer.
-  TreeSynchronizer::PushLayerProperties(layer_tree_root->layer_tree_host(),
+  TreeSynchronizer::PushLayerProperties(layer_tree_root->GetLayerTree(),
                                         host_->active_tree());
 
   // Now restructure the tree to look like this:
@@ -422,7 +422,7 @@
                           host_->active_tree());
 
   // We have to push properties to pick up the destruction list pointer.
-  TreeSynchronizer::PushLayerProperties(old_layer_tree_root->layer_tree_host(),
+  TreeSynchronizer::PushLayerProperties(old_layer_tree_root->GetLayerTree(),
                                         host_->active_tree());
 
   // Remove all children on the Layer side.