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

Side by Side Diff: components/nacl/loader/nacl_listener.cc

Issue 1903663004: IPC: Fix attachment brokering race condition. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments from tsepez. Created 4 years, 8 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "components/nacl/loader/nacl_listener.h" 5 #include "components/nacl/loader/nacl_listener.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 }; 217 };
218 218
219 void NaClListener::Listen() { 219 void NaClListener::Listen() {
220 std::string channel_name = 220 std::string channel_name =
221 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 221 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
222 switches::kProcessChannelID); 222 switches::kProcessChannelID);
223 channel_ = IPC::SyncChannel::Create(this, io_thread_.task_runner().get(), 223 channel_ = IPC::SyncChannel::Create(this, io_thread_.task_runner().get(),
224 &shutdown_event_); 224 &shutdown_event_);
225 filter_ = channel_->CreateSyncMessageFilter(); 225 filter_ = channel_->CreateSyncMessageFilter();
226 channel_->AddFilter(new FileTokenMessageFilter()); 226 channel_->AddFilter(new FileTokenMessageFilter());
227 channel_->Init(channel_name, IPC::Channel::MODE_CLIENT, true);
228 IPC::AttachmentBroker* global = IPC::AttachmentBroker::GetGlobal(); 227 IPC::AttachmentBroker* global = IPC::AttachmentBroker::GetGlobal();
229 if (global && !global->IsPrivilegedBroker()) 228 if (global && !global->IsPrivilegedBroker())
230 global->RegisterBrokerCommunicationChannel(channel_.get()); 229 global->RegisterBrokerCommunicationChannel(channel_.get());
230 channel_->Init(channel_name, IPC::Channel::MODE_CLIENT, true);
231 main_loop_ = base::MessageLoop::current(); 231 main_loop_ = base::MessageLoop::current();
232 main_loop_->Run(); 232 main_loop_->Run();
233 } 233 }
234 234
235 bool NaClListener::OnMessageReceived(const IPC::Message& msg) { 235 bool NaClListener::OnMessageReceived(const IPC::Message& msg) {
236 bool handled = true; 236 bool handled = true;
237 IPC_BEGIN_MESSAGE_MAP(NaClListener, msg) 237 IPC_BEGIN_MESSAGE_MAP(NaClListener, msg)
238 IPC_MESSAGE_HANDLER(NaClProcessMsg_AddPrefetchedResource, 238 IPC_MESSAGE_HANDLER(NaClProcessMsg_AddPrefetchedResource,
239 OnAddPrefetchedResource) 239 OnAddPrefetchedResource)
240 IPC_MESSAGE_HANDLER(NaClProcessMsg_Start, OnStart) 240 IPC_MESSAGE_HANDLER(NaClProcessMsg_Start, OnStart)
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 } 446 }
447 447
448 void NaClListener::OnFileTokenResolved( 448 void NaClListener::OnFileTokenResolved(
449 uint64_t token_lo, 449 uint64_t token_lo,
450 uint64_t token_hi, 450 uint64_t token_hi,
451 IPC::PlatformFileForTransit ipc_fd, 451 IPC::PlatformFileForTransit ipc_fd,
452 base::FilePath file_path) { 452 base::FilePath file_path) {
453 resolved_cb_.Run(ipc_fd, file_path); 453 resolved_cb_.Run(ipc_fd, file_path);
454 resolved_cb_.Reset(); 454 resolved_cb_.Reset();
455 } 455 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698