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

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

Issue 2215133002: Change signature of OnConnect (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cleanup
Patch Set: . Created 4 years, 4 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/shell/background/tests/test_service.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 "services/navigation/view_impl.h" 10 #include "services/navigation/view_impl.h"
(...skipping 17 matching lines...) Expand all
28 } // namespace 28 } // namespace
29 29
30 Navigation::Navigation() 30 Navigation::Navigation()
31 : view_task_runner_(base::ThreadTaskRunnerHandle::Get()), 31 : view_task_runner_(base::ThreadTaskRunnerHandle::Get()),
32 ref_factory_(base::MessageLoop::QuitWhenIdleClosure()) { 32 ref_factory_(base::MessageLoop::QuitWhenIdleClosure()) {
33 bindings_.set_connection_error_handler( 33 bindings_.set_connection_error_handler(
34 base::Bind(&Navigation::ViewFactoryLost, base::Unretained(this))); 34 base::Bind(&Navigation::ViewFactoryLost, base::Unretained(this)));
35 } 35 }
36 Navigation::~Navigation() {} 36 Navigation::~Navigation() {}
37 37
38 bool Navigation::OnConnect(shell::Connection* connection, 38 bool Navigation::OnConnect(const shell::Identity& remote_identity,
39 shell::InterfaceRegistry* registry,
39 shell::Connector* connector) { 40 shell::Connector* connector) {
40 std::string remote_user_id = connection->GetRemoteIdentity().user_id(); 41 std::string remote_user_id = remote_identity.user_id();
41 if (!client_user_id_.empty() && client_user_id_ != remote_user_id) { 42 if (!client_user_id_.empty() && client_user_id_ != remote_user_id) {
42 LOG(ERROR) << "Must have a separate Navigation service instance for " 43 LOG(ERROR) << "Must have a separate Navigation service instance for "
43 << "different BrowserContexts."; 44 << "different BrowserContexts.";
44 return false; 45 return false;
45 } 46 }
46 client_user_id_ = remote_user_id; 47 client_user_id_ = remote_user_id;
47 48
48 connection->AddInterface<mojom::ViewFactory>(this); 49 registry->AddInterface<mojom::ViewFactory>(this);
49 return true; 50 return true;
50 } 51 }
51 52
52 void Navigation::Create(const shell::Identity& remote_identity, 53 void Navigation::Create(const shell::Identity& remote_identity,
53 mojom::ViewFactoryRequest request) { 54 mojom::ViewFactoryRequest request) {
54 bindings_.AddBinding(this, std::move(request)); 55 bindings_.AddBinding(this, std::move(request));
55 refs_.insert(ref_factory_.CreateRef()); 56 refs_.insert(ref_factory_.CreateRef());
56 } 57 }
57 58
58 void Navigation::CreateView(mojom::ViewClientPtr client, 59 void Navigation::CreateView(mojom::ViewClientPtr client,
59 mojom::ViewRequest request) { 60 mojom::ViewRequest request) {
60 std::unique_ptr<shell::Connector> new_connector = connector_->Clone(); 61 std::unique_ptr<shell::Connector> new_connector = connector_->Clone();
61 std::unique_ptr<shell::ServiceContextRef> context_ref = 62 std::unique_ptr<shell::ServiceContextRef> context_ref =
62 ref_factory_.CreateRef(); 63 ref_factory_.CreateRef();
63 view_task_runner_->PostTask( 64 view_task_runner_->PostTask(
64 FROM_HERE, 65 FROM_HERE,
65 base::Bind(&CreateViewOnViewTaskRunner, base::Passed(&new_connector), 66 base::Bind(&CreateViewOnViewTaskRunner, base::Passed(&new_connector),
66 client_user_id_, base::Passed(&client), base::Passed(&request), 67 client_user_id_, base::Passed(&client), base::Passed(&request),
67 base::Passed(&context_ref))); 68 base::Passed(&context_ref)));
68 } 69 }
69 70
70 void Navigation::ViewFactoryLost() { 71 void Navigation::ViewFactoryLost() {
71 refs_.erase(refs_.begin()); 72 refs_.erase(refs_.begin());
72 } 73 }
73 74
74 } // navigation 75 } // navigation
OLDNEW
« no previous file with comments | « services/navigation/navigation.h ('k') | services/shell/background/tests/test_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698