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

Side by Side Diff: content/browser/device_sensors/device_sensor_host.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
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 "content/browser/device_sensors/device_sensor_host.h" 5 #include "content/browser/device_sensors/device_sensor_host.h"
6 6
7 #include "content/browser/device_sensors/device_sensor_service.h" 7 #include "content/browser/device_sensors/device_sensor_service.h"
8 #include "content/public/browser/browser_thread.h" 8 #include "content/public/browser/browser_thread.h"
9 #include "mojo/public/cpp/bindings/strong_binding.h"
9 10
10 namespace content { 11 namespace content {
11 12
12 template <typename MojoInterface, ConsumerType consumer_type> 13 template <typename MojoInterface, ConsumerType consumer_type>
13 void DeviceSensorHost<MojoInterface, consumer_type>::Create( 14 void DeviceSensorHost<MojoInterface, consumer_type>::Create(
14 mojo::InterfaceRequest<MojoInterface> request) { 15 mojo::InterfaceRequest<MojoInterface> request) {
15 new DeviceSensorHost(std::move(request)); 16 mojo::MakeStrongBinding(
17 base::WrapUnique(new DeviceSensorHost<MojoInterface, consumer_type>),
18 std::move(request));
16 } 19 }
17 20
18 template <typename MojoInterface, ConsumerType consumer_type> 21 template <typename MojoInterface, ConsumerType consumer_type>
19 DeviceSensorHost<MojoInterface, consumer_type>::DeviceSensorHost( 22 DeviceSensorHost<MojoInterface, consumer_type>::DeviceSensorHost()
20 mojo::InterfaceRequest<MojoInterface> request) 23 : is_started_(false) {
21 : is_started_(false), binding_(this, std::move(request)) {
22 DCHECK_CURRENTLY_ON(BrowserThread::IO); 24 DCHECK_CURRENTLY_ON(BrowserThread::IO);
23 } 25 }
24 26
25 template <typename MojoInterface, ConsumerType consumer_type> 27 template <typename MojoInterface, ConsumerType consumer_type>
26 DeviceSensorHost<MojoInterface, consumer_type>::~DeviceSensorHost() { 28 DeviceSensorHost<MojoInterface, consumer_type>::~DeviceSensorHost() {
27 DCHECK(thread_checker_.CalledOnValidThread()); 29 DCHECK(thread_checker_.CalledOnValidThread());
28 if (is_started_) 30 if (is_started_)
29 DeviceSensorService::GetInstance()->RemoveConsumer(consumer_type); 31 DeviceSensorService::GetInstance()->RemoveConsumer(consumer_type);
30 } 32 }
31 33
(...skipping 24 matching lines...) Expand all
56 template class DeviceSensorHost<device::mojom::LightSensor, 58 template class DeviceSensorHost<device::mojom::LightSensor,
57 CONSUMER_TYPE_LIGHT>; 59 CONSUMER_TYPE_LIGHT>;
58 template class DeviceSensorHost<device::mojom::MotionSensor, 60 template class DeviceSensorHost<device::mojom::MotionSensor,
59 CONSUMER_TYPE_MOTION>; 61 CONSUMER_TYPE_MOTION>;
60 template class DeviceSensorHost<device::mojom::OrientationSensor, 62 template class DeviceSensorHost<device::mojom::OrientationSensor,
61 CONSUMER_TYPE_ORIENTATION>; 63 CONSUMER_TYPE_ORIENTATION>;
62 template class DeviceSensorHost<device::mojom::OrientationAbsoluteSensor, 64 template class DeviceSensorHost<device::mojom::OrientationAbsoluteSensor,
63 CONSUMER_TYPE_ORIENTATION_ABSOLUTE>; 65 CONSUMER_TYPE_ORIENTATION_ABSOLUTE>;
64 66
65 } // namespace content 67 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/device_sensors/device_sensor_host.h ('k') | content/browser/hyphenation/hyphenation_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698