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

Side by Side Diff: components/drive/service/fake_drive_service.cc

Issue 2051663003: base::ListValue::Append cleanup: pass unique_ptr instead of the released pointer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 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 (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 "components/drive/service/fake_drive_service.h" 5 #include "components/drive/service/fake_drive_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 base::ReplaceSubstringsAfterOffset( 286 base::ReplaceSubstringsAfterOffset(
287 &app_json, 0, "$Removable", is_removable ? "true" : "false"); 287 &app_json, 0, "$Removable", is_removable ? "true" : "false");
288 288
289 JSONStringValueDeserializer json(app_json); 289 JSONStringValueDeserializer json(app_json);
290 std::string error_message; 290 std::string error_message;
291 std::unique_ptr<base::Value> value(json.Deserialize(NULL, &error_message)); 291 std::unique_ptr<base::Value> value(json.Deserialize(NULL, &error_message));
292 CHECK_EQ(base::Value::TYPE_DICTIONARY, value->GetType()); 292 CHECK_EQ(base::Value::TYPE_DICTIONARY, value->GetType());
293 293
294 base::ListValue* item_list; 294 base::ListValue* item_list;
295 CHECK(app_info_value_->GetListWithoutPathExpansion("items", &item_list)); 295 CHECK(app_info_value_->GetListWithoutPathExpansion("items", &item_list));
296 item_list->Append(value.release()); 296 item_list->Append(std::move(value));
297 } 297 }
298 298
299 void FakeDriveService::RemoveAppByProductId(const std::string& product_id) { 299 void FakeDriveService::RemoveAppByProductId(const std::string& product_id) {
300 base::ListValue* item_list; 300 base::ListValue* item_list;
301 CHECK(app_info_value_->GetListWithoutPathExpansion("items", &item_list)); 301 CHECK(app_info_value_->GetListWithoutPathExpansion("items", &item_list));
302 for (size_t i = 0; i < item_list->GetSize(); ++i) { 302 for (size_t i = 0; i < item_list->GetSize(); ++i) {
303 base::DictionaryValue* item; 303 base::DictionaryValue* item;
304 CHECK(item_list->GetDictionary(i, &item)); 304 CHECK(item_list->GetDictionary(i, &item));
305 const char kKeyProductId[] = "productId"; 305 const char kKeyProductId[] = "productId";
306 std::string item_product_id; 306 std::string item_product_id;
(...skipping 1493 matching lines...) Expand 10 before | Expand all | Expand 10 after
1800 1800
1801 NOTREACHED(); 1801 NOTREACHED();
1802 return std::unique_ptr<BatchRequestConfiguratorInterface>(); 1802 return std::unique_ptr<BatchRequestConfiguratorInterface>();
1803 } 1803 }
1804 1804
1805 void FakeDriveService::NotifyObservers() { 1805 void FakeDriveService::NotifyObservers() {
1806 FOR_EACH_OBSERVER(ChangeObserver, change_observers_, OnNewChangeAvailable()); 1806 FOR_EACH_OBSERVER(ChangeObserver, change_observers_, OnNewChangeAvailable());
1807 } 1807 }
1808 1808
1809 } // namespace drive 1809 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698