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

Side by Side Diff: chrome/browser/history/android/bookmark_model_sql_handler.cc

Issue 1105413002: Avoid conversion of index to BookmarkNode pointer unnacessarily. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes as per review comments. 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/history/android/bookmark_model_sql_handler.h" 5 #include "chrome/browser/history/android/bookmark_model_sql_handler.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 8 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
9 #include "chrome/browser/profiles/profile_manager.h" 9 #include "chrome/browser/profiles/profile_manager.h"
10 #include "components/bookmarks/browser/bookmark_model.h" 10 #include "components/bookmarks/browser/bookmark_model.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 } 54 }
55 55
56 void BookmarkModelSQLHandler::Task::RemoveBookmark(const GURL& url) { 56 void BookmarkModelSQLHandler::Task::RemoveBookmark(const GURL& url) {
57 BookmarkModel* bookmark_model = GetBookmarkModel(); 57 BookmarkModel* bookmark_model = GetBookmarkModel();
58 if (!bookmark_model) 58 if (!bookmark_model)
59 return; 59 return;
60 std::vector<const BookmarkNode*> nodes; 60 std::vector<const BookmarkNode*> nodes;
61 bookmark_model->GetNodesByURL(url, &nodes); 61 bookmark_model->GetNodesByURL(url, &nodes);
62 for (std::vector<const BookmarkNode*>::iterator i = nodes.begin(); 62 for (std::vector<const BookmarkNode*>::iterator i = nodes.begin();
63 i != nodes.end(); ++i) { 63 i != nodes.end(); ++i) {
64 const BookmarkNode* parent_node = (*i)->parent(); 64 bookmark_model->Remove(*i);
65 bookmark_model->Remove(parent_node, parent_node->GetIndexOf(*i));
66 } 65 }
67 } 66 }
68 67
69 void BookmarkModelSQLHandler::Task::UpdateBookmarkTitle( 68 void BookmarkModelSQLHandler::Task::UpdateBookmarkTitle(
70 const GURL& url, 69 const GURL& url,
71 const base::string16& title) { 70 const base::string16& title) {
72 BookmarkModel* bookmark_model = GetBookmarkModel(); 71 BookmarkModel* bookmark_model = GetBookmarkModel();
73 if (!bookmark_model) 72 if (!bookmark_model)
74 return; 73 return;
75 std::vector<const BookmarkNode*> nodes; 74 std::vector<const BookmarkNode*> nodes;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( 166 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind(
168 &BookmarkModelSQLHandler::Task::AddBookmarkToMobileFolder, 167 &BookmarkModelSQLHandler::Task::AddBookmarkToMobileFolder,
169 scoped_refptr<BookmarkModelSQLHandler::Task>( 168 scoped_refptr<BookmarkModelSQLHandler::Task>(
170 new BookmarkModelSQLHandler::Task()), 169 new BookmarkModelSQLHandler::Task()),
171 row->url(), row->title())); 170 row->url(), row->title()));
172 } 171 }
173 return true; 172 return true;
174 } 173 }
175 174
176 } // namespace history 175 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/bookmarks/bookmark_api_helpers.cc ('k') | chrome/browser/sync/glue/bookmark_change_processor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698