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

Side by Side Diff: components/arc/arc_service_manager.cc

Issue 2547163002: Add thread checker calls to all ArcServiceManager methods (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/arc/arc_service_manager.h" 5 #include "components/arc/arc_service_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/sequenced_task_runner.h" 10 #include "base/sequenced_task_runner.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 } 50 }
51 51
52 // static 52 // static
53 ArcServiceManager* ArcServiceManager::Get() { 53 ArcServiceManager* ArcServiceManager::Get() {
54 DCHECK(g_arc_service_manager); 54 DCHECK(g_arc_service_manager);
55 DCHECK(g_arc_service_manager->thread_checker_.CalledOnValidThread()); 55 DCHECK(g_arc_service_manager->thread_checker_.CalledOnValidThread());
56 return g_arc_service_manager; 56 return g_arc_service_manager;
57 } 57 }
58 58
59 // static 59 // static
60 bool ArcServiceManager::IsInitialized() { 60 bool ArcServiceManager::IsInitialized() {
Yusuke Sato 2016/12/02 21:06:54 FYI, this method was introduced for https://codere
Luis Héctor Chávez 2016/12/02 22:18:08 Not at the moment :(
61 DCHECK(!g_arc_service_manager ||
Yusuke Sato 2016/12/02 21:06:54 This DCHECK does not detect wrong threading when g
Luis Héctor Chávez 2016/12/02 22:18:08 This is fine. We have a similar problem in ArcBrid
Yusuke Sato 2016/12/02 22:27:28 Thanks, done.
62 g_arc_service_manager->thread_checker_.CalledOnValidThread());
61 return g_arc_service_manager; 63 return g_arc_service_manager;
62 } 64 }
63 65
64 ArcBridgeService* ArcServiceManager::arc_bridge_service() { 66 ArcBridgeService* ArcServiceManager::arc_bridge_service() {
65 DCHECK(thread_checker_.CalledOnValidThread()); 67 DCHECK(thread_checker_.CalledOnValidThread());
66 return arc_bridge_service_.get(); 68 return arc_bridge_service_.get();
67 } 69 }
68 70
69 void ArcServiceManager::AddService(std::unique_ptr<ArcService> service) { 71 void ArcServiceManager::AddService(std::unique_ptr<ArcService> service) {
70 DCHECK(thread_checker_.CalledOnValidThread()); 72 DCHECK(thread_checker_.CalledOnValidThread());
71 services_.emplace_back(std::move(service)); 73 services_.emplace_back(std::move(service));
72 } 74 }
73 75
74 void ArcServiceManager::AddObserver(Observer* observer) { 76 void ArcServiceManager::AddObserver(Observer* observer) {
77 DCHECK(thread_checker_.CalledOnValidThread());
75 observer_list_.AddObserver(observer); 78 observer_list_.AddObserver(observer);
76 } 79 }
77 80
78 void ArcServiceManager::RemoveObserver(Observer* observer) { 81 void ArcServiceManager::RemoveObserver(Observer* observer) {
82 DCHECK(thread_checker_.CalledOnValidThread());
79 observer_list_.RemoveObserver(observer); 83 observer_list_.RemoveObserver(observer);
80 } 84 }
81 85
82 void ArcServiceManager::OnAppsUpdated() { 86 void ArcServiceManager::OnAppsUpdated() {
87 DCHECK(thread_checker_.CalledOnValidThread());
83 for (auto& observer : observer_list_) 88 for (auto& observer : observer_list_)
84 observer.OnAppsUpdated(); 89 observer.OnAppsUpdated();
85 } 90 }
86 91
87 void ArcServiceManager::Shutdown() { 92 void ArcServiceManager::Shutdown() {
93 DCHECK(thread_checker_.CalledOnValidThread());
88 icon_loader_ = nullptr; 94 icon_loader_ = nullptr;
89 activity_resolver_ = nullptr; 95 activity_resolver_ = nullptr;
90 services_.clear(); 96 services_.clear();
91 arc_bridge_service_->OnShutdown(); 97 arc_bridge_service_->OnShutdown();
92 } 98 }
93 99
94 // static 100 // static
95 void ArcServiceManager::SetArcBridgeServiceForTesting( 101 void ArcServiceManager::SetArcBridgeServiceForTesting(
96 std::unique_ptr<ArcBridgeService> arc_bridge_service) { 102 std::unique_ptr<ArcBridgeService> arc_bridge_service) {
97 if (g_arc_bridge_service_for_testing) 103 if (g_arc_bridge_service_for_testing)
98 delete g_arc_bridge_service_for_testing; 104 delete g_arc_bridge_service_for_testing;
99 g_arc_bridge_service_for_testing = arc_bridge_service.release(); 105 g_arc_bridge_service_for_testing = arc_bridge_service.release();
100 } 106 }
101 107
102 } // namespace arc 108 } // namespace arc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698