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

Side by Side Diff: chrome/browser/ui/webui/cookies_tree_model_util.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 "chrome/browser/ui/webui/cookies_tree_model_util.h" 5 #include "chrome/browser/ui/webui/cookies_tree_model_util.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility>
8 #include <vector> 9 #include <vector>
9 10
10 #include "base/i18n/time_formatting.h" 11 #include "base/i18n/time_formatting.h"
11 #include "base/stl_util.h" 12 #include "base/stl_util.h"
12 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/string_split.h" 14 #include "base/strings/string_split.h"
14 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
15 #include "base/values.h" 16 #include "base/values.h"
16 #include "build/build_config.h" 17 #include "build/build_config.h"
17 #include "chrome/browser/browsing_data/cookies_tree_model.h" 18 #include "chrome/browser/browsing_data/cookies_tree_model.h"
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 } 322 }
322 323
323 void CookiesTreeModelUtil::GetChildNodeList(const CookieTreeNode* parent, 324 void CookiesTreeModelUtil::GetChildNodeList(const CookieTreeNode* parent,
324 int start, 325 int start,
325 int count, 326 int count,
326 base::ListValue* nodes) { 327 base::ListValue* nodes) {
327 for (int i = 0; i < count; ++i) { 328 for (int i = 0; i < count; ++i) {
328 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue); 329 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
329 const CookieTreeNode* child = parent->GetChild(start + i); 330 const CookieTreeNode* child = parent->GetChild(start + i);
330 if (GetCookieTreeNodeDictionary(*child, dict.get())) 331 if (GetCookieTreeNodeDictionary(*child, dict.get()))
331 nodes->Append(dict.release()); 332 nodes->Append(std::move(dict));
332 } 333 }
333 } 334 }
334 335
335 const CookieTreeNode* CookiesTreeModelUtil::GetTreeNodeFromPath( 336 const CookieTreeNode* CookiesTreeModelUtil::GetTreeNodeFromPath(
336 const CookieTreeNode* root, 337 const CookieTreeNode* root,
337 const std::string& path) { 338 const std::string& path) {
338 const CookieTreeNode* child = NULL; 339 const CookieTreeNode* child = NULL;
339 const CookieTreeNode* parent = root; 340 const CookieTreeNode* parent = root;
340 int child_index = -1; 341 int child_index = -1;
341 342
342 // Validate the tree path and get the node pointer. 343 // Validate the tree path and get the node pointer.
343 for (const base::StringPiece& cur_node : base::SplitStringPiece( 344 for (const base::StringPiece& cur_node : base::SplitStringPiece(
344 path, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) { 345 path, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) {
345 int32_t node_id = 0; 346 int32_t node_id = 0;
346 if (!base::StringToInt(cur_node, &node_id)) 347 if (!base::StringToInt(cur_node, &node_id))
347 break; 348 break;
348 349
349 child = id_map_.Lookup(node_id); 350 child = id_map_.Lookup(node_id);
350 child_index = parent->GetIndexOf(child); 351 child_index = parent->GetIndexOf(child);
351 if (child_index == -1) 352 if (child_index == -1)
352 break; 353 break;
353 354
354 parent = child; 355 parent = child;
355 } 356 }
356 357
357 return child_index >= 0 ? child : NULL; 358 return child_index >= 0 ? child : NULL;
358 } 359 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698