OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2012 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 PPAPI_HOST_RESOURCE_HOST_H_ | |
6 #define PPAPI_HOST_RESOURCE_HOST_H_ | |
7 | |
8 #include "base/basictypes.h" | |
9 #include "ppapi/c/pp_resource.h" | |
10 #include "ppapi/host/ppapi_host_export.h" | |
11 #include "ppapi/shared_impl/host_resource.h" | |
12 | |
13 namespace IPC { | |
14 class Message; | |
15 } | |
16 | |
17 namespace ppapi { | |
18 namespace host { | |
19 | |
20 struct HostMessageContext; | |
21 class PpapiHost; | |
22 | |
23 // Some (but not all) resources have a corresponding object in the host side | |
24 // that is kept alive as long as the resource in the plugin is alive. This is | |
25 // the base class for such objects. | |
26 class PPAPI_HOST_EXPORT ResourceHost { | |
27 public: | |
28 ResourceHost(PpapiHost* host, PP_Instance instance, PP_Resource resource); | |
29 virtual ~ResourceHost(); | |
30 | |
31 PpapiHost* host() { return host_; } | |
32 PP_Instance pp_instance() const { return pp_instance_; } | |
33 PP_Resource pp_resource() const { return pp_resource_; } | |
34 | |
35 // Handles messages associated with a given resource object. If the flags | |
36 // indicate that a response is required, the return value of this function | |
37 // will be sent as a resource message "response" along with the message | |
38 // specified in the reply of the context. | |
39 // | |
40 // You can do a response asynchronously by returning PP_OK_COMPLETIONPENDING. | |
41 // This will cause the reply to be skipped, and the class implementing this | |
42 // function will take responsibility for issuing the callback later. | |
43 // | |
44 // If you don't have a particular reply message, you can just ignore | |
45 // |optional_reply|. However, if you have a reply more than just the int32_t | |
dmichael (off chromium)
2012/06/29 22:54:03
missed two |optional_reply|s (45 and 46)
| |
46 // result code, just set |*optional_reply| to be the message of your | |
47 // choosing. | |
48 // | |
49 // The default implementation just returns PP_ERROR_NOTSUPPORTED. | |
50 virtual int32_t OnResourceMessageReceived(const IPC::Message& msg, | |
51 HostMessageContext* context); | |
52 | |
53 private: | |
54 // The host that owns this object. | |
55 PpapiHost* host_; | |
56 | |
57 PP_Instance pp_instance_; | |
58 PP_Resource pp_resource_; | |
59 | |
60 DISALLOW_COPY_AND_ASSIGN(ResourceHost); | |
61 }; | |
62 | |
63 } // namespace host | |
64 } // namespace ppapi | |
65 | |
66 #endif // PPAPI_HOST_RESOURCE_HOST_H_ | |
OLD | NEW |