summaryrefslogtreecommitdiff
path: root/chromium/device/vr/vr_service_impl.h
blob: ba8b6b162dd3949158b6676a41159a3ba858dc60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef DEVICE_VR_VR_SERVICE_IMPL_H
#define DEVICE_VR_VR_SERVICE_IMPL_H

#include <memory>

#include "base/macros.h"

#include "device/vr/vr_device.h"
#include "device/vr/vr_display_impl.h"
#include "device/vr/vr_export.h"
#include "device/vr/vr_service.mojom.h"
#include "mojo/public/cpp/bindings/binding.h"

namespace device {

class VRServiceImpl : public mojom::VRService {
 public:
  DEVICE_VR_EXPORT VRServiceImpl();
  DEVICE_VR_EXPORT ~VRServiceImpl() override;

  DEVICE_VR_EXPORT static void Create(
      mojo::InterfaceRequest<mojom::VRService> request);

  mojom::VRServiceClient* client() { return client_.get(); }

  DEVICE_VR_EXPORT VRDisplayImpl* GetVRDisplayImpl(VRDevice* device);

  // mojom::VRService implementation
  void SetClient(mojom::VRServiceClientPtr service_client,
                 const SetClientCallback& callback) override;

  bool listening_for_activate() { return listening_for_activate_; }

 private:
  friend class FakeVRServiceClient;
  friend class VRDeviceManagerTest;
  friend class VRDisplayImpl;
  friend class VRDisplayImplTest;
  friend class VRServiceImplTest;

  void RemoveDevice(VRDevice* device);

  void SetListeningForActivate(bool listening) override;

  std::map<VRDevice*, std::unique_ptr<VRDisplayImpl>> displays_;

  mojom::VRServiceClientPtr client_;

  bool listening_for_activate_;

  DISALLOW_COPY_AND_ASSIGN(VRServiceImpl);
};

}  // namespace device

#endif  // DEVICE_VR_VR_SERVICE_IMPL_H