OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/browser/vr/vr_service_consumer.h" |
| 6 |
| 7 #include "content/browser/vr/vr_service.h" |
| 8 |
| 9 namespace content { |
| 10 |
| 11 VRServiceConsumer::VRServiceConsumer() : |
| 12 service_(NULL), |
| 13 registered_with_service_(false) { |
| 14 } |
| 15 |
| 16 VRServiceConsumer::VRServiceConsumer(VRService* service) : |
| 17 service_(service), |
| 18 registered_with_service_(false) { |
| 19 } |
| 20 |
| 21 VRServiceConsumer::~VRServiceConsumer() { |
| 22 if (registered_with_service_) { |
| 23 service_->RemoveConsumer(this); |
| 24 } |
| 25 } |
| 26 |
| 27 VRService* VRServiceConsumer::GetServiceInstance() { |
| 28 if (!registered_with_service_) { |
| 29 if (!service_) { |
| 30 service_ = VRService::GetInstance(); |
| 31 } |
| 32 service_->AddConsumer(this); |
| 33 registered_with_service_ = true; |
| 34 } |
| 35 return service_; |
| 36 } |
| 37 |
| 38 } // namespace content |
OLD | NEW |