Chromium Code Reviews| 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 #ifndef CHROMECAST_BASE_CAST_RESOURCE_H_ | |
| 6 #define CHROMECAST_BASE_CAST_RESOURCE_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 | |
| 10 namespace chromecast { | |
| 11 | |
| 12 // Interface for resources needed to run application. | |
| 13 class CastResource { | |
| 14 public: | |
| 15 // Resources necessary to run cast apps. CastResource may contain union of the | |
| 16 // following types. | |
| 17 // TODO(yucliu): Split video resources and graphic resources. | |
| 18 enum Resource { | |
| 19 kResourceNone = 0, | |
| 20 // All resources necessary to render sounds, for example, audio pipeline, | |
| 21 // speaker, etc. | |
| 22 kResourceAudio = 1 << 0, | |
| 23 // All resources necessary to render videos or images, for example, video | |
| 24 // pipeline, primary graphics plane, display, etc. | |
| 25 kResourceScreenPrimary = 1 << 1, | |
| 26 // All resources necessary to render overlaid images, for example, secondary | |
| 27 // graphics plane, LCD, etc. | |
| 28 kResourceScreenSecondary = 1 << 2, | |
| 29 // Collection of resources used for display only combined with bitwise or. | |
| 30 kResourceDisplayOnly = (kResourceScreenPrimary | kResourceScreenSecondary), | |
| 31 // Collection of all resources combined with bitwise or. | |
| 32 kResourceAll = | |
| 33 (kResourceAudio | kResourceScreenPrimary | kResourceScreenSecondary), | |
| 34 }; | |
| 35 | |
| 36 class Client { | |
| 37 public: | |
| 38 // Called when resource is created. CastResource should not be owned by | |
| 39 // Client. | |
|
gunsch
2015/09/02 17:10:50
Please indicate that these can be called on any th
yucliu1
2015/09/02 17:30:18
Done.
| |
| 40 virtual void OnResourceAcquired(CastResource* cast_resource) = 0; | |
| 41 // Called when part or all resources are released. | |
| 42 // |cast_resource| the CastResource that is released. The pointer may be | |
| 43 // invalid. Client can't call functions with that pointer. | |
| 44 // |remain| the unreleased resource of CastResource. If kResourceNone is | |
| 45 // returned, Client will remove the resource from its watching | |
| 46 // list. | |
| 47 virtual void OnResourceReleased(CastResource* cast_resource, | |
| 48 Resource remain) = 0; | |
| 49 | |
| 50 protected: | |
| 51 virtual ~Client() {} | |
| 52 }; | |
| 53 | |
| 54 CastResource() {} | |
| 55 | |
| 56 virtual void SetCastResourceClient(Client* client) = 0; | |
| 57 // Called to release resources. Implementation should call | |
| 58 // Client::OnResourceReleased when resource is released on its side. | |
| 59 virtual void ReleaseResource(Resource resource) = 0; | |
| 60 | |
| 61 protected: | |
| 62 virtual ~CastResource() {} | |
| 63 | |
| 64 private: | |
| 65 DISALLOW_COPY_AND_ASSIGN(CastResource); | |
| 66 }; | |
| 67 | |
| 68 } // namespace chromecast | |
| 69 | |
| 70 #endif | |
| OLD | NEW |