OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "webkit/plugins/ppapi/message_channel.h" | 5 #include "webkit/plugins/ppapi/message_channel.h" |
6 | 6 |
7 #include <cstdlib> | 7 #include <cstdlib> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
277 return false; | 277 return false; |
278 | 278 |
279 // Invoke on the passthrough object, if we have one, to enumerate its | 279 // Invoke on the passthrough object, if we have one, to enumerate its |
280 // properties. | 280 // properties. |
281 NPObject* passthrough = ToPassThroughObject(np_obj); | 281 NPObject* passthrough = ToPassThroughObject(np_obj); |
282 if (passthrough) { | 282 if (passthrough) { |
283 bool success = WebBindings::enumerate(NULL, passthrough, value, count); | 283 bool success = WebBindings::enumerate(NULL, passthrough, value, count); |
284 if (success) { | 284 if (success) { |
285 // Add postMessage to the list and return it. | 285 // Add postMessage to the list and return it. |
286 if (std::numeric_limits<size_t>::max() / sizeof(NPIdentifier) <= | 286 if (std::numeric_limits<size_t>::max() / sizeof(NPIdentifier) <= |
287 (*count + 1)) | 287 static_cast<size_t>(*count + 1)) // Else, "always false" x64 warning. |
piman
2013/04/18 23:11:36
paranoid in me: static_cast<size_t>(*count) + 1 ?
Nico
2013/04/18 23:13:52
Done.
| |
288 return false; | 288 return false; |
289 NPIdentifier* new_array = static_cast<NPIdentifier*>( | 289 NPIdentifier* new_array = static_cast<NPIdentifier*>( |
290 std::malloc(sizeof(NPIdentifier) * (*count + 1))); | 290 std::malloc(sizeof(NPIdentifier) * (*count + 1))); |
291 std::memcpy(new_array, *value, sizeof(NPIdentifier)*(*count)); | 291 std::memcpy(new_array, *value, sizeof(NPIdentifier)*(*count)); |
292 new_array[*count] = WebBindings::getStringIdentifier(kPostMessage); | 292 new_array[*count] = WebBindings::getStringIdentifier(kPostMessage); |
293 std::free(*value); | 293 std::free(*value); |
294 *value = new_array; | 294 *value = new_array; |
295 ++(*count); | 295 ++(*count); |
296 return true; | 296 return true; |
297 } | 297 } |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
488 // invokes: | 488 // invokes: |
489 // SetPassthroughObject(passthrough_object()); | 489 // SetPassthroughObject(passthrough_object()); |
490 if (passthrough_object_) | 490 if (passthrough_object_) |
491 WebBindings::releaseObject(passthrough_object_); | 491 WebBindings::releaseObject(passthrough_object_); |
492 | 492 |
493 passthrough_object_ = passthrough; | 493 passthrough_object_ = passthrough; |
494 } | 494 } |
495 | 495 |
496 } // namespace ppapi | 496 } // namespace ppapi |
497 } // namespace webkit | 497 } // namespace webkit |
OLD | NEW |