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

Side by Side Diff: runtime/vm/message.h

Issue 10829444: Avoid trusting the length encoded in the Snapshot if there is an (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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
OLDNEW
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 "vm/thread.h" 8 #include "vm/thread.h"
9 9
10 // Duplicated from dart_api.h to avoid including the whole header. 10 // Duplicated from dart_api.h to avoid including the whole header.
(...skipping 14 matching lines...) Expand all
25 25
26 // A port number which is never used. 26 // A port number which is never used.
27 static const Dart_Port kIllegalPort = 0; 27 static const Dart_Port kIllegalPort = 0;
28 28
29 // A new message to be sent between two isolates. The data handed to this 29 // A new message to be sent between two isolates. The data handed to this
30 // message will be disposed by calling free() once the message object is 30 // message will be disposed by calling free() once the message object is
31 // being destructed (after delivery or when the receiving port is closed). 31 // being destructed (after delivery or when the receiving port is closed).
32 // 32 //
33 // If reply_port is kIllegalPort, then there is no reply port. 33 // If reply_port is kIllegalPort, then there is no reply port.
34 Message(Dart_Port dest_port, Dart_Port reply_port, 34 Message(Dart_Port dest_port, Dart_Port reply_port,
35 uint8_t* data, Priority priority) 35 uint8_t* data, intptr_t len, Priority priority)
36 : next_(NULL), 36 : next_(NULL),
37 dest_port_(dest_port), 37 dest_port_(dest_port),
38 reply_port_(reply_port), 38 reply_port_(reply_port),
39 data_(data), 39 data_(data),
40 len_(len),
40 priority_(priority) {} 41 priority_(priority) {}
41 ~Message() { 42 ~Message() {
42 free(data_); 43 free(data_);
43 } 44 }
44 45
45 Dart_Port dest_port() const { return dest_port_; } 46 Dart_Port dest_port() const { return dest_port_; }
46 Dart_Port reply_port() const { return reply_port_; } 47 Dart_Port reply_port() const { return reply_port_; }
47 uint8_t* data() const { return data_; } 48 uint8_t* data() const { return data_; }
49 intptr_t len() const { return len_; }
48 Priority priority() const { return priority_; } 50 Priority priority() const { return priority_; }
49 51
52 // Are the sender and receiver of this message in the same vm? For
53 // now, this is always true.
54 bool IsLocal() const { return true; }
55
50 bool IsOOB() const { return priority_ == Message::kOOBPriority; } 56 bool IsOOB() const { return priority_ == Message::kOOBPriority; }
51 57
52 private: 58 private:
53 friend class MessageQueue; 59 friend class MessageQueue;
54 60
55 Message* next_; 61 Message* next_;
56 Dart_Port dest_port_; 62 Dart_Port dest_port_;
57 Dart_Port reply_port_; 63 Dart_Port reply_port_;
58 uint8_t* data_; 64 uint8_t* data_;
65 intptr_t len_;
59 Priority priority_; 66 Priority priority_;
60 67
61 DISALLOW_COPY_AND_ASSIGN(Message); 68 DISALLOW_COPY_AND_ASSIGN(Message);
62 }; 69 };
63 70
64 // There is a message queue per isolate. 71 // There is a message queue per isolate.
65 class MessageQueue { 72 class MessageQueue {
66 public: 73 public:
67 MessageQueue(); 74 MessageQueue();
68 ~MessageQueue(); 75 ~MessageQueue();
(...skipping 12 matching lines...) Expand all
81 88
82 Message* head_; 89 Message* head_;
83 Message* tail_; 90 Message* tail_;
84 91
85 DISALLOW_COPY_AND_ASSIGN(MessageQueue); 92 DISALLOW_COPY_AND_ASSIGN(MessageQueue);
86 }; 93 };
87 94
88 } // namespace dart 95 } // namespace dart
89 96
90 #endif // VM_MESSAGE_H_ 97 #endif // VM_MESSAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698