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

Side by Side Diff: device/vr/vr_service_impl.cc

Issue 2625373002: Fix crash when destory VRServiceImpl (Closed)
Patch Set: Created 3 years, 11 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 | « no previous file | no next file » | 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 "device/vr/vr_service_impl.h" 5 #include "device/vr/vr_service_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "device/vr/vr_device.h" 11 #include "device/vr/vr_device.h"
12 #include "device/vr/vr_device_manager.h" 12 #include "device/vr/vr_device_manager.h"
13 #include "mojo/public/cpp/bindings/strong_binding.h" 13 #include "mojo/public/cpp/bindings/strong_binding.h"
14 14
15 namespace device { 15 namespace device {
16 16
17 VRServiceImpl::VRServiceImpl() : listening_for_activate_(false) {} 17 VRServiceImpl::VRServiceImpl() : listening_for_activate_(false) {}
18 18
19 VRServiceImpl::~VRServiceImpl() { 19 VRServiceImpl::~VRServiceImpl() {
20 // Destroy VRDisplay before calling RemoveService below. RemoveService might
21 // implicitly trigger destory VRDevice which VRDisplay needs to access in its
22 // dtor.
23 displays_.clear();
20 VRDeviceManager::GetInstance()->RemoveService(this); 24 VRDeviceManager::GetInstance()->RemoveService(this);
21 } 25 }
22 26
23 void VRServiceImpl::Create(mojo::InterfaceRequest<mojom::VRService> request) { 27 void VRServiceImpl::Create(mojo::InterfaceRequest<mojom::VRService> request) {
24 mojo::MakeStrongBinding(base::MakeUnique<VRServiceImpl>(), 28 mojo::MakeStrongBinding(base::MakeUnique<VRServiceImpl>(),
25 std::move(request)); 29 std::move(request));
26 } 30 }
27 31
28 // Gets a VRDisplayPtr unique to this service so that the associated page can 32 // Gets a VRDisplayPtr unique to this service so that the associated page can
29 // communicate with the VRDevice. 33 // communicate with the VRDevice.
(...skipping 24 matching lines...) Expand all
54 callback.Run(device_manager->GetNumberOfConnectedDevices()); 58 callback.Run(device_manager->GetNumberOfConnectedDevices());
55 } 59 }
56 60
57 void VRServiceImpl::SetListeningForActivate(bool listening) { 61 void VRServiceImpl::SetListeningForActivate(bool listening) {
58 listening_for_activate_ = listening; 62 listening_for_activate_ = listening;
59 VRDeviceManager* device_manager = VRDeviceManager::GetInstance(); 63 VRDeviceManager* device_manager = VRDeviceManager::GetInstance();
60 device_manager->ListeningForActivateChanged(listening); 64 device_manager->ListeningForActivateChanged(listening);
61 } 65 }
62 66
63 } // namespace device 67 } // namespace device
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698