OLD | NEW |
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 "remoting/host/native_messaging/native_messaging_writer.h" | 5 #include "remoting/host/native_messaging/native_messaging_writer.h" |
6 | 6 |
| 7 #include <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
7 #include <string> | 10 #include <string> |
8 | 11 |
9 #include "base/basictypes.h" | |
10 #include "base/json/json_writer.h" | 12 #include "base/json/json_writer.h" |
11 | 13 |
12 namespace { | 14 namespace { |
13 | 15 |
14 // 4-byte type used for the message header. | 16 // 4-byte type used for the message header. |
15 typedef uint32 MessageLengthType; | 17 typedef uint32_t MessageLengthType; |
16 | 18 |
17 // Defined as an int, for passing to APIs that take an int, to avoid | 19 // Defined as an int, for passing to APIs that take an int, to avoid |
18 // signed/unsigned warnings about implicit cast. | 20 // signed/unsigned warnings about implicit cast. |
19 const int kMessageHeaderSize = sizeof(MessageLengthType); | 21 const int kMessageHeaderSize = sizeof(MessageLengthType); |
20 | 22 |
21 // Limit the size of sent messages, since Chrome will not accept messages | 23 // Limit the size of sent messages, since Chrome will not accept messages |
22 // larger than 1MB, and this helps deal with the problem of integer overflow | 24 // larger than 1MB, and this helps deal with the problem of integer overflow |
23 // when passing sizes to net::FileStream APIs that take |int| parameters. | 25 // when passing sizes to net::FileStream APIs that take |int| parameters. |
24 // This is defined as size_t (unsigned type) so it can be compared with the | 26 // This is defined as size_t (unsigned type) so it can be compared with the |
25 // result of std::string::length() without compiler warnings. | 27 // result of std::string::length() without compiler warnings. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 if (result != message_length_as_int) { | 74 if (result != message_length_as_int) { |
73 LOG(ERROR) << "Failed to send message body, write returned " << result; | 75 LOG(ERROR) << "Failed to send message body, write returned " << result; |
74 fail_ = true; | 76 fail_ = true; |
75 return false; | 77 return false; |
76 } | 78 } |
77 | 79 |
78 return true; | 80 return true; |
79 } | 81 } |
80 | 82 |
81 } // namespace remoting | 83 } // namespace remoting |
OLD | NEW |