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

Side by Side Diff: ipc/mojo/ipc_channel_mojo_unittest.cc

Issue 2047953002: Explicitly serialise platform file attachments instead of doing them implicitly as a mojo handle at… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 | « ipc/mojo/ipc_channel_mojo.cc ('k') | ipc/mojo/ipc_mojo_handle_attachment.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 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 "ipc/mojo/ipc_channel_mojo.h" 5 #include "ipc/mojo/ipc_channel_mojo.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 WriteFile(message, file); 355 WriteFile(message, file);
356 WritePipe(message, pipe); 356 WritePipe(message, pipe);
357 ASSERT_TRUE(sender->Send(message)); 357 ASSERT_TRUE(sender->Send(message));
358 } 358 }
359 359
360 static void ReadReceivedFile(const IPC::Message& message, 360 static void ReadReceivedFile(const IPC::Message& message,
361 base::PickleIterator* iter) { 361 base::PickleIterator* iter) {
362 base::ScopedFD fd; 362 base::ScopedFD fd;
363 scoped_refptr<base::Pickle::Attachment> attachment; 363 scoped_refptr<base::Pickle::Attachment> attachment;
364 EXPECT_TRUE(message.ReadAttachment(iter, &attachment)); 364 EXPECT_TRUE(message.ReadAttachment(iter, &attachment));
365 EXPECT_EQ(IPC::MessageAttachment::TYPE_PLATFORM_FILE,
366 static_cast<IPC::MessageAttachment*>(attachment.get())
367 ->GetType());
365 base::File file(static_cast<IPC::MessageAttachment*>(attachment.get()) 368 base::File file(static_cast<IPC::MessageAttachment*>(attachment.get())
366 ->TakePlatformFile()); 369 ->TakePlatformFile());
367 std::string content(GetSendingFileContent().size(), ' '); 370 std::string content(GetSendingFileContent().size(), ' ');
368 file.Read(0, &content[0], content.size()); 371 file.Read(0, &content[0], content.size());
369 EXPECT_EQ(content, GetSendingFileContent()); 372 EXPECT_EQ(content, GetSendingFileContent());
370 } 373 }
371 #endif 374 #endif
372 }; 375 };
373 376
374 class ListenerThatExpectsMessagePipe : public IPC::Listener { 377 class ListenerThatExpectsMessagePipe : public IPC::Listener {
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 Connect(&listener); 730 Connect(&listener);
728 731
729 base::MessageLoop::current()->Run(); 732 base::MessageLoop::current()->Run();
730 733
731 Close(); 734 Close();
732 } 735 }
733 736
734 #endif // OS_LINUX 737 #endif // OS_LINUX
735 738
736 } // namespace 739 } // namespace
OLDNEW
« no previous file with comments | « ipc/mojo/ipc_channel_mojo.cc ('k') | ipc/mojo/ipc_mojo_handle_attachment.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698