| 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 <limits.h> | 5 #include <limits.h> |
| 6 #include <set> | 6 #include <set> |
| 7 | 7 |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/platform_file.h" | 9 #include "base/platform_file.h" |
| 10 #include "tools/ipc_fuzzer/message_lib/message_file.h" | 10 #include "tools/ipc_fuzzer/message_lib/message_file.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 return false; | 72 return false; |
| 73 } | 73 } |
| 74 return true; | 74 return true; |
| 75 } | 75 } |
| 76 | 76 |
| 77 bool Writer::WriteBlob(const void *buffer, size_t size) { | 77 bool Writer::WriteBlob(const void *buffer, size_t size) { |
| 78 if (size > INT_MAX) | 78 if (size > INT_MAX) |
| 79 return false; | 79 return false; |
| 80 const char* char_buffer = static_cast<const char*>(buffer); | 80 const char* char_buffer = static_cast<const char*>(buffer); |
| 81 int ret = base::WritePlatformFileAtCurrentPos(file_, char_buffer, size); | 81 int ret = base::WritePlatformFileAtCurrentPos(file_, char_buffer, size); |
| 82 if (ret != size) { | 82 if (ret != static_cast<int>(size)) { |
| 83 LOG(ERROR) << "Failed to write " << size << " bytes."; | 83 LOG(ERROR) << "Failed to write " << size << " bytes."; |
| 84 return false; | 84 return false; |
| 85 } | 85 } |
| 86 return true; | 86 return true; |
| 87 } | 87 } |
| 88 | 88 |
| 89 bool Writer::CollectMessageTypes() { | 89 bool Writer::CollectMessageTypes() { |
| 90 for (size_t i = 0; i < messages_->size(); ++i) { | 90 for (size_t i = 0; i < messages_->size(); ++i) { |
| 91 uint32_t type = (*messages_)[i]->type(); | 91 uint32_t type = (*messages_)[i]->type(); |
| 92 if (!MessageNames::GetInstance()->TypeExists(type)) { | 92 if (!MessageNames::GetInstance()->TypeExists(type)) { |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 | 167 |
| 168 } // namespace | 168 } // namespace |
| 169 | 169 |
| 170 bool MessageFile::Write(const base::FilePath& path, | 170 bool MessageFile::Write(const base::FilePath& path, |
| 171 const MessageVector& messages) { | 171 const MessageVector& messages) { |
| 172 Writer writer(path); | 172 Writer writer(path); |
| 173 return writer.Write(messages); | 173 return writer.Write(messages); |
| 174 } | 174 } |
| 175 | 175 |
| 176 } // namespace ipc_fuzzer | 176 } // namespace ipc_fuzzer |
| OLD | NEW |