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

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

Issue 2547163002: Add thread checker calls to all ArcServiceManager methods (Closed)
Patch Set: address comment 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
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() {
61 return g_arc_service_manager; 61 if (!g_arc_service_manager)
62 return false;
63 DCHECK(g_arc_service_manager->thread_checker_.CalledOnValidThread());
64 return true;
62 } 65 }
63 66
64 ArcBridgeService* ArcServiceManager::arc_bridge_service() { 67 ArcBridgeService* ArcServiceManager::arc_bridge_service() {
65 DCHECK(thread_checker_.CalledOnValidThread()); 68 DCHECK(thread_checker_.CalledOnValidThread());
66 return arc_bridge_service_.get(); 69 return arc_bridge_service_.get();
67 } 70 }
68 71
69 void ArcServiceManager::AddService(std::unique_ptr<ArcService> service) { 72 void ArcServiceManager::AddService(std::unique_ptr<ArcService> service) {
70 DCHECK(thread_checker_.CalledOnValidThread()); 73 DCHECK(thread_checker_.CalledOnValidThread());
71 services_.emplace_back(std::move(service)); 74 services_.emplace_back(std::move(service));
72 } 75 }
73 76
74 void ArcServiceManager::AddObserver(Observer* observer) { 77 void ArcServiceManager::AddObserver(Observer* observer) {
78 DCHECK(thread_checker_.CalledOnValidThread());
75 observer_list_.AddObserver(observer); 79 observer_list_.AddObserver(observer);
76 } 80 }
77 81
78 void ArcServiceManager::RemoveObserver(Observer* observer) { 82 void ArcServiceManager::RemoveObserver(Observer* observer) {
83 DCHECK(thread_checker_.CalledOnValidThread());
79 observer_list_.RemoveObserver(observer); 84 observer_list_.RemoveObserver(observer);
80 } 85 }
81 86
82 void ArcServiceManager::OnAppsUpdated() { 87 void ArcServiceManager::OnAppsUpdated() {
88 DCHECK(thread_checker_.CalledOnValidThread());
83 for (auto& observer : observer_list_) 89 for (auto& observer : observer_list_)
84 observer.OnAppsUpdated(); 90 observer.OnAppsUpdated();
85 } 91 }
86 92
87 void ArcServiceManager::Shutdown() { 93 void ArcServiceManager::Shutdown() {
94 DCHECK(thread_checker_.CalledOnValidThread());
88 icon_loader_ = nullptr; 95 icon_loader_ = nullptr;
89 activity_resolver_ = nullptr; 96 activity_resolver_ = nullptr;
90 services_.clear(); 97 services_.clear();
91 arc_bridge_service_->OnShutdown(); 98 arc_bridge_service_->OnShutdown();
92 } 99 }
93 100
94 // static 101 // static
95 void ArcServiceManager::SetArcBridgeServiceForTesting( 102 void ArcServiceManager::SetArcBridgeServiceForTesting(
96 std::unique_ptr<ArcBridgeService> arc_bridge_service) { 103 std::unique_ptr<ArcBridgeService> arc_bridge_service) {
97 if (g_arc_bridge_service_for_testing) 104 if (g_arc_bridge_service_for_testing)
98 delete g_arc_bridge_service_for_testing; 105 delete g_arc_bridge_service_for_testing;
99 g_arc_bridge_service_for_testing = arc_bridge_service.release(); 106 g_arc_bridge_service_for_testing = arc_bridge_service.release();
100 } 107 }
101 108
102 } // namespace arc 109 } // 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