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

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: still need to check MessageLoop::current() in Mojo's RunLoopNestingObserver::GetForThread() Created 3 years, 7 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
« no previous file with comments | « mojo/public/cpp/bindings/lib/connector.cc ('k') | services/ui/service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/binder_registry.h" 15 #include "services/service_manager/public/cpp/binder_registry.h"
14 #include "services/service_manager/public/cpp/service_context.h" 16 #include "services/service_manager/public/cpp/service_context.h"
15 #include "services/service_manager/public/cpp/service_runner.h" 17 #include "services/service_manager/public/cpp/service_runner.h"
16 #include "services/service_manager/public/interfaces/service_factory.mojom.h" 18 #include "services/service_manager/public/interfaces/service_factory.mojom.h"
17 #include "services/service_manager/tests/lifecycle/app_client.h" 19 #include "services/service_manager/tests/lifecycle/app_client.h"
18 #include "services/service_manager/tests/lifecycle/lifecycle_unittest.mojom.h" 20 #include "services/service_manager/tests/lifecycle/lifecycle_unittest.mojom.h"
19 21
20 namespace { 22 namespace {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 } 148 }
147 149
148 void DestroyService(int id) { 150 void DestroyService(int id) {
149 auto id_it = id_to_context_.find(id); 151 auto id_it = id_to_context_.find(id);
150 DCHECK(id_it != id_to_context_.end()); 152 DCHECK(id_it != id_to_context_.end());
151 153
152 auto it = contexts_.find(id_it->second); 154 auto it = contexts_.find(id_it->second);
153 DCHECK(it != contexts_.end()); 155 DCHECK(it != contexts_.end());
154 contexts_.erase(it); 156 contexts_.erase(it);
155 id_to_context_.erase(id_it); 157 id_to_context_.erase(id_it);
156 if (contexts_.empty() && base::MessageLoop::current()->is_running()) 158 if (contexts_.empty() && base::RunLoop::IsRunningOnCurrentThread())
157 base::MessageLoop::current()->QuitWhenIdle(); 159 base::MessageLoop::current()->QuitWhenIdle();
158 } 160 }
159 161
160 service_manager::test::AppClient app_client_; 162 service_manager::test::AppClient app_client_;
161 int service_manager_connection_refcount_ = 0; 163 int service_manager_connection_refcount_ = 0;
162 service_manager::BinderRegistry registry_; 164 service_manager::BinderRegistry registry_;
163 mojo::BindingSet<service_manager::mojom::ServiceFactory> bindings_; 165 mojo::BindingSet<service_manager::mojom::ServiceFactory> bindings_;
164 166
165 using ServiceContextMap = 167 using ServiceContextMap =
166 std::map<service_manager::ServiceContext*, 168 std::map<service_manager::ServiceContext*,
167 std::unique_ptr<service_manager::ServiceContext>>; 169 std::unique_ptr<service_manager::ServiceContext>>;
168 ServiceContextMap contexts_; 170 ServiceContextMap contexts_;
169 171
170 int next_id_ = 0; 172 int next_id_ = 0;
171 std::map<int, service_manager::ServiceContext*> id_to_context_; 173 std::map<int, service_manager::ServiceContext*> id_to_context_;
172 174
173 DISALLOW_COPY_AND_ASSIGN(Package); 175 DISALLOW_COPY_AND_ASSIGN(Package);
174 }; 176 };
175 177
176 } // namespace 178 } // namespace
177 179
178 MojoResult ServiceMain(MojoHandle service_request_handle) { 180 MojoResult ServiceMain(MojoHandle service_request_handle) {
179 service_manager::ServiceRunner runner(new Package); 181 service_manager::ServiceRunner runner(new Package);
180 return runner.Run(service_request_handle); 182 return runner.Run(service_request_handle);
181 } 183 }
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/connector.cc ('k') | services/ui/service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698