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 "content/common/service_manager/embedded_service_runner.h" | 5 #include "content/common/service_manager/embedded_service_runner.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <memory> | 8 #include <memory> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 service_manager::mojom::ServiceRequest request) { | 80 service_manager::mojom::ServiceRequest request) { |
81 DCHECK(service_task_runner_->BelongsToCurrentThread()); | 81 DCHECK(service_task_runner_->BelongsToCurrentThread()); |
82 | 82 |
83 int instance_id = next_instance_id_++; | 83 int instance_id = next_instance_id_++; |
84 | 84 |
85 std::unique_ptr<service_manager::ServiceContext> context = | 85 std::unique_ptr<service_manager::ServiceContext> context = |
86 base::MakeUnique<service_manager::ServiceContext>( | 86 base::MakeUnique<service_manager::ServiceContext>( |
87 factory_callback_.Run(), std::move(request)); | 87 factory_callback_.Run(), std::move(request)); |
88 | 88 |
89 service_manager::ServiceContext* raw_context = context.get(); | 89 service_manager::ServiceContext* raw_context = context.get(); |
90 context->SetConnectionLostClosure( | 90 context->SetQuitClosure( |
91 base::Bind(&InstanceManager::OnInstanceLost, this, instance_id)); | 91 base::Bind(&InstanceManager::OnInstanceLost, this, instance_id)); |
92 contexts_.insert(std::make_pair(raw_context, std::move(context))); | 92 contexts_.insert(std::make_pair(raw_context, std::move(context))); |
93 id_to_context_map_.insert(std::make_pair(instance_id, raw_context)); | 93 id_to_context_map_.insert(std::make_pair(instance_id, raw_context)); |
94 } | 94 } |
95 | 95 |
96 void OnInstanceLost(int instance_id) { | 96 void OnInstanceLost(int instance_id) { |
97 DCHECK(service_task_runner_->BelongsToCurrentThread()); | 97 DCHECK(service_task_runner_->BelongsToCurrentThread()); |
98 | 98 |
99 auto id_iter = id_to_context_map_.find(instance_id); | 99 auto id_iter = id_to_context_map_.find(instance_id); |
100 CHECK(id_iter != id_to_context_map_.end()); | 100 CHECK(id_iter != id_to_context_map_.end()); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 const base::Closure& quit_closure) { | 186 const base::Closure& quit_closure) { |
187 quit_closure_ = quit_closure; | 187 quit_closure_ = quit_closure; |
188 } | 188 } |
189 | 189 |
190 void EmbeddedServiceRunner::OnQuit() { | 190 void EmbeddedServiceRunner::OnQuit() { |
191 if (!quit_closure_.is_null()) | 191 if (!quit_closure_.is_null()) |
192 quit_closure_.Run(); | 192 quit_closure_.Run(); |
193 } | 193 } |
194 | 194 |
195 } // namespace content | 195 } // namespace content |
OLD | NEW |