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

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

Issue 1548813002: Switch to standard integer types in ppapi/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixes Created 4 years, 12 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
« no previous file with comments | « ppapi/proxy/serialized_handle.h ('k') | ppapi/proxy/serialized_structs.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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/serialized_handle.h" 5 #include "ppapi/proxy/serialized_handle.h"
6 6
7 #include "base/files/file.h" 7 #include "base/files/file.h"
8 #include "base/memory/shared_memory.h" 8 #include "base/memory/shared_memory.h"
9 #include "base/pickle.h" 9 #include "base/pickle.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 18 matching lines...) Expand all
29 SerializedHandle::SerializedHandle(Type type_param) 29 SerializedHandle::SerializedHandle(Type type_param)
30 : type_(type_param), 30 : type_(type_param),
31 shm_handle_(base::SharedMemory::NULLHandle()), 31 shm_handle_(base::SharedMemory::NULLHandle()),
32 size_(0), 32 size_(0),
33 descriptor_(IPC::InvalidPlatformFileForTransit()), 33 descriptor_(IPC::InvalidPlatformFileForTransit()),
34 open_flags_(0), 34 open_flags_(0),
35 file_io_(0) { 35 file_io_(0) {
36 } 36 }
37 37
38 SerializedHandle::SerializedHandle(const base::SharedMemoryHandle& handle, 38 SerializedHandle::SerializedHandle(const base::SharedMemoryHandle& handle,
39 uint32 size) 39 uint32_t size)
40 : type_(SHARED_MEMORY), 40 : type_(SHARED_MEMORY),
41 shm_handle_(handle), 41 shm_handle_(handle),
42 size_(size), 42 size_(size),
43 descriptor_(IPC::InvalidPlatformFileForTransit()), 43 descriptor_(IPC::InvalidPlatformFileForTransit()),
44 open_flags_(0), 44 open_flags_(0),
45 file_io_(0) { 45 file_io_(0) {}
46 }
47 46
48 SerializedHandle::SerializedHandle( 47 SerializedHandle::SerializedHandle(
49 Type type, 48 Type type,
50 const IPC::PlatformFileForTransit& socket_descriptor) 49 const IPC::PlatformFileForTransit& socket_descriptor)
51 : type_(type), 50 : type_(type),
52 shm_handle_(base::SharedMemory::NULLHandle()), 51 shm_handle_(base::SharedMemory::NULLHandle()),
53 size_(0), 52 size_(0),
54 descriptor_(socket_descriptor), 53 descriptor_(socket_descriptor),
55 open_flags_(0), 54 open_flags_(0),
56 file_io_(0) { 55 file_io_(0) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 105
107 // static 106 // static
108 bool SerializedHandle::ReadHeader(base::PickleIterator* iter, Header* hdr) { 107 bool SerializedHandle::ReadHeader(base::PickleIterator* iter, Header* hdr) {
109 *hdr = Header(INVALID, 0, 0, 0); 108 *hdr = Header(INVALID, 0, 0, 0);
110 int type = 0; 109 int type = 0;
111 if (!iter->ReadInt(&type)) 110 if (!iter->ReadInt(&type))
112 return false; 111 return false;
113 bool valid_type = false; 112 bool valid_type = false;
114 switch (type) { 113 switch (type) {
115 case SHARED_MEMORY: { 114 case SHARED_MEMORY: {
116 uint32 size = 0; 115 uint32_t size = 0;
117 if (!iter->ReadUInt32(&size)) 116 if (!iter->ReadUInt32(&size))
118 return false; 117 return false;
119 hdr->size = size; 118 hdr->size = size;
120 valid_type = true; 119 valid_type = true;
121 break; 120 break;
122 } 121 }
123 case FILE: { 122 case FILE: {
124 int open_flags = 0; 123 int open_flags = 0;
125 PP_Resource file_io = 0; 124 PP_Resource file_io = 0;
126 if (!iter->ReadInt(&open_flags) || !iter->ReadInt(&file_io)) 125 if (!iter->ReadInt(&open_flags) || !iter->ReadInt(&file_io))
127 return false; 126 return false;
128 hdr->open_flags = open_flags; 127 hdr->open_flags = open_flags;
129 hdr->file_io = file_io; 128 hdr->file_io = file_io;
130 valid_type = true; 129 valid_type = true;
131 } 130 }
132 case SOCKET: 131 case SOCKET:
133 case INVALID: 132 case INVALID:
134 valid_type = true; 133 valid_type = true;
135 break; 134 break;
136 // No default so the compiler will warn us if a new type is added. 135 // No default so the compiler will warn us if a new type is added.
137 } 136 }
138 if (valid_type) 137 if (valid_type)
139 hdr->type = Type(type); 138 hdr->type = Type(type);
140 return valid_type; 139 return valid_type;
141 } 140 }
142 141
143 } // namespace proxy 142 } // namespace proxy
144 } // namespace ppapi 143 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/serialized_handle.h ('k') | ppapi/proxy/serialized_structs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698