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

Side by Side Diff: chrome/nacl/nacl_ipc_adapter.cc

Issue 15274002: Do not translate the file open flags other than read/write. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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 "chrome/nacl/nacl_ipc_adapter.h" 5 #include "chrome/nacl/nacl_ipc_adapter.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 funcs.SendMsg = NaClDescCustomSendMsg; 89 funcs.SendMsg = NaClDescCustomSendMsg;
90 funcs.RecvMsg = NaClDescCustomRecvMsg; 90 funcs.RecvMsg = NaClDescCustomRecvMsg;
91 // NaClDescMakeCustomDesc gives us a reference on the returned NaClDesc. 91 // NaClDescMakeCustomDesc gives us a reference on the returned NaClDesc.
92 return NaClDescMakeCustomDesc(new DescThunker(adapter), &funcs); 92 return NaClDescMakeCustomDesc(new DescThunker(adapter), &funcs);
93 } 93 }
94 94
95 void DeleteChannel(IPC::Channel* channel) { 95 void DeleteChannel(IPC::Channel* channel) {
96 delete channel; 96 delete channel;
97 } 97 }
98 98
99 int TranslatePepperFileOpenFlags(int32_t pp_open_flags) { 99 int TranslatePepperFileOpenFlags(int32_t pp_open_flags) {
bsy 2013/05/17 17:35:03 If the intention is to use this only for NaClDescI
mazda 2013/05/17 22:09:55 Renamed TranslatePepperFileOpenFlags to TranslateP
100 int nacl_open_flag; 100 int nacl_open_flag;
101 switch (pp_open_flags & (PP_FILEOPENFLAG_READ | PP_FILEOPENFLAG_WRITE)) { 101 switch (pp_open_flags & (PP_FILEOPENFLAG_READ | PP_FILEOPENFLAG_WRITE)) {
102 case PP_FILEOPENFLAG_READ: 102 case PP_FILEOPENFLAG_READ:
103 nacl_open_flag = NACL_ABI_O_RDONLY; 103 nacl_open_flag = NACL_ABI_O_RDONLY;
104 break; 104 break;
105 case PP_FILEOPENFLAG_WRITE: 105 case PP_FILEOPENFLAG_WRITE:
106 nacl_open_flag = NACL_ABI_O_WRONLY; 106 nacl_open_flag = NACL_ABI_O_WRONLY;
107 break; 107 break;
108 case PP_FILEOPENFLAG_READ | PP_FILEOPENFLAG_WRITE: 108 case PP_FILEOPENFLAG_READ | PP_FILEOPENFLAG_WRITE:
109 nacl_open_flag = NACL_ABI_O_RDWR; 109 nacl_open_flag = NACL_ABI_O_RDWR;
110 break; 110 break;
111 default: 111 default:
112 // NACL_ABI_O_RDONLY == 0, so make this ambiguous case readonly as a safe 112 // NACL_ABI_O_RDONLY == 0, so make this ambiguous case readonly as a safe
113 // fallback. 113 // fallback.
114 nacl_open_flag = NACL_ABI_O_RDONLY; 114 nacl_open_flag = NACL_ABI_O_RDONLY;
115 break; 115 break;
116 } 116 }
117 117
118 if (pp_open_flags & PP_FILEOPENFLAG_CREATE) 118 if (pp_open_flags & PP_FILEOPENFLAG_CREATE)
119 nacl_open_flag |= NACL_ABI_O_CREAT; 119 nacl_open_flag |= NACL_ABI_O_CREAT;
120 if (pp_open_flags & PP_FILEOPENFLAG_TRUNCATE) 120 if (pp_open_flags & PP_FILEOPENFLAG_TRUNCATE)
121 nacl_open_flag |= NACL_ABI_O_TRUNC; 121 nacl_open_flag |= NACL_ABI_O_TRUNC;
122 #if 0
Mark Seaborn 2013/05/17 14:02:35 Don't disable code with "#if 0" -- why don't you j
mazda 2013/05/17 22:09:55 Deleted the code and added a test.
123 // NaCl does not support NACL_ABI_O_EXCL yet and sending the flag can cause
124 // NaCl module to crash, so we discard the flag here for now.
122 if (pp_open_flags & PP_FILEOPENFLAG_EXCLUSIVE) 125 if (pp_open_flags & PP_FILEOPENFLAG_EXCLUSIVE)
123 nacl_open_flag |= NACL_ABI_O_EXCL; 126 nacl_open_flag |= NACL_ABI_O_EXCL;
bsy 2013/05/17 16:38:52 TranslatePepperFileOpenFlags is used at line 452 b
mazda 2013/05/17 22:09:55 Changed the code not to include NACL_ABI_O_EXCL, N
127 #endif
124 return nacl_open_flag; 128 return nacl_open_flag;
125 } 129 }
126 130
127 class NaClDescWrapper { 131 class NaClDescWrapper {
128 public: 132 public:
129 explicit NaClDescWrapper(NaClDesc* desc): desc_(desc) {} 133 explicit NaClDescWrapper(NaClDesc* desc): desc_(desc) {}
130 ~NaClDescWrapper() { 134 ~NaClDescWrapper() {
131 NaClDescUnref(desc_); 135 NaClDescUnref(desc_);
132 } 136 }
133 137
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 581
578 header.payload_size = static_cast<uint32>(msg.payload_size()); 582 header.payload_size = static_cast<uint32>(msg.payload_size());
579 header.routing = msg.routing_id(); 583 header.routing = msg.routing_id();
580 header.type = msg.type(); 584 header.type = msg.type();
581 header.flags = msg.flags(); 585 header.flags = msg.flags();
582 header.num_fds = static_cast<int>(rewritten_msg->desc_count()); 586 header.num_fds = static_cast<int>(rewritten_msg->desc_count());
583 587
584 rewritten_msg->SetData(header, msg.payload(), msg.payload_size()); 588 rewritten_msg->SetData(header, msg.payload(), msg.payload_size());
585 locked_data_.to_be_received_.push(rewritten_msg); 589 locked_data_.to_be_received_.push(rewritten_msg);
586 } 590 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698