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 <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 // when passing sizes to net::FileStream APIs that take |int| parameters. | 23 // 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 | 24 // This is defined as size_t (unsigned type) so it can be compared with the |
25 // result of std::string::length() without compiler warnings. | 25 // result of std::string::length() without compiler warnings. |
26 const size_t kMaximumMessageSize = 1024 * 1024; | 26 const size_t kMaximumMessageSize = 1024 * 1024; |
27 | 27 |
28 } // namespace | 28 } // namespace |
29 | 29 |
30 namespace remoting { | 30 namespace remoting { |
31 | 31 |
32 NativeMessagingWriter::NativeMessagingWriter(base::File file) | 32 NativeMessagingWriter::NativeMessagingWriter(base::File file) |
33 : write_stream_(file.Pass()), | 33 : write_stream_(std::move(file)), fail_(false) {} |
34 fail_(false) { | |
35 } | |
36 | 34 |
37 NativeMessagingWriter::~NativeMessagingWriter() { | 35 NativeMessagingWriter::~NativeMessagingWriter() { |
38 } | 36 } |
39 | 37 |
40 bool NativeMessagingWriter::WriteMessage(const base::Value& message) { | 38 bool NativeMessagingWriter::WriteMessage(const base::Value& message) { |
41 if (fail_) { | 39 if (fail_) { |
42 LOG(ERROR) << "Stream marked as corrupt."; | 40 LOG(ERROR) << "Stream marked as corrupt."; |
43 return false; | 41 return false; |
44 } | 42 } |
45 | 43 |
(...skipping 26 matching lines...) Expand all Loading... |
72 if (result != message_length_as_int) { | 70 if (result != message_length_as_int) { |
73 LOG(ERROR) << "Failed to send message body, write returned " << result; | 71 LOG(ERROR) << "Failed to send message body, write returned " << result; |
74 fail_ = true; | 72 fail_ = true; |
75 return false; | 73 return false; |
76 } | 74 } |
77 | 75 |
78 return true; | 76 return true; |
79 } | 77 } |
80 | 78 |
81 } // namespace remoting | 79 } // namespace remoting |
OLD | NEW |