Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef VM_MESSAGE_H_ | 5 #ifndef VM_MESSAGE_H_ |
| 6 #define VM_MESSAGE_H_ | 6 #define VM_MESSAGE_H_ |
| 7 | 7 |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/allocation.h" | 9 #include "vm/allocation.h" |
| 10 #include "vm/globals.h" | 10 #include "vm/globals.h" |
| 11 #include "vm/raw_object.h" | |
| 11 | 12 |
| 12 // Duplicated from dart_api.h to avoid including the whole header. | 13 // Duplicated from dart_api.h to avoid including the whole header. |
| 13 typedef int64_t Dart_Port; | 14 typedef int64_t Dart_Port; |
| 14 | 15 |
| 15 namespace dart { | 16 namespace dart { |
| 16 | 17 |
| 17 class JSONStream; | 18 class JSONStream; |
| 18 | 19 |
| 19 class Message { | 20 class Message { |
| 20 public: | 21 public: |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 50 Dart_Port delivery_failure_port = kIllegalPort) | 51 Dart_Port delivery_failure_port = kIllegalPort) |
| 51 : next_(NULL), | 52 : next_(NULL), |
| 52 dest_port_(dest_port), | 53 dest_port_(dest_port), |
| 53 delivery_failure_port_(delivery_failure_port), | 54 delivery_failure_port_(delivery_failure_port), |
| 54 data_(data), | 55 data_(data), |
| 55 len_(len), | 56 len_(len), |
| 56 priority_(priority) { | 57 priority_(priority) { |
| 57 ASSERT((priority == kNormalPriority) || | 58 ASSERT((priority == kNormalPriority) || |
| 58 (delivery_failure_port == kIllegalPort)); | 59 (delivery_failure_port == kIllegalPort)); |
| 59 } | 60 } |
| 61 Message(Dart_Port dest_port, | |
| 62 RawObject* raw_obj, | |
| 63 Priority priority, | |
| 64 Dart_Port delivery_failure_port = kIllegalPort) | |
| 65 : next_(NULL), | |
| 66 dest_port_(dest_port), | |
| 67 delivery_failure_port_(delivery_failure_port), | |
| 68 data_(reinterpret_cast<uint8_t*>(raw_obj)), | |
| 69 len_(0), | |
| 70 priority_(priority) { | |
| 71 ASSERT((priority == kNormalPriority) || | |
|
Ivan Posva
2015/12/09 22:35:29
Also please assert that raw_obj is not a heap obje
zra
2015/12/10 00:07:29
Done.
| |
| 72 (delivery_failure_port == kIllegalPort)); | |
| 73 } | |
| 60 ~Message() { | 74 ~Message() { |
| 61 ASSERT(delivery_failure_port_ == kIllegalPort); | 75 ASSERT(delivery_failure_port_ == kIllegalPort); |
| 62 free(data_); | 76 if (len_ > 0) { |
| 77 free(data_); | |
| 78 } | |
| 63 } | 79 } |
| 64 | 80 |
| 65 Dart_Port dest_port() const { return dest_port_; } | 81 Dart_Port dest_port() const { return dest_port_; } |
| 66 uint8_t* data() const { return data_; } | 82 uint8_t* data() const { |
| 67 intptr_t len() const { return len_; } | 83 ASSERT(len_ > 0); |
| 84 return data_; | |
| 85 } | |
| 86 intptr_t len() const { | |
| 87 return len_; | |
| 88 } | |
| 89 RawObject* raw_obj() const { | |
| 90 ASSERT(len_ == 0); | |
| 91 return reinterpret_cast<RawObject*>(data_); | |
| 92 } | |
| 68 Priority priority() const { return priority_; } | 93 Priority priority() const { return priority_; } |
| 69 | 94 |
| 95 bool IsData() const { return len_ > 0; } | |
| 96 bool IsRawObject() const { return len_ == 0; } | |
| 97 | |
| 70 bool IsOOB() const { return priority_ == Message::kOOBPriority; } | 98 bool IsOOB() const { return priority_ == Message::kOOBPriority; } |
| 71 | 99 |
| 72 bool RedirectToDeliveryFailurePort(); | 100 bool RedirectToDeliveryFailurePort(); |
| 73 | 101 |
| 74 intptr_t Id() const; | 102 intptr_t Id() const; |
| 75 | 103 |
| 76 static const char* PriorityAsString(Priority priority); | 104 static const char* PriorityAsString(Priority priority); |
| 77 | 105 |
| 78 private: | 106 private: |
| 79 friend class MessageQueue; | 107 friend class MessageQueue; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 private: | 161 private: |
| 134 Message* head_; | 162 Message* head_; |
| 135 Message* tail_; | 163 Message* tail_; |
| 136 | 164 |
| 137 DISALLOW_COPY_AND_ASSIGN(MessageQueue); | 165 DISALLOW_COPY_AND_ASSIGN(MessageQueue); |
| 138 }; | 166 }; |
| 139 | 167 |
| 140 } // namespace dart | 168 } // namespace dart |
| 141 | 169 |
| 142 #endif // VM_MESSAGE_H_ | 170 #endif // VM_MESSAGE_H_ |
| OLD | NEW |