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

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

Issue 2326913003: Privatize StrongBinding lifetime management (Closed)
Patch Set: rebase Created 4 years, 3 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/file/file_system.cc ('k') | services/navigation/view_impl.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 "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 "services/navigation/view_impl.h" 11 #include "services/navigation/view_impl.h"
11 #include "services/shell/public/cpp/connector.h" 12 #include "services/shell/public/cpp/connector.h"
12 13
13 namespace navigation { 14 namespace navigation {
14 15
15 namespace { 16 namespace {
16 17
17 void CreateViewOnViewTaskRunner( 18 void CreateViewOnViewTaskRunner(
18 std::unique_ptr<shell::Connector> connector, 19 std::unique_ptr<shell::Connector> connector,
19 const std::string& client_user_id, 20 const std::string& client_user_id,
20 mojom::ViewClientPtr client, 21 mojom::ViewClientPtr client,
21 mojom::ViewRequest request, 22 mojom::ViewRequest request,
22 std::unique_ptr<shell::ServiceContextRef> context_ref) { 23 std::unique_ptr<shell::ServiceContextRef> context_ref) {
23 // Owns itself. 24 mojo::MakeStrongBinding(
24 new ViewImpl(std::move(connector), client_user_id, std::move(client), 25 base::MakeUnique<ViewImpl>(std::move(connector), client_user_id,
25 std::move(request), std::move(context_ref)); 26 std::move(client), std::move(context_ref)),
27 std::move(request));
26 } 28 }
27 29
28 } // namespace 30 } // namespace
29 31
30 Navigation::Navigation() 32 Navigation::Navigation()
31 : view_task_runner_(base::ThreadTaskRunnerHandle::Get()), 33 : view_task_runner_(base::ThreadTaskRunnerHandle::Get()),
32 ref_factory_(base::MessageLoop::QuitWhenIdleClosure()), 34 ref_factory_(base::MessageLoop::QuitWhenIdleClosure()),
33 weak_factory_(this) { 35 weak_factory_(this) {
34 bindings_.set_connection_error_handler( 36 bindings_.set_connection_error_handler(
35 base::Bind(&Navigation::ViewFactoryLost, base::Unretained(this))); 37 base::Bind(&Navigation::ViewFactoryLost, base::Unretained(this)));
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 void Navigation::CreateViewFactory(mojom::ViewFactoryRequest request) { 69 void Navigation::CreateViewFactory(mojom::ViewFactoryRequest request) {
68 bindings_.AddBinding(this, std::move(request)); 70 bindings_.AddBinding(this, std::move(request));
69 refs_.insert(ref_factory_.CreateRef()); 71 refs_.insert(ref_factory_.CreateRef());
70 } 72 }
71 73
72 void Navigation::ViewFactoryLost() { 74 void Navigation::ViewFactoryLost() {
73 refs_.erase(refs_.begin()); 75 refs_.erase(refs_.begin());
74 } 76 }
75 77
76 } // navigation 78 } // navigation
OLDNEW
« no previous file with comments | « services/file/file_system.cc ('k') | services/navigation/view_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698