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

Side by Side Diff: mojo/system/raw_channel_unittest.cc

Issue 265753006: Mojo: Factor MessageInTransit secondary buffer stuff out into a separate class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: oops Created 6 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 | « mojo/system/raw_channel.cc ('k') | mojo/system/transport_data.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 "mojo/system/raw_channel.h" 5 #include "mojo/system/raw_channel.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 22 matching lines...) Expand all
33 namespace system { 33 namespace system {
34 namespace { 34 namespace {
35 35
36 scoped_ptr<MessageInTransit> MakeTestMessage(uint32_t num_bytes) { 36 scoped_ptr<MessageInTransit> MakeTestMessage(uint32_t num_bytes) {
37 std::vector<unsigned char> bytes(num_bytes, 0); 37 std::vector<unsigned char> bytes(num_bytes, 0);
38 for (size_t i = 0; i < num_bytes; i++) 38 for (size_t i = 0; i < num_bytes; i++)
39 bytes[i] = static_cast<unsigned char>(i + num_bytes); 39 bytes[i] = static_cast<unsigned char>(i + num_bytes);
40 return make_scoped_ptr( 40 return make_scoped_ptr(
41 new MessageInTransit(MessageInTransit::kTypeMessagePipeEndpoint, 41 new MessageInTransit(MessageInTransit::kTypeMessagePipeEndpoint,
42 MessageInTransit::kSubtypeMessagePipeEndpointData, 42 MessageInTransit::kSubtypeMessagePipeEndpointData,
43 num_bytes, 0, bytes.empty() ? NULL : &bytes[0])); 43 num_bytes, bytes.empty() ? NULL : &bytes[0]));
44 } 44 }
45 45
46 bool CheckMessageData(const void* bytes, uint32_t num_bytes) { 46 bool CheckMessageData(const void* bytes, uint32_t num_bytes) {
47 const unsigned char* b = static_cast<const unsigned char*>(bytes); 47 const unsigned char* b = static_cast<const unsigned char*>(bytes);
48 for (uint32_t i = 0; i < num_bytes; i++) { 48 for (uint32_t i = 0; i < num_bytes; i++) {
49 if (b[i] != static_cast<unsigned char>(i + num_bytes)) 49 if (b[i] != static_cast<unsigned char>(i + num_bytes))
50 return false; 50 return false;
51 } 51 }
52 return true; 52 return true;
53 } 53 }
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 669
670 EXPECT_FALSE(rc->WriteMessage(MakeTestMessage(1))); 670 EXPECT_FALSE(rc->WriteMessage(MakeTestMessage(1)));
671 671
672 // Wait for the delegate, which will shut the |RawChannel| down. 672 // Wait for the delegate, which will shut the |RawChannel| down.
673 delegate.Wait(); 673 delegate.Wait();
674 } 674 }
675 675
676 } // namespace 676 } // namespace
677 } // namespace system 677 } // namespace system
678 } // namespace mojo 678 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/system/raw_channel.cc ('k') | mojo/system/transport_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698