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/public/cpp/bindings/lib/message.cc

Issue 613053002: Mojo: NULL -> nullptr in mojo/public/cpp/bindings and also for the bindings generator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 "mojo/public/cpp/bindings/message.h" 5 #include "mojo/public/cpp/bindings/message.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
11 #include "mojo/public/cpp/environment/logging.h" 11 #include "mojo/public/cpp/environment/logging.h"
12 12
13 namespace mojo { 13 namespace mojo {
14 14
15 Message::Message() 15 Message::Message()
16 : data_num_bytes_(0), 16 : data_num_bytes_(0),
17 data_(NULL) { 17 data_(nullptr) {
18 } 18 }
19 19
20 Message::~Message() { 20 Message::~Message() {
21 free(data_); 21 free(data_);
22 22
23 for (std::vector<Handle>::iterator it = handles_.begin(); 23 for (std::vector<Handle>::iterator it = handles_.begin();
24 it != handles_.end(); ++it) { 24 it != handles_.end(); ++it) {
25 if (it->is_valid()) 25 if (it->is_valid())
26 CloseRaw(*it); 26 CloseRaw(*it);
27 } 27 }
(...skipping 17 matching lines...) Expand all
45 std::swap(handles_, other->handles_); 45 std::swap(handles_, other->handles_);
46 } 46 }
47 47
48 MojoResult ReadAndDispatchMessage(MessagePipeHandle handle, 48 MojoResult ReadAndDispatchMessage(MessagePipeHandle handle,
49 MessageReceiver* receiver, 49 MessageReceiver* receiver,
50 bool* receiver_result) { 50 bool* receiver_result) {
51 MojoResult rv; 51 MojoResult rv;
52 52
53 uint32_t num_bytes = 0, num_handles = 0; 53 uint32_t num_bytes = 0, num_handles = 0;
54 rv = ReadMessageRaw(handle, 54 rv = ReadMessageRaw(handle,
55 NULL, 55 nullptr,
56 &num_bytes, 56 &num_bytes,
57 NULL, 57 nullptr,
58 &num_handles, 58 &num_handles,
59 MOJO_READ_MESSAGE_FLAG_NONE); 59 MOJO_READ_MESSAGE_FLAG_NONE);
60 if (rv != MOJO_RESULT_RESOURCE_EXHAUSTED) 60 if (rv != MOJO_RESULT_RESOURCE_EXHAUSTED)
61 return rv; 61 return rv;
62 62
63 Message message; 63 Message message;
64 message.AllocUninitializedData(num_bytes); 64 message.AllocUninitializedData(num_bytes);
65 message.mutable_handles()->resize(num_handles); 65 message.mutable_handles()->resize(num_handles);
66 66
67 rv = ReadMessageRaw(handle, 67 rv = ReadMessageRaw(handle,
68 message.mutable_data(), 68 message.mutable_data(),
69 &num_bytes, 69 &num_bytes,
70 message.mutable_handles()->empty() 70 message.mutable_handles()->empty()
71 ? NULL 71 ? nullptr
72 : reinterpret_cast<MojoHandle*>( 72 : reinterpret_cast<MojoHandle*>(
73 &message.mutable_handles()->front()), 73 &message.mutable_handles()->front()),
74 &num_handles, 74 &num_handles,
75 MOJO_READ_MESSAGE_FLAG_NONE); 75 MOJO_READ_MESSAGE_FLAG_NONE);
76 if (receiver && rv == MOJO_RESULT_OK) 76 if (receiver && rv == MOJO_RESULT_OK)
77 *receiver_result = receiver->Accept(&message); 77 *receiver_result = receiver->Accept(&message);
78 78
79 return rv; 79 return rv;
80 } 80 }
81 81
82 } // namespace mojo 82 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/interface_ptr_internal.h ('k') | mojo/public/cpp/bindings/lib/message_header_validator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698