Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: chrome/browser/extensions/api/bluetooth/bluetooth_api.cc

Issue 11745016: BinaryValue support for NULL buffer. (Closed) Base URL: https://git.chromium.org/chromium/src.git@master
Patch Set: BinaryValue support for NULL buffer. Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/values_unittest.cc ('k') | chrome/browser/extensions/api/socket/socket_api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chrome/browser/extensions/api/bluetooth/bluetooth_api.h" 5 #include "chrome/browser/extensions/api/bluetooth/bluetooth_api.h"
6 6
7 #if defined(OS_CHROMEOS) 7 #if defined(OS_CHROMEOS)
8 #include <errno.h> 8 #include <errno.h>
9 #endif 9 #endif
10 10
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 buffer_size - total_bytes_read); 386 buffer_size - total_bytes_read);
387 errsv = errno; 387 errsv = errno;
388 if (bytes_read <= 0) 388 if (bytes_read <= 0)
389 break; 389 break;
390 390
391 total_bytes_read += bytes_read; 391 total_bytes_read += bytes_read;
392 } 392 }
393 393
394 if (total_bytes_read > 0) { 394 if (total_bytes_read > 0) {
395 success_ = true; 395 success_ = true;
396 SetResult(base::BinaryValue::Create(all_bytes, total_bytes_read)); 396 SetResult(base::BinaryValue::CreateWithCopiedBuffer(all_bytes,
397 total_bytes_read));
398 free(all_bytes);
397 } else { 399 } else {
398 success_ = (errsv == EAGAIN || errsv == EWOULDBLOCK); 400 success_ = (errsv == EAGAIN || errsv == EWOULDBLOCK);
399 free(all_bytes); 401 free(all_bytes);
400 } 402 }
401 403
402 if (!success_) 404 if (!success_)
403 SetError(safe_strerror(errsv)); 405 SetError(safe_strerror(errsv));
404 #endif 406 #endif
405 } 407 }
406 408
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 if (GetEventRouter(profile())->IsResponsibleForDiscovery()) { 621 if (GetEventRouter(profile())->IsResponsibleForDiscovery()) {
620 GetMutableAdapter(profile())->SetDiscovering(false, 622 GetMutableAdapter(profile())->SetDiscovering(false,
621 base::Bind(&BluetoothStopDiscoveryFunction::OnSuccessCallback, this), 623 base::Bind(&BluetoothStopDiscoveryFunction::OnSuccessCallback, this),
622 base::Bind(&BluetoothStopDiscoveryFunction::OnErrorCallback, this)); 624 base::Bind(&BluetoothStopDiscoveryFunction::OnErrorCallback, this));
623 } 625 }
624 return true; 626 return true;
625 } 627 }
626 628
627 } // namespace api 629 } // namespace api
628 } // namespace extensions 630 } // namespace extensions
OLDNEW
« no previous file with comments | « base/values_unittest.cc ('k') | chrome/browser/extensions/api/socket/socket_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698