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

Side by Side Diff: extensions/browser/api/usb/usb_api.cc

Issue 2899743002: Remove raw base::DictionaryValue::Set in //extensions (Closed)
Patch Set: Rebase Created 3 years, 6 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
OLDNEW
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 "extensions/browser/api/usb/usb_api.h" 5 #include "extensions/browser/api/usb/usb_api.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <numeric> 9 #include <numeric>
10 #include <set> 10 #include <set>
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 scoped_refptr<net::IOBuffer> data, 464 scoped_refptr<net::IOBuffer> data,
465 size_t length) { 465 size_t length) {
466 std::unique_ptr<base::DictionaryValue> transfer_info( 466 std::unique_ptr<base::DictionaryValue> transfer_info(
467 new base::DictionaryValue()); 467 new base::DictionaryValue());
468 transfer_info->SetInteger(kResultCodeKey, static_cast<int>(status)); 468 transfer_info->SetInteger(kResultCodeKey, static_cast<int>(status));
469 469
470 if (data) { 470 if (data) {
471 transfer_info->Set( 471 transfer_info->Set(
472 kDataKey, base::Value::CreateWithCopiedBuffer(data->data(), length)); 472 kDataKey, base::Value::CreateWithCopiedBuffer(data->data(), length));
473 } else { 473 } else {
474 transfer_info->Set(kDataKey, new base::Value(base::Value::Type::BINARY)); 474 transfer_info->Set(
475 kDataKey, base::MakeUnique<base::Value>(base::Value::Type::BINARY));
475 } 476 }
476 477
477 if (status == UsbTransferStatus::COMPLETED) { 478 if (status == UsbTransferStatus::COMPLETED) {
478 Respond(OneArgument(std::move(transfer_info))); 479 Respond(OneArgument(std::move(transfer_info)));
479 } else { 480 } else {
480 std::unique_ptr<base::ListValue> error_args(new base::ListValue()); 481 std::unique_ptr<base::ListValue> error_args(new base::ListValue());
481 error_args->Append(std::move(transfer_info)); 482 error_args->Append(std::move(transfer_info));
482 // Using ErrorWithArguments is discouraged but required to provide the 483 // Using ErrorWithArguments is discouraged but required to provide the
483 // detailed transfer info as the transfer may have partially succeeded. 484 // detailed transfer info as the transfer may have partially succeeded.
484 Respond(ErrorWithArguments(std::move(error_args), 485 Respond(ErrorWithArguments(std::move(error_args),
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after
1235 if (data) { 1236 if (data) {
1236 buffer.insert(buffer.end(), data_ptr, 1237 buffer.insert(buffer.end(), data_ptr,
1237 data_ptr + packet.transferred_length); 1238 data_ptr + packet.transferred_length);
1238 data_ptr += packet.length; 1239 data_ptr += packet.length;
1239 } 1240 }
1240 } 1241 }
1241 1242
1242 std::unique_ptr<base::DictionaryValue> transfer_info( 1243 std::unique_ptr<base::DictionaryValue> transfer_info(
1243 new base::DictionaryValue()); 1244 new base::DictionaryValue());
1244 transfer_info->SetInteger(kResultCodeKey, static_cast<int>(status)); 1245 transfer_info->SetInteger(kResultCodeKey, static_cast<int>(status));
1245 transfer_info->Set(kDataKey, new base::Value(std::move(buffer))); 1246 transfer_info->Set(kDataKey,
1247 base::MakeUnique<base::Value>(std::move(buffer)));
1246 if (status == UsbTransferStatus::COMPLETED) { 1248 if (status == UsbTransferStatus::COMPLETED) {
1247 Respond(OneArgument(std::move(transfer_info))); 1249 Respond(OneArgument(std::move(transfer_info)));
1248 } else { 1250 } else {
1249 std::unique_ptr<base::ListValue> error_args(new base::ListValue()); 1251 std::unique_ptr<base::ListValue> error_args(new base::ListValue());
1250 error_args->Append(std::move(transfer_info)); 1252 error_args->Append(std::move(transfer_info));
1251 // Using ErrorWithArguments is discouraged but required to provide the 1253 // Using ErrorWithArguments is discouraged but required to provide the
1252 // detailed transfer info as the transfer may have partially succeeded. 1254 // detailed transfer info as the transfer may have partially succeeded.
1253 Respond(ErrorWithArguments(std::move(error_args), 1255 Respond(ErrorWithArguments(std::move(error_args),
1254 ConvertTransferStatusToApi(status))); 1256 ConvertTransferStatusToApi(status)));
1255 } 1257 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1289 1291
1290 std::unique_ptr<base::ListValue> error_args(new base::ListValue()); 1292 std::unique_ptr<base::ListValue> error_args(new base::ListValue());
1291 error_args->AppendBoolean(false); 1293 error_args->AppendBoolean(false);
1292 // Using ErrorWithArguments is discouraged but required to maintain 1294 // Using ErrorWithArguments is discouraged but required to maintain
1293 // compatibility with existing applications. 1295 // compatibility with existing applications.
1294 Respond(ErrorWithArguments(std::move(error_args), kErrorResetDevice)); 1296 Respond(ErrorWithArguments(std::move(error_args), kErrorResetDevice));
1295 } 1297 }
1296 } 1298 }
1297 1299
1298 } // namespace extensions 1300 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698