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

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

Issue 2420253002: Rename shell namespace to service_manager (Closed)
Patch Set: . Created 4 years, 2 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 | « services/navigation/navigation.h ('k') | services/navigation/navigation_unittest.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 "services/navigation/navigation.h" 5 #include "services/navigation/navigation.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/threading/thread_task_runner_handle.h" 9 #include "base/threading/thread_task_runner_handle.h"
10 #include "mojo/public/cpp/bindings/strong_binding.h" 10 #include "mojo/public/cpp/bindings/strong_binding.h"
11 #include "services/navigation/view_impl.h" 11 #include "services/navigation/view_impl.h"
12 #include "services/service_manager/public/cpp/connector.h" 12 #include "services/service_manager/public/cpp/connector.h"
13 13
14 namespace navigation { 14 namespace navigation {
15 15
16 namespace { 16 namespace {
17 17
18 void CreateViewOnViewTaskRunner( 18 void CreateViewOnViewTaskRunner(
19 std::unique_ptr<shell::Connector> connector, 19 std::unique_ptr<service_manager::Connector> connector,
20 const std::string& client_user_id, 20 const std::string& client_user_id,
21 mojom::ViewClientPtr client, 21 mojom::ViewClientPtr client,
22 mojom::ViewRequest request, 22 mojom::ViewRequest request,
23 std::unique_ptr<shell::ServiceContextRef> context_ref) { 23 std::unique_ptr<service_manager::ServiceContextRef> context_ref) {
24 mojo::MakeStrongBinding( 24 mojo::MakeStrongBinding(
25 base::MakeUnique<ViewImpl>(std::move(connector), client_user_id, 25 base::MakeUnique<ViewImpl>(std::move(connector), client_user_id,
26 std::move(client), std::move(context_ref)), 26 std::move(client), std::move(context_ref)),
27 std::move(request)); 27 std::move(request));
28 } 28 }
29 29
30 } // namespace 30 } // namespace
31 31
32 Navigation::Navigation() 32 Navigation::Navigation()
33 : view_task_runner_(base::ThreadTaskRunnerHandle::Get()), 33 : view_task_runner_(base::ThreadTaskRunnerHandle::Get()),
34 ref_factory_(base::MessageLoop::QuitWhenIdleClosure()), 34 ref_factory_(base::MessageLoop::QuitWhenIdleClosure()),
35 weak_factory_(this) { 35 weak_factory_(this) {
36 bindings_.set_connection_error_handler( 36 bindings_.set_connection_error_handler(
37 base::Bind(&Navigation::ViewFactoryLost, base::Unretained(this))); 37 base::Bind(&Navigation::ViewFactoryLost, base::Unretained(this)));
38 } 38 }
39 Navigation::~Navigation() {} 39 Navigation::~Navigation() {}
40 40
41 bool Navigation::OnConnect(const shell::Identity& remote_identity, 41 bool Navigation::OnConnect(const service_manager::Identity& remote_identity,
42 shell::InterfaceRegistry* registry, 42 service_manager::InterfaceRegistry* registry,
43 shell::Connector* connector) { 43 service_manager::Connector* connector) {
44 std::string remote_user_id = remote_identity.user_id(); 44 std::string remote_user_id = remote_identity.user_id();
45 if (!client_user_id_.empty() && client_user_id_ != remote_user_id) { 45 if (!client_user_id_.empty() && client_user_id_ != remote_user_id) {
46 LOG(ERROR) << "Must have a separate Navigation service instance for " 46 LOG(ERROR) << "Must have a separate Navigation service instance for "
47 << "different BrowserContexts."; 47 << "different BrowserContexts.";
48 return false; 48 return false;
49 } 49 }
50 client_user_id_ = remote_user_id; 50 client_user_id_ = remote_user_id;
51 51
52 registry->AddInterface( 52 registry->AddInterface(
53 base::Bind(&Navigation::CreateViewFactory, weak_factory_.GetWeakPtr())); 53 base::Bind(&Navigation::CreateViewFactory, weak_factory_.GetWeakPtr()));
54 return true; 54 return true;
55 } 55 }
56 56
57 void Navigation::CreateView(mojom::ViewClientPtr client, 57 void Navigation::CreateView(mojom::ViewClientPtr client,
58 mojom::ViewRequest request) { 58 mojom::ViewRequest request) {
59 std::unique_ptr<shell::Connector> new_connector = connector_->Clone(); 59 std::unique_ptr<service_manager::Connector> new_connector =
60 std::unique_ptr<shell::ServiceContextRef> context_ref = 60 connector_->Clone();
61 std::unique_ptr<service_manager::ServiceContextRef> context_ref =
61 ref_factory_.CreateRef(); 62 ref_factory_.CreateRef();
62 view_task_runner_->PostTask( 63 view_task_runner_->PostTask(
63 FROM_HERE, 64 FROM_HERE,
64 base::Bind(&CreateViewOnViewTaskRunner, base::Passed(&new_connector), 65 base::Bind(&CreateViewOnViewTaskRunner, base::Passed(&new_connector),
65 client_user_id_, base::Passed(&client), base::Passed(&request), 66 client_user_id_, base::Passed(&client), base::Passed(&request),
66 base::Passed(&context_ref))); 67 base::Passed(&context_ref)));
67 } 68 }
68 69
69 void Navigation::CreateViewFactory(mojom::ViewFactoryRequest request) { 70 void Navigation::CreateViewFactory(mojom::ViewFactoryRequest request) {
70 bindings_.AddBinding(this, std::move(request)); 71 bindings_.AddBinding(this, std::move(request));
71 refs_.insert(ref_factory_.CreateRef()); 72 refs_.insert(ref_factory_.CreateRef());
72 } 73 }
73 74
74 void Navigation::ViewFactoryLost() { 75 void Navigation::ViewFactoryLost() {
75 refs_.erase(refs_.begin()); 76 refs_.erase(refs_.begin());
76 } 77 }
77 78
78 } // navigation 79 } // navigation
OLDNEW
« no previous file with comments | « services/navigation/navigation.h ('k') | services/navigation/navigation_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698