OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "blimp/client/core/contents/blimp_contents_manager.h" | 5 #include "blimp/client/core/contents/blimp_contents_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/threading/thread_task_runner_handle.h" | 9 #include "base/threading/thread_task_runner_handle.h" |
| 10 #include "blimp/client/core/compositor/compositor_deps_provider.h" |
10 #include "blimp/client/public/contents/blimp_contents_observer.h" | 11 #include "blimp/client/public/contents/blimp_contents_observer.h" |
11 | 12 |
12 namespace { | 13 namespace { |
13 const int kDummyTabId = 0; | 14 const int kDummyTabId = 0; |
14 } | 15 } |
15 | 16 |
16 namespace blimp { | 17 namespace blimp { |
17 namespace client { | 18 namespace client { |
18 | 19 |
19 class BlimpContentsManager::BlimpContentsDeletionObserver | 20 class BlimpContentsManager::BlimpContentsDeletionObserver |
(...skipping 20 matching lines...) Expand all Loading... |
40 void BlimpContentsManager::BlimpContentsDeletionObserver:: | 41 void BlimpContentsManager::BlimpContentsDeletionObserver:: |
41 OnContentsDestroyed() { | 42 OnContentsDestroyed() { |
42 BlimpContents* contents = blimp_contents(); | 43 BlimpContents* contents = blimp_contents(); |
43 int id = static_cast<BlimpContentsImpl*>(contents)->id(); | 44 int id = static_cast<BlimpContentsImpl*>(contents)->id(); |
44 DCHECK(base::ThreadTaskRunnerHandle::Get()); | 45 DCHECK(base::ThreadTaskRunnerHandle::Get()); |
45 base::ThreadTaskRunnerHandle::Get()->PostTask( | 46 base::ThreadTaskRunnerHandle::Get()->PostTask( |
46 FROM_HERE, base::Bind(&BlimpContentsManager::EraseObserverFromMap, | 47 FROM_HERE, base::Bind(&BlimpContentsManager::EraseObserverFromMap, |
47 blimp_contents_manager_->GetWeakPtr(), id)); | 48 blimp_contents_manager_->GetWeakPtr(), id)); |
48 } | 49 } |
49 | 50 |
50 BlimpContentsManager::BlimpContentsManager() : weak_ptr_factory_(this) {} | 51 BlimpContentsManager::BlimpContentsManager( |
| 52 bool use_internal_display, |
| 53 RenderWidgetFeature* render_widget_feature) |
| 54 : compositor_deps_provider_(use_internal_display), |
| 55 render_widget_feature_(render_widget_feature), |
| 56 weak_ptr_factory_(this) {} |
51 | 57 |
52 BlimpContentsManager::~BlimpContentsManager() {} | 58 BlimpContentsManager::~BlimpContentsManager() {} |
53 | 59 |
54 std::unique_ptr<BlimpContentsImpl> BlimpContentsManager::CreateBlimpContents() { | 60 std::unique_ptr<BlimpContentsImpl> BlimpContentsManager::CreateBlimpContents() { |
55 int id = CreateBlimpContentsId(); | 61 int id = CreateBlimpContentsId(); |
56 std::unique_ptr<BlimpContentsImpl> new_contents = | 62 std::unique_ptr<BlimpContentsImpl> new_contents = |
57 base::MakeUnique<BlimpContentsImpl>(id); | 63 base::MakeUnique<BlimpContentsImpl>(id, &compositor_deps_provider_, |
| 64 render_widget_feature_); |
58 std::unique_ptr<BlimpContentsDeletionObserver> observer = | 65 std::unique_ptr<BlimpContentsDeletionObserver> observer = |
59 base::MakeUnique<BlimpContentsDeletionObserver>(this, new_contents.get()); | 66 base::MakeUnique<BlimpContentsDeletionObserver>(this, new_contents.get()); |
60 observer_map_.insert( | 67 observer_map_.insert( |
61 std::pair<int, std::unique_ptr<BlimpContentsDeletionObserver>>( | 68 std::pair<int, std::unique_ptr<BlimpContentsDeletionObserver>>( |
62 id, std::move(observer))); | 69 id, std::move(observer))); |
63 return new_contents; | 70 return new_contents; |
64 } | 71 } |
65 | 72 |
66 BlimpContentsImpl* BlimpContentsManager::GetBlimpContents(int id) { | 73 BlimpContentsImpl* BlimpContentsManager::GetBlimpContents(int id) { |
67 if (observer_map_.find(id) == observer_map_.end()) return nullptr; | 74 if (observer_map_.find(id) == observer_map_.end()) return nullptr; |
(...skipping 18 matching lines...) Expand all Loading... |
86 void BlimpContentsManager::EraseObserverFromMap(int id) { | 93 void BlimpContentsManager::EraseObserverFromMap(int id) { |
87 observer_map_.erase(id); | 94 observer_map_.erase(id); |
88 } | 95 } |
89 | 96 |
90 base::WeakPtr<BlimpContentsManager> BlimpContentsManager::GetWeakPtr() { | 97 base::WeakPtr<BlimpContentsManager> BlimpContentsManager::GetWeakPtr() { |
91 return weak_ptr_factory_.GetWeakPtr(); | 98 return weak_ptr_factory_.GetWeakPtr(); |
92 } | 99 } |
93 | 100 |
94 } // namespace client | 101 } // namespace client |
95 } // namespace blimp | 102 } // namespace blimp |
OLD | NEW |