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

Side by Side Diff: chrome/browser/history/starred_url_database.cc

Issue 179028: Revert "Fix a ton of compiler warnings." (Closed)
Patch Set: Created 11 years, 3 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
« no previous file with comments | « chrome/browser/history/history_types.h ('k') | chrome/browser/icon_loader.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/starred_url_database.h" 5 #include "chrome/browser/history/starred_url_database.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/json_writer.h" 9 #include "base/json_writer.h"
10 #include "base/scoped_vector.h" 10 #include "base/scoped_vector.h"
11 #include "base/stl_util-inl.h" 11 #include "base/stl_util-inl.h"
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 } 538 }
539 539
540 bool StarredURLDatabase::MigrateBookmarksToFileImpl(const FilePath& path) { 540 bool StarredURLDatabase::MigrateBookmarksToFileImpl(const FilePath& path) {
541 std::vector<history::StarredEntry> entries; 541 std::vector<history::StarredEntry> entries;
542 if (!GetAllStarredEntries(&entries)) 542 if (!GetAllStarredEntries(&entries))
543 return false; 543 return false;
544 544
545 // Create the bookmark bar and other folder nodes. 545 // Create the bookmark bar and other folder nodes.
546 history::StarredEntry entry; 546 history::StarredEntry entry;
547 entry.type = history::StarredEntry::BOOKMARK_BAR; 547 entry.type = history::StarredEntry::BOOKMARK_BAR;
548 BookmarkNode bookmark_bar_node(0, GURL()); 548 BookmarkNode bookmark_bar_node(NULL, GURL());
549 bookmark_bar_node.Reset(entry); 549 bookmark_bar_node.Reset(entry);
550 entry.type = history::StarredEntry::OTHER; 550 entry.type = history::StarredEntry::OTHER;
551 BookmarkNode other_node(0, GURL()); 551 BookmarkNode other_node(NULL, GURL());
552 other_node.Reset(entry); 552 other_node.Reset(entry);
553 553
554 std::map<history::UIStarID, history::StarID> group_id_to_id_map; 554 std::map<history::UIStarID, history::StarID> group_id_to_id_map;
555 typedef std::map<history::StarID, BookmarkNode*> IDToNodeMap; 555 typedef std::map<history::StarID, BookmarkNode*> IDToNodeMap;
556 IDToNodeMap id_to_node_map; 556 IDToNodeMap id_to_node_map;
557 557
558 history::UIStarID other_folder_group_id = 0; 558 history::UIStarID other_folder_group_id = 0;
559 history::StarID other_folder_id = 0; 559 history::StarID other_folder_id = 0;
560 560
561 // Iterate through the entries building a mapping between group_id and id. 561 // Iterate through the entries building a mapping between group_id and id.
(...skipping 28 matching lines...) Expand all
590 continue; 590 continue;
591 } 591 }
592 592
593 BookmarkNode* node = id_to_node_map[i->id]; 593 BookmarkNode* node = id_to_node_map[i->id];
594 if (!node) { 594 if (!node) {
595 // Creating a node results in creating the parent. As such, it is 595 // Creating a node results in creating the parent. As such, it is
596 // possible for the node representing a group to have been created before 596 // possible for the node representing a group to have been created before
597 // encountering the details. 597 // encountering the details.
598 598
599 // The created nodes are owned by the root node. 599 // The created nodes are owned by the root node.
600 node = new BookmarkNode(0, i->url); 600 node = new BookmarkNode(NULL, i->url);
601 id_to_node_map[i->id] = node; 601 id_to_node_map[i->id] = node;
602 } 602 }
603 node->Reset(*i); 603 node->Reset(*i);
604 604
605 DCHECK(group_id_to_id_map.find(i->parent_group_id) != 605 DCHECK(group_id_to_id_map.find(i->parent_group_id) !=
606 group_id_to_id_map.end()); 606 group_id_to_id_map.end());
607 history::StarID parent_id = group_id_to_id_map[i->parent_group_id]; 607 history::StarID parent_id = group_id_to_id_map[i->parent_group_id];
608 BookmarkNode* parent = id_to_node_map[parent_id]; 608 BookmarkNode* parent = id_to_node_map[parent_id];
609 if (!parent) { 609 if (!parent) {
610 // Haven't encountered the parent yet, create it now. 610 // Haven't encountered the parent yet, create it now.
611 parent = new BookmarkNode(0, GURL()); 611 parent = new BookmarkNode(NULL, GURL());
612 id_to_node_map[parent_id] = parent; 612 id_to_node_map[parent_id] = parent;
613 } 613 }
614 614
615 // Add the node to its parent. |entries| is ordered by parent then 615 // Add the node to its parent. |entries| is ordered by parent then
616 // visual order so that we know we maintain visual order by always adding 616 // visual order so that we know we maintain visual order by always adding
617 // to the end. 617 // to the end.
618 parent->Add(parent->GetChildCount(), node); 618 parent->Add(parent->GetChildCount(), node);
619 } 619 }
620 620
621 // Save to file. 621 // Save to file.
622 BookmarkCodec encoder; 622 BookmarkCodec encoder;
623 scoped_ptr<Value> encoded_bookmarks( 623 scoped_ptr<Value> encoded_bookmarks(
624 encoder.Encode(&bookmark_bar_node, &other_node)); 624 encoder.Encode(&bookmark_bar_node, &other_node));
625 std::string content; 625 std::string content;
626 JSONWriter::Write(encoded_bookmarks.get(), true, &content); 626 JSONWriter::Write(encoded_bookmarks.get(), true, &content);
627 627
628 return (file_util::WriteFile(path, content.c_str(), 628 return (file_util::WriteFile(path, content.c_str(),
629 static_cast<int>(content.length())) != -1); 629 static_cast<int>(content.length())) != -1);
630 } 630 }
631 631
632 } // namespace history 632 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/history_types.h ('k') | chrome/browser/icon_loader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698