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

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

Issue 2849633002: Get rid of base::SharedMemory::NULLHandle(); (Closed)
Patch Set: Rebase. Created 3 years, 7 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/video_decoder_resource.cc » ('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"
11 #include "ipc/ipc_platform_file.h" 11 #include "ipc/ipc_platform_file.h"
12 12
13 #if defined(OS_NACL) 13 #if defined(OS_NACL)
14 #include <unistd.h> 14 #include <unistd.h>
15 #endif 15 #endif
16 16
17 namespace ppapi { 17 namespace ppapi {
18 namespace proxy { 18 namespace proxy {
19 19
20 SerializedHandle::SerializedHandle() 20 SerializedHandle::SerializedHandle()
21 : type_(INVALID), 21 : type_(INVALID),
22 shm_handle_(base::SharedMemory::NULLHandle()),
23 size_(0), 22 size_(0),
24 descriptor_(IPC::InvalidPlatformFileForTransit()), 23 descriptor_(IPC::InvalidPlatformFileForTransit()),
25 open_flags_(0), 24 open_flags_(0),
26 file_io_(0) { 25 file_io_(0) {
27 } 26 }
28 27
29 SerializedHandle::SerializedHandle(Type type_param) 28 SerializedHandle::SerializedHandle(Type type_param)
30 : type_(type_param), 29 : type_(type_param),
31 shm_handle_(base::SharedMemory::NULLHandle()),
32 size_(0), 30 size_(0),
33 descriptor_(IPC::InvalidPlatformFileForTransit()), 31 descriptor_(IPC::InvalidPlatformFileForTransit()),
34 open_flags_(0), 32 open_flags_(0),
35 file_io_(0) { 33 file_io_(0) {
36 } 34 }
37 35
38 SerializedHandle::SerializedHandle(const base::SharedMemoryHandle& handle, 36 SerializedHandle::SerializedHandle(const base::SharedMemoryHandle& handle,
39 uint32_t size) 37 uint32_t size)
40 : type_(SHARED_MEMORY), 38 : type_(SHARED_MEMORY),
41 shm_handle_(handle), 39 shm_handle_(handle),
42 size_(size), 40 size_(size),
43 descriptor_(IPC::InvalidPlatformFileForTransit()), 41 descriptor_(IPC::InvalidPlatformFileForTransit()),
44 open_flags_(0), 42 open_flags_(0),
45 file_io_(0) {} 43 file_io_(0) {}
46 44
47 SerializedHandle::SerializedHandle( 45 SerializedHandle::SerializedHandle(
48 Type type, 46 Type type,
49 const IPC::PlatformFileForTransit& socket_descriptor) 47 const IPC::PlatformFileForTransit& socket_descriptor)
50 : type_(type), 48 : type_(type),
51 shm_handle_(base::SharedMemory::NULLHandle()),
52 size_(0), 49 size_(0),
53 descriptor_(socket_descriptor), 50 descriptor_(socket_descriptor),
54 open_flags_(0), 51 open_flags_(0),
55 file_io_(0) { 52 file_io_(0) {
56 } 53 }
57 54
58 bool SerializedHandle::IsHandleValid() const { 55 bool SerializedHandle::IsHandleValid() const {
59 switch (type_) { 56 switch (type_) {
60 case SHARED_MEMORY: 57 case SHARED_MEMORY:
61 return base::SharedMemory::IsHandleValid(shm_handle_); 58 return base::SharedMemory::IsHandleValid(shm_handle_);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 break; 132 break;
136 // No default so the compiler will warn us if a new type is added. 133 // No default so the compiler will warn us if a new type is added.
137 } 134 }
138 if (valid_type) 135 if (valid_type)
139 hdr->type = Type(type); 136 hdr->type = Type(type);
140 return valid_type; 137 return valid_type;
141 } 138 }
142 139
143 } // namespace proxy 140 } // namespace proxy
144 } // namespace ppapi 141 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/serialized_handle.h ('k') | ppapi/proxy/video_decoder_resource.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698