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

Side by Side Diff: sandbox/linux/syscall_broker/broker_client.cc

Issue 1154283003: Change most uses of Pickle to base::Pickle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 | « remoting/host/chromoting_param_traits.cc ('k') | sandbox/linux/syscall_broker/broker_host.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "sandbox/linux/syscall_broker/broker_client.h" 5 #include "sandbox/linux/syscall_broker/broker_client.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <sys/stat.h> 9 #include <sys/stat.h>
10 #include <sys/socket.h> 10 #include <sys/socket.h>
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 pathname, flags, NULL /* file_to_open */, 58 pathname, flags, NULL /* file_to_open */,
59 NULL /* unlink_after_open */)) { 59 NULL /* unlink_after_open */)) {
60 return -broker_policy_.denied_errno(); 60 return -broker_policy_.denied_errno();
61 } 61 }
62 if (syscall_type == COMMAND_ACCESS && 62 if (syscall_type == COMMAND_ACCESS &&
63 !broker_policy_.GetFileNameIfAllowedToAccess(pathname, flags, NULL)) { 63 !broker_policy_.GetFileNameIfAllowedToAccess(pathname, flags, NULL)) {
64 return -broker_policy_.denied_errno(); 64 return -broker_policy_.denied_errno();
65 } 65 }
66 } 66 }
67 67
68 Pickle write_pickle; 68 base::Pickle write_pickle;
69 write_pickle.WriteInt(syscall_type); 69 write_pickle.WriteInt(syscall_type);
70 write_pickle.WriteString(pathname); 70 write_pickle.WriteString(pathname);
71 write_pickle.WriteInt(flags); 71 write_pickle.WriteInt(flags);
72 RAW_CHECK(write_pickle.size() <= kMaxMessageLength); 72 RAW_CHECK(write_pickle.size() <= kMaxMessageLength);
73 73
74 int returned_fd = -1; 74 int returned_fd = -1;
75 uint8_t reply_buf[kMaxMessageLength]; 75 uint8_t reply_buf[kMaxMessageLength];
76 76
77 // Send a request (in write_pickle) as well that will include a new 77 // Send a request (in write_pickle) as well that will include a new
78 // temporary socketpair (created internally by SendRecvMsg()). 78 // temporary socketpair (created internally by SendRecvMsg()).
79 // Then read the reply on this new socketpair in reply_buf and put an 79 // Then read the reply on this new socketpair in reply_buf and put an
80 // eventual attached file descriptor in |returned_fd|. 80 // eventual attached file descriptor in |returned_fd|.
81 ssize_t msg_len = UnixDomainSocket::SendRecvMsgWithFlags( 81 ssize_t msg_len = UnixDomainSocket::SendRecvMsgWithFlags(
82 ipc_channel_.get(), reply_buf, sizeof(reply_buf), recvmsg_flags, 82 ipc_channel_.get(), reply_buf, sizeof(reply_buf), recvmsg_flags,
83 &returned_fd, write_pickle); 83 &returned_fd, write_pickle);
84 if (msg_len <= 0) { 84 if (msg_len <= 0) {
85 if (!quiet_failures_for_tests_) 85 if (!quiet_failures_for_tests_)
86 RAW_LOG(ERROR, "Could not make request to broker process"); 86 RAW_LOG(ERROR, "Could not make request to broker process");
87 return -ENOMEM; 87 return -ENOMEM;
88 } 88 }
89 89
90 Pickle read_pickle(reinterpret_cast<char*>(reply_buf), msg_len); 90 base::Pickle read_pickle(reinterpret_cast<char*>(reply_buf), msg_len);
91 PickleIterator iter(read_pickle); 91 base::PickleIterator iter(read_pickle);
92 int return_value = -1; 92 int return_value = -1;
93 // Now deserialize the return value and eventually return the file 93 // Now deserialize the return value and eventually return the file
94 // descriptor. 94 // descriptor.
95 if (iter.ReadInt(&return_value)) { 95 if (iter.ReadInt(&return_value)) {
96 switch (syscall_type) { 96 switch (syscall_type) {
97 case COMMAND_ACCESS: 97 case COMMAND_ACCESS:
98 // We should never have a fd to return. 98 // We should never have a fd to return.
99 RAW_CHECK(returned_fd == -1); 99 RAW_CHECK(returned_fd == -1);
100 return return_value; 100 return return_value;
101 case COMMAND_OPEN: 101 case COMMAND_OPEN:
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 return PathAndFlagsSyscall(COMMAND_ACCESS, pathname, mode); 135 return PathAndFlagsSyscall(COMMAND_ACCESS, pathname, mode);
136 } 136 }
137 137
138 int BrokerClient::Open(const char* pathname, int flags) const { 138 int BrokerClient::Open(const char* pathname, int flags) const {
139 return PathAndFlagsSyscall(COMMAND_OPEN, pathname, flags); 139 return PathAndFlagsSyscall(COMMAND_OPEN, pathname, flags);
140 } 140 }
141 141
142 } // namespace syscall_broker 142 } // namespace syscall_broker
143 143
144 } // namespace sandbox 144 } // namespace sandbox
OLDNEW
« no previous file with comments | « remoting/host/chromoting_param_traits.cc ('k') | sandbox/linux/syscall_broker/broker_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698