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

Side by Side Diff: chrome/browser/extensions/api/bookmarks/bookmark_api_helpers.cc

Issue 1105413002: Avoid conversion of index to BookmarkNode pointer unnacessarily. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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/extensions/api/bookmarks/bookmark_api_helpers.h" 5 #include "chrome/browser/extensions/api/bookmarks/bookmark_api_helpers.h"
6 6
7 #include <math.h> // For floor() 7 #include <math.h> // For floor()
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 bookmarks::IsDescendantOf(node, client->supervised_node())) { 130 bookmarks::IsDescendantOf(node, client->supervised_node())) {
131 *error = keys::kModifyManagedError; 131 *error = keys::kModifyManagedError;
132 return false; 132 return false;
133 } 133 }
134 if (node->is_folder() && !node->empty() && !recursive) { 134 if (node->is_folder() && !node->empty() && !recursive) {
135 *error = keys::kFolderNotEmptyError; 135 *error = keys::kFolderNotEmptyError;
136 return false; 136 return false;
137 } 137 }
138 138
139 const BookmarkNode* parent = node->parent(); 139 const BookmarkNode* parent = node->parent();
140 model->Remove(parent, parent->GetIndexOf(node)); 140 model->Remove(parent, node);
141 return true; 141 return true;
142 } 142 }
143 143
144 void GetMetaInfo(const BookmarkNode& node, 144 void GetMetaInfo(const BookmarkNode& node,
145 base::DictionaryValue* id_to_meta_info_map) { 145 base::DictionaryValue* id_to_meta_info_map) {
146 if (!node.IsVisible()) 146 if (!node.IsVisible())
147 return; 147 return;
148 148
149 const BookmarkNode::MetaInfoMap* meta_info = node.GetMetaInfoMap(); 149 const BookmarkNode::MetaInfoMap* meta_info = node.GetMetaInfoMap();
150 base::DictionaryValue* value = new base::DictionaryValue(); 150 base::DictionaryValue* value = new base::DictionaryValue();
151 if (meta_info) { 151 if (meta_info) {
152 BookmarkNode::MetaInfoMap::const_iterator itr; 152 BookmarkNode::MetaInfoMap::const_iterator itr;
153 for (itr = meta_info->begin(); itr != meta_info->end(); ++itr) { 153 for (itr = meta_info->begin(); itr != meta_info->end(); ++itr) {
154 value->SetStringWithoutPathExpansion(itr->first, itr->second); 154 value->SetStringWithoutPathExpansion(itr->first, itr->second);
155 } 155 }
156 } 156 }
157 id_to_meta_info_map->Set(base::Int64ToString(node.id()), value); 157 id_to_meta_info_map->Set(base::Int64ToString(node.id()), value);
158 158
159 if (node.is_folder()) { 159 if (node.is_folder()) {
160 for (int i = 0; i < node.child_count(); ++i) { 160 for (int i = 0; i < node.child_count(); ++i) {
161 GetMetaInfo(*(node.GetChild(i)), id_to_meta_info_map); 161 GetMetaInfo(*(node.GetChild(i)), id_to_meta_info_map);
162 } 162 }
163 } 163 }
164 } 164 }
165 165
166 } // namespace bookmark_api_helpers 166 } // namespace bookmark_api_helpers
167 } // namespace extensions 167 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698