OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ppapi/tests/test_file_mapping.h" | 5 #include "ppapi/tests/test_file_mapping.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include <limits> | 9 #include <limits> |
10 #include <string> | 10 #include <string> |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 } | 48 } |
49 | 49 |
50 int32_t WriteEntireBuffer(PP_Instance instance, | 50 int32_t WriteEntireBuffer(PP_Instance instance, |
51 pp::FileIO* file_io, | 51 pp::FileIO* file_io, |
52 int32_t offset, | 52 int32_t offset, |
53 const std::string& data, | 53 const std::string& data, |
54 CallbackType callback_type) { | 54 CallbackType callback_type) { |
55 TestCompletionCallback callback(instance, callback_type); | 55 TestCompletionCallback callback(instance, callback_type); |
56 int32_t write_offset = offset; | 56 int32_t write_offset = offset; |
57 const char* buf = data.c_str(); | 57 const char* buf = data.c_str(); |
58 int32_t size = data.size(); | 58 int32_t size = static_cast<int32_t>(data.size()); |
59 | 59 |
60 while (write_offset < offset + size) { | 60 while (write_offset < offset + size) { |
61 callback.WaitForResult(file_io->Write(write_offset, | 61 callback.WaitForResult(file_io->Write(write_offset, |
62 &buf[write_offset - offset], | 62 &buf[write_offset - offset], |
63 size - write_offset + offset, | 63 size - write_offset + offset, |
64 callback.GetCallback())); | 64 callback.GetCallback())); |
65 if (callback.result() < 0) | 65 if (callback.result() < 0) |
66 return callback.result(); | 66 return callback.result(); |
67 if (callback.result() == 0) | 67 if (callback.result() == 0) |
68 return PP_ERROR_FAILED; | 68 return PP_ERROR_FAILED; |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 0, | 530 0, |
531 &new_file_contents2, | 531 &new_file_contents2, |
532 callback_type())); | 532 callback_type())); |
533 ASSERT_EQ(expected_file_contents2, new_file_contents2); | 533 ASSERT_EQ(expected_file_contents2, new_file_contents2); |
534 | 534 |
535 // TODO(dmichael): Test non-zero offset | 535 // TODO(dmichael): Test non-zero offset |
536 | 536 |
537 PASS(); | 537 PASS(); |
538 } | 538 } |
539 | 539 |
OLD | NEW |