| OLD | NEW |
| 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/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "base/task_runner.h" | 11 #include "base/task_runner.h" |
| 12 #include "components/arc/arc_bridge_service.h" | 12 #include "components/arc/arc_bridge_service.h" |
| 13 #include "components/arc/arc_session.h" | 13 #include "components/arc/arc_session.h" |
| 14 #include "components/arc/arc_session_runner.h" | 14 #include "components/arc/arc_session_runner.h" |
| 15 #include "components/arc/file_system/arc_file_system_observer.h" |
| 15 #include "components/arc/intent_helper/arc_intent_helper_observer.h" | 16 #include "components/arc/intent_helper/arc_intent_helper_observer.h" |
| 16 | 17 |
| 17 namespace arc { | 18 namespace arc { |
| 18 namespace { | 19 namespace { |
| 19 | 20 |
| 20 // Weak pointer. This class is owned by arc::ArcServiceLauncher. | 21 // Weak pointer. This class is owned by arc::ArcServiceLauncher. |
| 21 ArcServiceManager* g_arc_service_manager = nullptr; | 22 ArcServiceManager* g_arc_service_manager = nullptr; |
| 22 | 23 |
| 23 } // namespace | 24 } // namespace |
| 24 | 25 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 38 ArcServiceManager::IntentHelperObserverImpl::IntentHelperObserverImpl( | 39 ArcServiceManager::IntentHelperObserverImpl::IntentHelperObserverImpl( |
| 39 ArcServiceManager* manager) | 40 ArcServiceManager* manager) |
| 40 : manager_(manager) {} | 41 : manager_(manager) {} |
| 41 | 42 |
| 42 void ArcServiceManager::IntentHelperObserverImpl::OnIntentFiltersUpdated() { | 43 void ArcServiceManager::IntentHelperObserverImpl::OnIntentFiltersUpdated() { |
| 43 DCHECK(manager_->thread_checker_.CalledOnValidThread()); | 44 DCHECK(manager_->thread_checker_.CalledOnValidThread()); |
| 44 for (auto& observer : manager_->observer_list_) | 45 for (auto& observer : manager_->observer_list_) |
| 45 observer.OnIntentFiltersUpdated(); | 46 observer.OnIntentFiltersUpdated(); |
| 46 } | 47 } |
| 47 | 48 |
| 49 class ArcServiceManager::FileSystemObserverImpl : public ArcFileSystemObserver { |
| 50 public: |
| 51 explicit FileSystemObserverImpl(ArcServiceManager* manager); |
| 52 ~FileSystemObserverImpl() override = default; |
| 53 |
| 54 private: |
| 55 void OnFileSystemsReady() override; |
| 56 ArcServiceManager* const manager_; |
| 57 |
| 58 DISALLOW_COPY_AND_ASSIGN(FileSystemObserverImpl); |
| 59 }; |
| 60 |
| 61 ArcServiceManager::FileSystemObserverImpl::FileSystemObserverImpl( |
| 62 ArcServiceManager* manager) |
| 63 : manager_(manager) {} |
| 64 |
| 65 void ArcServiceManager::FileSystemObserverImpl::OnFileSystemsReady() { |
| 66 DCHECK(manager_->thread_checker_.CalledOnValidThread()); |
| 67 for (auto& observer : manager_->observer_list_) |
| 68 observer.OnFileSystemsReady(); |
| 69 } |
| 70 |
| 48 ArcServiceManager::ArcServiceManager( | 71 ArcServiceManager::ArcServiceManager( |
| 49 scoped_refptr<base::TaskRunner> blocking_task_runner) | 72 scoped_refptr<base::TaskRunner> blocking_task_runner) |
| 50 : blocking_task_runner_(blocking_task_runner), | 73 : blocking_task_runner_(blocking_task_runner), |
| 51 intent_helper_observer_(base::MakeUnique<IntentHelperObserverImpl>(this)), | 74 intent_helper_observer_(base::MakeUnique<IntentHelperObserverImpl>(this)), |
| 75 file_system_observer_(base::MakeUnique<FileSystemObserverImpl>(this)), |
| 52 arc_bridge_service_(base::MakeUnique<ArcBridgeService>()), | 76 arc_bridge_service_(base::MakeUnique<ArcBridgeService>()), |
| 53 icon_loader_(new ActivityIconLoader()), | 77 icon_loader_(new ActivityIconLoader()), |
| 54 activity_resolver_(new LocalActivityResolver()) { | 78 activity_resolver_(new LocalActivityResolver()) { |
| 55 DCHECK(!g_arc_service_manager); | 79 DCHECK(!g_arc_service_manager); |
| 56 g_arc_service_manager = this; | 80 g_arc_service_manager = this; |
| 57 } | 81 } |
| 58 | 82 |
| 59 ArcServiceManager::~ArcServiceManager() { | 83 ArcServiceManager::~ArcServiceManager() { |
| 60 DCHECK(thread_checker_.CalledOnValidThread()); | 84 DCHECK(thread_checker_.CalledOnValidThread()); |
| 61 DCHECK_EQ(g_arc_service_manager, this); | 85 DCHECK_EQ(g_arc_service_manager, this); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 // Before actual shutdown, notify observers for clean up. | 120 // Before actual shutdown, notify observers for clean up. |
| 97 for (auto& observer : observer_list_) | 121 for (auto& observer : observer_list_) |
| 98 observer.OnArcShutdown(); | 122 observer.OnArcShutdown(); |
| 99 | 123 |
| 100 icon_loader_ = nullptr; | 124 icon_loader_ = nullptr; |
| 101 activity_resolver_ = nullptr; | 125 activity_resolver_ = nullptr; |
| 102 services_.clear(); | 126 services_.clear(); |
| 103 } | 127 } |
| 104 | 128 |
| 105 } // namespace arc | 129 } // namespace arc |
| OLD | NEW |