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

Side by Side Diff: blimp/client/core/contents/blimp_contents_manager.cc

Issue 2255533002: Add TabControlFeature to BlimpClientContextImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Pass TabControlFeature* to BlimpContentsImpl's constructor, remove blimp contents factory Created 4 years, 4 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
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/public/contents/blimp_contents_observer.h" 10 #include "blimp/client/public/contents/blimp_contents_observer.h"
(...skipping 21 matching lines...) Expand all
32 }; 32 };
33 33
34 BlimpContentsManager::BlimpContentsDeletionObserver:: 34 BlimpContentsManager::BlimpContentsDeletionObserver::
35 BlimpContentsDeletionObserver(BlimpContentsManager* blimp_contents_manager, 35 BlimpContentsDeletionObserver(BlimpContentsManager* blimp_contents_manager,
36 BlimpContentsImpl* blimp_contents) 36 BlimpContentsImpl* blimp_contents)
37 : BlimpContentsObserver(blimp_contents), 37 : BlimpContentsObserver(blimp_contents),
38 blimp_contents_manager_(blimp_contents_manager) {} 38 blimp_contents_manager_(blimp_contents_manager) {}
39 39
40 void BlimpContentsManager::BlimpContentsDeletionObserver:: 40 void BlimpContentsManager::BlimpContentsDeletionObserver::
41 OnContentsDestroyed() { 41 OnContentsDestroyed() {
42 BlimpContents* contents = blimp_contents(); 42 BlimpContents* contents = blimp_contents();
David Trainor- moved to gerrit 2016/08/18 17:41:58 It might make sense to change this now. We don't
Menglin 2016/08/19 00:50:21 Done.
43 int id = static_cast<BlimpContentsImpl*>(contents)->id(); 43 int id = static_cast<BlimpContentsImpl*>(contents)->id();
44 DCHECK(base::ThreadTaskRunnerHandle::Get()); 44 DCHECK(base::ThreadTaskRunnerHandle::Get());
45 base::ThreadTaskRunnerHandle::Get()->PostTask( 45 base::ThreadTaskRunnerHandle::Get()->PostTask(
46 FROM_HERE, base::Bind(&BlimpContentsManager::EraseObserverFromMap, 46 FROM_HERE, base::Bind(&BlimpContentsManager::EraseObserverFromMap,
47 blimp_contents_manager_->GetWeakPtr(), id)); 47 blimp_contents_manager_->GetWeakPtr(), id));
48 } 48 }
49 49
50 BlimpContentsManager::BlimpContentsManager() : weak_ptr_factory_(this) {} 50 BlimpContentsManager::BlimpContentsManager() : weak_ptr_factory_(this) {}
51 51
52 BlimpContentsManager::~BlimpContentsManager() {} 52 BlimpContentsManager::~BlimpContentsManager() {}
53 53
54 std::unique_ptr<BlimpContentsImpl> BlimpContentsManager::CreateBlimpContents() { 54 std::unique_ptr<BlimpContentsImpl> BlimpContentsManager::CreateBlimpContents(
David Trainor- moved to gerrit 2016/08/18 17:41:58 This class should also call tab_control_feature->C
Menglin 2016/08/19 00:50:21 Done.
55 TabControlFeature* tab_control_feature) {
55 int id = CreateBlimpContentsId(); 56 int id = CreateBlimpContentsId();
56 std::unique_ptr<BlimpContentsImpl> new_contents = 57 std::unique_ptr<BlimpContentsImpl> new_contents =
57 base::MakeUnique<BlimpContentsImpl>(id); 58 base::MakeUnique<BlimpContentsImpl>(id, tab_control_feature);
58 std::unique_ptr<BlimpContentsDeletionObserver> observer = 59 std::unique_ptr<BlimpContentsDeletionObserver> observer =
59 base::MakeUnique<BlimpContentsDeletionObserver>(this, new_contents.get()); 60 base::MakeUnique<BlimpContentsDeletionObserver>(this, new_contents.get());
60 observer_map_.insert( 61 observer_map_.insert(
61 std::pair<int, std::unique_ptr<BlimpContentsDeletionObserver>>( 62 std::pair<int, std::unique_ptr<BlimpContentsDeletionObserver>>(
62 id, std::move(observer))); 63 id, std::move(observer)));
63 return new_contents; 64 return new_contents;
64 } 65 }
65 66
66 BlimpContentsImpl* BlimpContentsManager::GetBlimpContents(int id) { 67 BlimpContentsImpl* BlimpContentsManager::GetBlimpContents(int id) {
67 if (observer_map_.find(id) == observer_map_.end()) return nullptr; 68 if (observer_map_.find(id) == observer_map_.end()) return nullptr;
(...skipping 18 matching lines...) Expand all
86 void BlimpContentsManager::EraseObserverFromMap(int id) { 87 void BlimpContentsManager::EraseObserverFromMap(int id) {
87 observer_map_.erase(id); 88 observer_map_.erase(id);
88 } 89 }
89 90
90 base::WeakPtr<BlimpContentsManager> BlimpContentsManager::GetWeakPtr() { 91 base::WeakPtr<BlimpContentsManager> BlimpContentsManager::GetWeakPtr() {
91 return weak_ptr_factory_.GetWeakPtr(); 92 return weak_ptr_factory_.GetWeakPtr();
92 } 93 }
93 94
94 } // namespace client 95 } // namespace client
95 } // namespace blimp 96 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698