Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: ppapi/proxy/resource_message_params.cc

Issue 10912062: Implement the gamepad API in the IPC proxy (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/proxy/resource_message_params.h ('k') | ppapi/shared_impl/ppapi_permissions.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ppapi/proxy/resource_message_params.h" 5 #include "ppapi/proxy/resource_message_params.h"
6 6
7 #include "ppapi/c/pp_errors.h" 7 #include "ppapi/c/pp_errors.h"
8 #include "ppapi/proxy/ppapi_messages.h" 8 #include "ppapi/proxy/ppapi_messages.h"
9 9
10 namespace ppapi { 10 namespace ppapi {
11 namespace proxy { 11 namespace proxy {
12 12
13 ResourceMessageParams::ResourceMessageParams() 13 ResourceMessageParams::ResourceMessageParams()
14 : pp_resource_(0), 14 : pp_resource_(0),
15 sequence_(0) { 15 sequence_(0) {
16 } 16 }
17 17
18 ResourceMessageParams::ResourceMessageParams(PP_Resource resource, 18 ResourceMessageParams::ResourceMessageParams(PP_Resource resource,
19 int32_t sequence) 19 int32_t sequence)
20 : pp_resource_(resource), 20 : pp_resource_(resource),
21 sequence_(sequence) { 21 sequence_(sequence) {
22 } 22 }
23 23
24 ResourceMessageParams::~ResourceMessageParams() { 24 ResourceMessageParams::~ResourceMessageParams() {
25 } 25 }
26 26
27 void ResourceMessageParams::Serialize(IPC::Message* msg) const { 27 void ResourceMessageParams::Serialize(IPC::Message* msg) const {
28 IPC::ParamTraits<PP_Resource>::Write(msg, pp_resource_); 28 IPC::ParamTraits<PP_Resource>::Write(msg, pp_resource_);
29 IPC::ParamTraits<int32_t>::Write(msg, sequence_); 29 IPC::ParamTraits<int32_t>::Write(msg, sequence_);
30 IPC::ParamTraits<std::vector<SerializedHandle> >::Write(msg, handles_);
30 } 31 }
31 32
32 bool ResourceMessageParams::Deserialize(const IPC::Message* msg, 33 bool ResourceMessageParams::Deserialize(const IPC::Message* msg,
33 PickleIterator* iter) { 34 PickleIterator* iter) {
34 return IPC::ParamTraits<PP_Resource>::Read(msg, iter, &pp_resource_) && 35 return IPC::ParamTraits<PP_Resource>::Read(msg, iter, &pp_resource_) &&
35 IPC::ParamTraits<int32_t>::Read(msg, iter, &sequence_); 36 IPC::ParamTraits<int32_t>::Read(msg, iter, &sequence_) &&
37 IPC::ParamTraits<std::vector<SerializedHandle> >::Read(
38 msg, iter, &handles_);
39 }
40
41 const SerializedHandle* ResourceMessageParams::GetHandleOfTypeAtIndex(
42 size_t index,
43 SerializedHandle::Type type) const {
44 if (handles_.size() <= index)
45 return NULL;
46 if (handles_[index].type() != type)
47 return NULL;
48 return &handles_[index];
49 }
50
51 bool ResourceMessageParams::GetSharedMemoryHandleAtIndex(
52 size_t index,
53 base::SharedMemoryHandle* handle) const {
54 const SerializedHandle* serialized = GetHandleOfTypeAtIndex(
55 index, SerializedHandle::SHARED_MEMORY);
56 if (!serialized)
57 return false;
58 *handle = serialized->shmem();
59 return true;
60 }
61
62 bool ResourceMessageParams::GetSocketHandleAtIndex(
63 size_t index,
64 IPC::PlatformFileForTransit* handle) const {
65 const SerializedHandle* serialized = GetHandleOfTypeAtIndex(
66 index, SerializedHandle::SOCKET);
67 if (!serialized)
68 return false;
69 *handle = serialized->descriptor();
70 return true;
71 }
72
73 void ResourceMessageParams::AppendHandle(const SerializedHandle& handle) {
74 handles_.push_back(handle);
36 } 75 }
37 76
38 ResourceMessageCallParams::ResourceMessageCallParams() 77 ResourceMessageCallParams::ResourceMessageCallParams()
39 : ResourceMessageParams(), 78 : ResourceMessageParams(),
40 has_callback_(0) { 79 has_callback_(0) {
41 } 80 }
42 81
43 ResourceMessageCallParams::ResourceMessageCallParams(PP_Resource resource, 82 ResourceMessageCallParams::ResourceMessageCallParams(PP_Resource resource,
44 int32_t sequence) 83 int32_t sequence)
45 : ResourceMessageParams(resource, sequence), 84 : ResourceMessageParams(resource, sequence),
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 121
83 bool ResourceMessageReplyParams::Deserialize(const IPC::Message* msg, 122 bool ResourceMessageReplyParams::Deserialize(const IPC::Message* msg,
84 PickleIterator* iter) { 123 PickleIterator* iter) {
85 if (!ResourceMessageParams::Deserialize(msg, iter)) 124 if (!ResourceMessageParams::Deserialize(msg, iter))
86 return false; 125 return false;
87 return IPC::ParamTraits<int32_t>::Read(msg, iter, &result_); 126 return IPC::ParamTraits<int32_t>::Read(msg, iter, &result_);
88 } 127 }
89 128
90 } // namespace proxy 129 } // namespace proxy
91 } // namespace ppapi 130 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/resource_message_params.h ('k') | ppapi/shared_impl/ppapi_permissions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698