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

Side by Side Diff: mash/browser/browser.cc

Issue 2476063002: Service Manager: Rework Service and ServiceContext lifetime (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
« no previous file with comments | « mash/browser/browser.h ('k') | mash/catalog_viewer/catalog_viewer.h » ('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 "mash/browser/browser.h" 5 #include "mash/browser/browser.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/strings/string16.h" 11 #include "base/strings/string16.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "base/threading/thread_task_runner_handle.h" 14 #include "base/threading/thread_task_runner_handle.h"
15 #include "base/timer/timer.h" 15 #include "base/timer/timer.h"
16 #include "mash/browser/debug_view.h" 16 #include "mash/browser/debug_view.h"
17 #include "mash/public/interfaces/launchable.mojom.h" 17 #include "mash/public/interfaces/launchable.mojom.h"
18 #include "services/navigation/public/cpp/view.h" 18 #include "services/navigation/public/cpp/view.h"
19 #include "services/navigation/public/cpp/view_delegate.h" 19 #include "services/navigation/public/cpp/view_delegate.h"
20 #include "services/navigation/public/cpp/view_observer.h" 20 #include "services/navigation/public/cpp/view_observer.h"
21 #include "services/navigation/public/interfaces/view.mojom.h" 21 #include "services/navigation/public/interfaces/view.mojom.h"
22 #include "services/service_manager/public/c/main.h" 22 #include "services/service_manager/public/c/main.h"
23 #include "services/service_manager/public/cpp/connector.h" 23 #include "services/service_manager/public/cpp/connector.h"
24 #include "services/service_manager/public/cpp/interface_registry.h"
24 #include "services/service_manager/public/cpp/service.h" 25 #include "services/service_manager/public/cpp/service.h"
26 #include "services/service_manager/public/cpp/service_context.h"
25 #include "services/service_manager/public/cpp/service_runner.h" 27 #include "services/service_manager/public/cpp/service_runner.h"
26 #include "services/tracing/public/cpp/provider.h" 28 #include "services/tracing/public/cpp/provider.h"
27 #include "services/ui/public/cpp/window.h" 29 #include "services/ui/public/cpp/window.h"
28 #include "services/ui/public/cpp/window_tree_client.h" 30 #include "services/ui/public/cpp/window_tree_client.h"
29 #include "ui/aura/mus/mus_util.h" 31 #include "ui/aura/mus/mus_util.h"
30 #include "ui/base/models/menu_model.h" 32 #include "ui/base/models/menu_model.h"
31 #include "ui/gfx/canvas.h" 33 #include "ui/gfx/canvas.h"
32 #include "ui/gfx/paint_throbber.h" 34 #include "ui/gfx/paint_throbber.h"
33 #include "ui/gfx/text_constants.h" 35 #include "ui/gfx/text_constants.h"
34 #include "ui/native_theme/native_theme.h" 36 #include "ui/native_theme/native_theme.h"
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 void Browser::RemoveWindow(views::Widget* window) { 858 void Browser::RemoveWindow(views::Widget* window) {
857 auto it = std::find(windows_.begin(), windows_.end(), window); 859 auto it = std::find(windows_.begin(), windows_.end(), window);
858 DCHECK(it != windows_.end()); 860 DCHECK(it != windows_.end());
859 windows_.erase(it); 861 windows_.erase(it);
860 if (windows_.empty()) 862 if (windows_.empty())
861 base::MessageLoop::current()->QuitWhenIdle(); 863 base::MessageLoop::current()->QuitWhenIdle();
862 } 864 }
863 865
864 std::unique_ptr<navigation::View> Browser::CreateView() { 866 std::unique_ptr<navigation::View> Browser::CreateView() {
865 navigation::mojom::ViewFactoryPtr factory; 867 navigation::mojom::ViewFactoryPtr factory;
866 connector()->ConnectToInterface("exe:navigation", &factory); 868 context_->connector()->ConnectToInterface("exe:navigation", &factory);
867 return base::MakeUnique<navigation::View>(std::move(factory)); 869 return base::MakeUnique<navigation::View>(std::move(factory));
868 } 870 }
869 871
870 void Browser::OnStart(const service_manager::ServiceInfo& info) { 872 void Browser::OnStart(service_manager::ServiceContext* context) {
871 tracing_.Initialize(connector(), info.identity.name()); 873 context_ = context;
874 tracing_.Initialize(context->connector(), context->identity().name());
872 875
873 aura_init_ = base::MakeUnique<views::AuraInit>(connector(), info.identity, 876 aura_init_ = base::MakeUnique<views::AuraInit>(
874 "views_mus_resources.pak"); 877 context->connector(), context->identity(), "views_mus_resources.pak");
875 window_manager_connection_ = 878 window_manager_connection_ = views::WindowManagerConnection::Create(
876 views::WindowManagerConnection::Create(connector(), info.identity); 879 context->connector(), context->identity());
877 } 880 }
878 881
879 bool Browser::OnConnect(const service_manager::ServiceInfo& remote_info, 882 bool Browser::OnConnect(const service_manager::ServiceInfo& remote_info,
880 service_manager::InterfaceRegistry* registry) { 883 service_manager::InterfaceRegistry* registry) {
881 registry->AddInterface<mojom::Launchable>(this); 884 registry->AddInterface<mojom::Launchable>(this);
882 return true; 885 return true;
883 } 886 }
884 887
885 void Browser::Launch(uint32_t what, mojom::LaunchMode how) { 888 void Browser::Launch(uint32_t what, mojom::LaunchMode how) {
886 bool reuse = 889 bool reuse =
(...skipping 11 matching lines...) Expand all
898 AddWindow(window); 901 AddWindow(window);
899 } 902 }
900 903
901 void Browser::Create(const service_manager::Identity& remote_identity, 904 void Browser::Create(const service_manager::Identity& remote_identity,
902 mojom::LaunchableRequest request) { 905 mojom::LaunchableRequest request) {
903 bindings_.AddBinding(this, std::move(request)); 906 bindings_.AddBinding(this, std::move(request));
904 } 907 }
905 908
906 } // namespace browser 909 } // namespace browser
907 } // namespace mash 910 } // namespace mash
OLDNEW
« no previous file with comments | « mash/browser/browser.h ('k') | mash/catalog_viewer/catalog_viewer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698