BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / chromecast / base / cast_resource.h
blob8836e9c7c1783609ee10b20046763d2733b8ae20
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.
5 #ifndef CHROMECAST_BASE_CAST_RESOURCE_H_
6 #define CHROMECAST_BASE_CAST_RESOURCE_H_
8 #include "base/macros.h"
10 namespace chromecast {
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),
36 class Client {
37 public:
38 // Called when resource is created. CastResource should not be owned by
39 // Client. It can be called from any thread.
40 virtual void OnResourceAcquired(CastResource* cast_resource) = 0;
41 // Called when part or all resources are released. It can be called from any
42 // thread.
43 // |cast_resource| the CastResource that is released. The pointer may be
44 // invalid. Client can't call functions with that pointer.
45 // |remain| the unreleased resource of CastResource. If kResourceNone is
46 // returned, Client will remove the resource from its watching
47 // list.
48 virtual void OnResourceReleased(CastResource* cast_resource,
49 Resource remain) = 0;
51 protected:
52 virtual ~Client() {}
55 CastResource() {}
57 virtual void SetCastResourceClient(Client* client) = 0;
58 // Called to release resources. Implementation should call
59 // Client::OnResourceReleased when resource is released on its side.
60 virtual void ReleaseResource(Resource resource) = 0;
62 protected:
63 virtual ~CastResource() {}
65 private:
66 DISALLOW_COPY_AND_ASSIGN(CastResource);
69 } // namespace chromecast
71 #endif