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

Side by Side Diff: services/shell/shell.cc

Issue 1947213002: Enable the MojoDOMSTorageBrowserTests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 | « content/public/app/mojo/content_browser_manifest.json ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "services/shell/shell.h" 5 #include "services/shell/shell.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 public mojom::Shell { 115 public mojom::Shell {
116 public: 116 public:
117 Instance(shell::Shell* shell, 117 Instance(shell::Shell* shell,
118 const Identity& identity, 118 const Identity& identity,
119 const CapabilitySpec& capability_spec) 119 const CapabilitySpec& capability_spec)
120 : shell_(shell), 120 : shell_(shell),
121 id_(GenerateUniqueID()), 121 id_(GenerateUniqueID()),
122 identity_(identity), 122 identity_(identity),
123 capability_spec_(capability_spec), 123 capability_spec_(capability_spec),
124 allow_any_application_(capability_spec.required.count("*") == 1), 124 allow_any_application_(capability_spec.required.count("*") == 1),
125 pid_receiver_binding_(this) { 125 pid_receiver_binding_(this),
126 weak_factory_(this) {
126 if (identity_.name() == kShellName || identity_.name() == kCatalogName) 127 if (identity_.name() == kShellName || identity_.name() == kCatalogName)
127 pid_ = base::Process::Current().Pid(); 128 pid_ = base::Process::Current().Pid();
128 DCHECK_NE(mojom::kInvalidInstanceID, id_); 129 DCHECK_NE(mojom::kInvalidInstanceID, id_);
129 } 130 }
130 131
131 ~Instance() override { 132 ~Instance() override {
132 if (parent_) 133 if (parent_)
133 parent_->RemoveChild(this); 134 parent_->RemoveChild(this);
134 // |children_| will be modified during destruction. 135 // |children_| will be modified during destruction.
135 std::set<Instance*> children = children_; 136 std::set<Instance*> children = children_;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 std::move(client_process_connection->shell_client), 0)); 210 std::move(client_process_connection->shell_client), 0));
210 pid_receiver_binding_.Bind( 211 pid_receiver_binding_.Bind(
211 std::move(client_process_connection->pid_receiver_request)); 212 std::move(client_process_connection->pid_receiver_request));
212 StartWithClient(std::move(client)); 213 StartWithClient(std::move(client));
213 } 214 }
214 215
215 void StartWithFilePath(const base::FilePath& path) { 216 void StartWithFilePath(const base::FilePath& path) {
216 CHECK(!shell_client_); 217 CHECK(!shell_client_);
217 runner_ = shell_->native_runner_factory_->Create(path); 218 runner_ = shell_->native_runner_factory_->Create(path);
218 bool start_sandboxed = false; 219 bool start_sandboxed = false;
219 // We own |runner_|, so Unretained is safe here.
michaeln 2016/05/06 22:12:42 The InProcessNativeRunner wraps the OnRunnerComple
220 mojom::ShellClientPtr client = runner_->Start( 220 mojom::ShellClientPtr client = runner_->Start(
221 path, identity_, start_sandboxed, 221 path, identity_, start_sandboxed,
222 base::Bind(&Instance::PIDAvailable, base::Unretained(this)), 222 base::Bind(&Instance::PIDAvailable, weak_factory_.GetWeakPtr()),
223 base::Bind(&Instance::OnRunnerCompleted, base::Unretained(this))); 223 base::Bind(&Instance::OnRunnerCompleted, weak_factory_.GetWeakPtr()));
224 StartWithClient(std::move(client)); 224 StartWithClient(std::move(client));
225 } 225 }
226 226
227 mojom::InstanceInfoPtr CreateInstanceInfo() const { 227 mojom::InstanceInfoPtr CreateInstanceInfo() const {
228 mojom::InstanceInfoPtr info(mojom::InstanceInfo::New()); 228 mojom::InstanceInfoPtr info(mojom::InstanceInfo::New());
229 info->id = id_; 229 info->id = id_;
230 info->identity = mojom::Identity::From(identity_); 230 info->identity = mojom::Identity::From(identity_);
231 info->pid = pid_; 231 info->pid = pid_;
232 return info; 232 return info;
233 } 233 }
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 const CapabilitySpec capability_spec_; 447 const CapabilitySpec capability_spec_;
448 const bool allow_any_application_; 448 const bool allow_any_application_;
449 std::unique_ptr<NativeRunner> runner_; 449 std::unique_ptr<NativeRunner> runner_;
450 mojom::ShellClientPtr shell_client_; 450 mojom::ShellClientPtr shell_client_;
451 mojo::Binding<mojom::PIDReceiver> pid_receiver_binding_; 451 mojo::Binding<mojom::PIDReceiver> pid_receiver_binding_;
452 mojo::BindingSet<mojom::Connector> connectors_; 452 mojo::BindingSet<mojom::Connector> connectors_;
453 mojo::BindingSet<mojom::Shell> shell_bindings_; 453 mojo::BindingSet<mojom::Shell> shell_bindings_;
454 base::ProcessId pid_ = base::kNullProcessId; 454 base::ProcessId pid_ = base::kNullProcessId;
455 Instance* parent_ = nullptr; 455 Instance* parent_ = nullptr;
456 std::set<Instance*> children_; 456 std::set<Instance*> children_;
457 base::WeakPtrFactory<Instance> weak_factory_;
457 458
458 DISALLOW_COPY_AND_ASSIGN(Instance); 459 DISALLOW_COPY_AND_ASSIGN(Instance);
459 }; 460 };
460 461
461 // static 462 // static
462 Shell::TestAPI::TestAPI(Shell* shell) : shell_(shell) {} 463 Shell::TestAPI::TestAPI(Shell* shell) : shell_(shell) {}
463 Shell::TestAPI::~TestAPI() {} 464 Shell::TestAPI::~TestAPI() {}
464 465
465 bool Shell::TestAPI::HasRunningInstanceForName(const std::string& name) const { 466 bool Shell::TestAPI::HasRunningInstanceForName(const std::string& name) const {
466 for (const auto& entry : shell_->identity_to_instance_) { 467 for (const auto& entry : shell_->identity_to_instance_) {
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 783
783 // Now that the instance has a ShellClient, we can connect to it. 784 // Now that the instance has a ShellClient, we can connect to it.
784 instance->ConnectToClient(std::move(params)); 785 instance->ConnectToClient(std::move(params));
785 } 786 }
786 787
787 base::WeakPtr<Shell> Shell::GetWeakPtr() { 788 base::WeakPtr<Shell> Shell::GetWeakPtr() {
788 return weak_ptr_factory_.GetWeakPtr(); 789 return weak_ptr_factory_.GetWeakPtr();
789 } 790 }
790 791
791 } // namespace shell 792 } // namespace shell
OLDNEW
« no previous file with comments | « content/public/app/mojo/content_browser_manifest.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698