| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "app/sql/connection.h" | 7 #include "app/sql/connection.h" |
| 8 #include "app/sql/statement.h" | 8 #include "app/sql/statement.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 group_id_to_node_map.end()) { | 373 group_id_to_node_map.end()) { |
| 374 // Entry has no parent, or the parent wasn't found. | 374 // Entry has no parent, or the parent wasn't found. |
| 375 roots->insert(group_id_to_node_map[star_entries[i].group_id]); | 375 roots->insert(group_id_to_node_map[star_entries[i].group_id]); |
| 376 } else { | 376 } else { |
| 377 // Parent the group node. | 377 // Parent the group node. |
| 378 StarredNode* parent = | 378 StarredNode* parent = |
| 379 group_id_to_node_map[star_entries[i].parent_group_id]; | 379 group_id_to_node_map[star_entries[i].parent_group_id]; |
| 380 StarredNode* node = group_id_to_node_map[star_entries[i].group_id]; | 380 StarredNode* node = group_id_to_node_map[star_entries[i].group_id]; |
| 381 if (!node->HasAncestor(parent) && !parent->HasAncestor(node)) { | 381 if (!node->HasAncestor(parent) && !parent->HasAncestor(node)) { |
| 382 parent->Add(parent->GetChildCount(), node); | 382 parent->Add(parent->GetChildCount(), node); |
| 383 } else{ | 383 } else { |
| 384 // The node has a cycle. Add it to the list of roots so the cycle is | 384 // The node has a cycle. Add it to the list of roots so the cycle is |
| 385 // broken. | 385 // broken. |
| 386 roots->insert(node); | 386 roots->insert(node); |
| 387 } | 387 } |
| 388 } | 388 } |
| 389 } | 389 } |
| 390 } | 390 } |
| 391 return true; | 391 return true; |
| 392 } | 392 } |
| 393 | 393 |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 scoped_ptr<Value> encoded_bookmarks( | 620 scoped_ptr<Value> encoded_bookmarks( |
| 621 encoder.Encode(&bookmark_bar_node, &other_node)); | 621 encoder.Encode(&bookmark_bar_node, &other_node)); |
| 622 std::string content; | 622 std::string content; |
| 623 JSONWriter::Write(encoded_bookmarks.get(), true, &content); | 623 JSONWriter::Write(encoded_bookmarks.get(), true, &content); |
| 624 | 624 |
| 625 return (file_util::WriteFile(path, content.c_str(), | 625 return (file_util::WriteFile(path, content.c_str(), |
| 626 static_cast<int>(content.length())) != -1); | 626 static_cast<int>(content.length())) != -1); |
| 627 } | 627 } |
| 628 | 628 |
| 629 } // namespace history | 629 } // namespace history |
| OLD | NEW |