| 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 "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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |