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

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

Issue 2425563004: Support reading multiple InterfaceProviderSpecs from manifests (Closed)
Patch Set: . Created 4 years, 1 month 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 <memory> 5 #include <memory>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.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"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 void WaitForInstanceDestruction(base::RunLoop* loop) { 62 void WaitForInstanceDestruction(base::RunLoop* loop) {
63 DCHECK(!destruction_loop_); 63 DCHECK(!destruction_loop_);
64 destruction_loop_ = loop; 64 destruction_loop_ = loop;
65 // First of all check to see if we should be spinning this loop at all - 65 // First of all check to see if we should be spinning this loop at all -
66 // the app(s) we're waiting on quitting may already have quit. 66 // the app(s) we're waiting on quitting may already have quit.
67 TryToQuitDestructionLoop(); 67 TryToQuitDestructionLoop();
68 } 68 }
69 69
70 private: 70 private:
71 // mojom::ServiceManagerListener: 71 // mojom::ServiceManagerListener:
72 void OnInit(std::vector<mojom::ServiceInfoPtr> instances) override { 72 void OnInit(std::vector<mojom::RunningServiceInfoPtr> instances) override {
73 for (const auto& instance : instances) { 73 for (const auto& instance : instances) {
74 Instance i(instance->identity, instance->pid); 74 Instance i(instance->identity, instance->pid);
75 initial_instances_[i.identity.name()] = i; 75 initial_instances_[i.identity.name()] = i;
76 instances_[i.identity.name()] = i; 76 instances_[i.identity.name()] = i;
77 } 77 }
78 loop_->Quit(); 78 loop_->Quit();
79 } 79 }
80 void OnServiceCreated(mojom::ServiceInfoPtr instance) override { 80 void OnServiceCreated(mojom::RunningServiceInfoPtr instance) override {
81 instances_[instance->identity.name()] = 81 instances_[instance->identity.name()] =
82 Instance(instance->identity, instance->pid); 82 Instance(instance->identity, instance->pid);
83 } 83 }
84 void OnServiceStarted(const service_manager::Identity& identity, 84 void OnServiceStarted(const service_manager::Identity& identity,
85 uint32_t pid) override { 85 uint32_t pid) override {
86 for (auto& instance : instances_) { 86 for (auto& instance : instances_) {
87 if (instance.second.identity == identity) { 87 if (instance.second.identity == identity) {
88 instance.second.pid = pid; 88 instance.second.pid = pid;
89 break; 89 break;
90 } 90 }
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 parent->Quit(); 444 parent->Quit();
445 445
446 // Quitting the parent should cascade-quit the child. 446 // Quitting the parent should cascade-quit the child.
447 WaitForInstanceDestruction(); 447 WaitForInstanceDestruction();
448 EXPECT_EQ(0u, instances()->GetNewInstanceCount()); 448 EXPECT_EQ(0u, instances()->GetNewInstanceCount());
449 EXPECT_FALSE(instances()->HasInstanceForName(kTestParentName)); 449 EXPECT_FALSE(instances()->HasInstanceForName(kTestParentName));
450 EXPECT_FALSE(instances()->HasInstanceForName(kTestAppName)); 450 EXPECT_FALSE(instances()->HasInstanceForName(kTestAppName));
451 } 451 }
452 452
453 } // namespace service_manager 453 } // namespace service_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698