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

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

Issue 1775243002: Rename PackageManager->Catalog. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@42cpi
Patch Set: . Created 4 years, 9 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/shell/shell.h ('k') | mojo/shell/standalone/BUILD.gn » ('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 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 "mojo/shell/shell.h" 5 #include "mojo/shell/shell.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/guid.h" 13 #include "base/guid.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/process/process.h" 16 #include "base/process/process.h"
17 #include "base/process/process_handle.h" 17 #include "base/process/process_handle.h"
18 #include "base/stl_util.h" 18 #include "base/stl_util.h"
19 #include "base/strings/string_util.h" 19 #include "base/strings/string_util.h"
20 #include "base/trace_event/trace_event.h" 20 #include "base/trace_event/trace_event.h"
21 #include "mojo/common/url_type_converters.h" 21 #include "mojo/common/url_type_converters.h"
22 #include "mojo/public/cpp/bindings/binding.h" 22 #include "mojo/public/cpp/bindings/binding.h"
23 #include "mojo/public/cpp/bindings/binding_set.h" 23 #include "mojo/public/cpp/bindings/binding_set.h"
24 #include "mojo/services/package_manager/loader.h" 24 #include "mojo/services/catalog/loader.h"
25 #include "mojo/shell/connect_util.h" 25 #include "mojo/shell/connect_util.h"
26 #include "mojo/shell/public/cpp/connect.h" 26 #include "mojo/shell/public/cpp/connect.h"
27 #include "mojo/shell/public/cpp/names.h" 27 #include "mojo/shell/public/cpp/names.h"
28 #include "mojo/shell/public/cpp/shell_connection.h" 28 #include "mojo/shell/public/cpp/shell_connection.h"
29 #include "mojo/shell/public/interfaces/connector.mojom.h" 29 #include "mojo/shell/public/interfaces/connector.mojom.h"
30 #include "mojo/shell/public/interfaces/shell.mojom.h" 30 #include "mojo/shell/public/interfaces/shell.mojom.h"
31 #include "mojo/shell/public/interfaces/shell_client.mojom.h" 31 #include "mojo/shell/public/interfaces/shell_client.mojom.h"
32 #include "mojo/util/filename_util.h" 32 #include "mojo/util/filename_util.h"
33 33
34 namespace mojo { 34 namespace mojo {
35 namespace shell { 35 namespace shell {
36 namespace { 36 namespace {
37 const char kPackageManagerName[] = "mojo:package_manager"; 37 const char kCatalogName[] = "mojo:catalog";
38 38
39 void EmptyResolverCallback(const String& resolved_name, 39 void EmptyResolverCallback(const String& resolved_name,
40 const String& resolved_instance, 40 const String& resolved_instance,
41 mojom::CapabilityFilterPtr base_filter, 41 mojom::CapabilityFilterPtr base_filter,
42 const String& file_url) {} 42 const String& file_url) {}
43 43
44 } 44 }
45 45
46 Identity CreateShellIdentity() { 46 Identity CreateShellIdentity() {
47 return Identity("mojo:shell", mojom::kRootUserID); 47 return Identity("mojo:shell", mojom::kRootUserID);
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 return true; 318 return true;
319 } 319 }
320 return false; 320 return false;
321 } 321 }
322 322
323 //////////////////////////////////////////////////////////////////////////////// 323 ////////////////////////////////////////////////////////////////////////////////
324 // Shell, public: 324 // Shell, public:
325 325
326 Shell::Shell(scoped_ptr<NativeRunnerFactory> native_runner_factory, 326 Shell::Shell(scoped_ptr<NativeRunnerFactory> native_runner_factory,
327 base::TaskRunner* file_task_runner, 327 base::TaskRunner* file_task_runner,
328 scoped_ptr<package_manager::ApplicationCatalogStore> app_catalog) 328 scoped_ptr<catalog::Store> catalog_store)
329 : file_task_runner_(file_task_runner), 329 : file_task_runner_(file_task_runner),
330 native_runner_factory_(std::move(native_runner_factory)), 330 native_runner_factory_(std::move(native_runner_factory)),
331 weak_ptr_factory_(this) { 331 weak_ptr_factory_(this) {
332 mojom::ShellClientRequest request; 332 mojom::ShellClientRequest request;
333 CreateInstance(CreateShellIdentity(), GetPermissiveCapabilityFilter(), 333 CreateInstance(CreateShellIdentity(), GetPermissiveCapabilityFilter(),
334 &request); 334 &request);
335 shell_connection_.reset(new ShellConnection(this, std::move(request))); 335 shell_connection_.reset(new ShellConnection(this, std::move(request)));
336 336
337 InitPackageManager(std::move(app_catalog)); 337 InitCatalog(std::move(catalog_store));
338 } 338 }
339 339
340 Shell::~Shell() { 340 Shell::~Shell() {
341 TerminateShellConnections(); 341 TerminateShellConnections();
342 STLDeleteValues(&name_to_loader_); 342 STLDeleteValues(&name_to_loader_);
343 for (auto& runner : native_runners_) 343 for (auto& runner : native_runners_)
344 runner.reset(); 344 runner.reset();
345 } 345 }
346 346
347 void Shell::SetInstanceQuitCallback( 347 void Shell::SetInstanceQuitCallback(
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 break; 415 break;
416 } 416 }
417 } 417 }
418 DCHECK(instance); 418 DCHECK(instance);
419 return instance->AcceptConnection(connection); 419 return instance->AcceptConnection(connection);
420 } 420 }
421 421
422 //////////////////////////////////////////////////////////////////////////////// 422 ////////////////////////////////////////////////////////////////////////////////
423 // Shell, private: 423 // Shell, private:
424 424
425 void Shell::InitPackageManager( 425 void Shell::InitCatalog(scoped_ptr<catalog::Store> store) {
426 scoped_ptr<package_manager::ApplicationCatalogStore> app_catalog) {
427 scoped_ptr<Loader> loader( 426 scoped_ptr<Loader> loader(
428 new package_manager::Loader(file_task_runner_, std::move(app_catalog))); 427 new catalog::Loader(file_task_runner_, std::move(store)));
429 Loader* loader_raw = loader.get(); 428 Loader* loader_raw = loader.get();
430 std::string name = kPackageManagerName; 429 std::string name = kCatalogName;
431 SetLoaderForName(std::move(loader), name); 430 SetLoaderForName(std::move(loader), name);
432 431
433 mojom::ShellClientRequest request; 432 mojom::ShellClientRequest request;
434 // TODO(beng): Does the package manager actually have to be run with a 433 // TODO(beng): Does the catalog actually have to be run with a permissive
435 // permissive filter? 434 // filter?
436 Identity identity(name, mojom::kRootUserID); 435 Identity identity(name, mojom::kRootUserID);
437 CreateInstance(identity, GetPermissiveCapabilityFilter(), &request); 436 CreateInstance(identity, GetPermissiveCapabilityFilter(), &request);
438 loader_raw->Load(name, std::move(request)); 437 loader_raw->Load(name, std::move(request));
439 438
440 ConnectToInterface(this, CreateShellIdentity(), name, &shell_resolver_); 439 ConnectToInterface(this, CreateShellIdentity(), name, &shell_resolver_);
441 440
442 // Seed the catalog with manifest info for the shell & package manager. 441 // Seed the catalog with manifest info for the shell & catalog.
443 if (file_task_runner_) { 442 if (file_task_runner_) {
444 shell_resolver_->ResolveMojoName(name, base::Bind(&EmptyResolverCallback)); 443 shell_resolver_->ResolveMojoName(name, base::Bind(&EmptyResolverCallback));
445 shell_resolver_->ResolveMojoName("mojo:shell", 444 shell_resolver_->ResolveMojoName("mojo:shell",
446 base::Bind(&EmptyResolverCallback)); 445 base::Bind(&EmptyResolverCallback));
447 } 446 }
448 } 447 }
449 448
450 void Shell::TerminateShellConnections() { 449 void Shell::TerminateShellConnections() {
451 STLDeleteValues(&identity_to_instance_); 450 STLDeleteValues(&identity_to_instance_);
452 } 451 }
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 for (auto it = native_runners_.begin(); it != native_runners_.end(); ++it) { 638 for (auto it = native_runners_.begin(); it != native_runners_.end(); ++it) {
640 if (it->get() == runner) { 639 if (it->get() == runner) {
641 native_runners_.erase(it); 640 native_runners_.erase(it);
642 return; 641 return;
643 } 642 }
644 } 643 }
645 } 644 }
646 645
647 } // namespace shell 646 } // namespace shell
648 } // namespace mojo 647 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/shell.h ('k') | mojo/shell/standalone/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698