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

Side by Side Diff: services/service_manager/tests/lifecycle/package.cc

Issue 2818533003: Make nesting/running states a RunLoop rather than a MessageLoop concept. (Closed)
Patch Set: fix compile and add RunLoopTests Created 3 years, 8 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 <algorithm> 5 #include <algorithm>
6 #include <memory> 6 #include <memory>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/message_loop/message_loop.h"
12 #include "base/run_loop.h"
11 #include "mojo/public/cpp/bindings/binding_set.h" 13 #include "mojo/public/cpp/bindings/binding_set.h"
12 #include "services/service_manager/public/c/main.h" 14 #include "services/service_manager/public/c/main.h"
13 #include "services/service_manager/public/cpp/interface_factory.h" 15 #include "services/service_manager/public/cpp/interface_factory.h"
14 #include "services/service_manager/public/cpp/interface_registry.h" 16 #include "services/service_manager/public/cpp/interface_registry.h"
15 #include "services/service_manager/public/cpp/service_context.h" 17 #include "services/service_manager/public/cpp/service_context.h"
16 #include "services/service_manager/public/cpp/service_runner.h" 18 #include "services/service_manager/public/cpp/service_runner.h"
17 #include "services/service_manager/public/interfaces/service_factory.mojom.h" 19 #include "services/service_manager/public/interfaces/service_factory.mojom.h"
18 #include "services/service_manager/tests/lifecycle/app_client.h" 20 #include "services/service_manager/tests/lifecycle/app_client.h"
19 #include "services/service_manager/tests/lifecycle/lifecycle_unittest.mojom.h" 21 #include "services/service_manager/tests/lifecycle/lifecycle_unittest.mojom.h"
20 22
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 } 145 }
144 146
145 void DestroyService(int id) { 147 void DestroyService(int id) {
146 auto id_it = id_to_context_.find(id); 148 auto id_it = id_to_context_.find(id);
147 DCHECK(id_it != id_to_context_.end()); 149 DCHECK(id_it != id_to_context_.end());
148 150
149 auto it = contexts_.find(id_it->second); 151 auto it = contexts_.find(id_it->second);
150 DCHECK(it != contexts_.end()); 152 DCHECK(it != contexts_.end());
151 contexts_.erase(it); 153 contexts_.erase(it);
152 id_to_context_.erase(id_it); 154 id_to_context_.erase(id_it);
153 if (contexts_.empty() && base::MessageLoop::current()->is_running()) 155 if (contexts_.empty() && base::RunLoop::IsRunningOnCurrentThread())
154 base::MessageLoop::current()->QuitWhenIdle(); 156 base::MessageLoop::current()->QuitWhenIdle();
155 } 157 }
156 158
157 service_manager::test::AppClient app_client_; 159 service_manager::test::AppClient app_client_;
158 int service_manager_connection_refcount_ = 0; 160 int service_manager_connection_refcount_ = 0;
159 mojo::BindingSet<service_manager::mojom::ServiceFactory> bindings_; 161 mojo::BindingSet<service_manager::mojom::ServiceFactory> bindings_;
160 162
161 using ServiceContextMap = 163 using ServiceContextMap =
162 std::map<service_manager::ServiceContext*, 164 std::map<service_manager::ServiceContext*,
163 std::unique_ptr<service_manager::ServiceContext>>; 165 std::unique_ptr<service_manager::ServiceContext>>;
164 ServiceContextMap contexts_; 166 ServiceContextMap contexts_;
165 167
166 int next_id_ = 0; 168 int next_id_ = 0;
167 std::map<int, service_manager::ServiceContext*> id_to_context_; 169 std::map<int, service_manager::ServiceContext*> id_to_context_;
168 170
169 DISALLOW_COPY_AND_ASSIGN(Package); 171 DISALLOW_COPY_AND_ASSIGN(Package);
170 }; 172 };
171 173
172 } // namespace 174 } // namespace
173 175
174 MojoResult ServiceMain(MojoHandle service_request_handle) { 176 MojoResult ServiceMain(MojoHandle service_request_handle) {
175 service_manager::ServiceRunner runner(new Package); 177 service_manager::ServiceRunner runner(new Package);
176 return runner.Run(service_request_handle); 178 return runner.Run(service_request_handle);
177 } 179 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698