OLD | NEW |
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 "ipc/ipc_channel.h" | 5 #include "ipc/ipc_channel.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/atomic_sequence_num.h" | 9 #include "base/atomic_sequence_num.h" |
10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 int process_id = -1; | 34 int process_id = -1; |
35 #else | 35 #else |
36 int process_id = base::GetCurrentProcId(); | 36 int process_id = base::GetCurrentProcId(); |
37 #endif | 37 #endif |
38 return base::StringPrintf("%d.%u.%d", | 38 return base::StringPrintf("%d.%u.%d", |
39 process_id, | 39 process_id, |
40 g_last_id.GetNext(), | 40 g_last_id.GetNext(), |
41 base::RandInt(0, std::numeric_limits<int32>::max())); | 41 base::RandInt(0, std::numeric_limits<int32>::max())); |
42 } | 42 } |
43 | 43 |
| 44 Channel::OutputElement::OutputElement(Message* message) |
| 45 : message_(message), buffer_(nullptr), length_(0) {} |
| 46 |
| 47 Channel::OutputElement::OutputElement(void* buffer, size_t length) |
| 48 : message_(nullptr), buffer_(buffer), length_(length) {} |
| 49 |
| 50 Channel::OutputElement::~OutputElement() { |
| 51 free(buffer_); |
| 52 } |
| 53 |
| 54 size_t Channel::OutputElement::size() const { |
| 55 if (message_) |
| 56 return message_->size(); |
| 57 return length_; |
| 58 } |
| 59 |
| 60 const void* Channel::OutputElement::data() const { |
| 61 if (message_) |
| 62 return message_->data(); |
| 63 return buffer_; |
| 64 } |
| 65 |
44 } // namespace IPC | 66 } // namespace IPC |
OLD | NEW |