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

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

Issue 7316013: history: Move kBookmarkBarID constant out of HistoryService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/statement.h" 7 #include "app/sql/statement.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 24 matching lines...) Expand all
35 // visual_order Visual order within parent. 35 // visual_order Visual order within parent.
36 // parent_id Folder ID of the parent this entry is contained in, if 0 36 // parent_id Folder ID of the parent this entry is contained in, if 0
37 // entry is not in a folder. 37 // entry is not in a folder.
38 // date_modified Time the folder was last modified. See comments in 38 // date_modified Time the folder was last modified. See comments in
39 // StarredEntry::date_folder_modified 39 // StarredEntry::date_folder_modified
40 // NOTE: group_id and parent_id come from the UI, id is assigned by the 40 // NOTE: group_id and parent_id come from the UI, id is assigned by the
41 // db. 41 // db.
42 42
43 namespace history { 43 namespace history {
44 44
45 const int64 kBookmarkBarID = 1;
46
45 namespace { 47 namespace {
46 48
47 // Fields used by FillInStarredEntry. 49 // Fields used by FillInStarredEntry.
48 #define STAR_FIELDS \ 50 #define STAR_FIELDS \
49 " starred.id, starred.type, starred.title, starred.date_added, " \ 51 " starred.id, starred.type, starred.title, starred.date_added, " \
50 "starred.visual_order, starred.parent_id, urls.url, urls.id, " \ 52 "starred.visual_order, starred.parent_id, urls.url, urls.id, " \
51 "starred.group_id, starred.date_modified " 53 "starred.group_id, starred.date_modified "
52 const char kHistoryStarFields[] = STAR_FIELDS; 54 const char kHistoryStarFields[] = STAR_FIELDS;
53 55
54 void FillInStarredEntry(const sql::Statement& s, StarredEntry* entry) { 56 void FillInStarredEntry(const sql::Statement& s, StarredEntry* entry) {
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 if (i->type != history::StarredEntry::URL) { 601 if (i->type != history::StarredEntry::URL) {
600 folder_id_to_id_map[i->folder_id] = i->id; 602 folder_id_to_id_map[i->folder_id] = i->id;
601 if (i->type == history::StarredEntry::OTHER) { 603 if (i->type == history::StarredEntry::OTHER) {
602 other_folder_id = i->id; 604 other_folder_id = i->id;
603 other_folder_folder_id = i->folder_id; 605 other_folder_folder_id = i->folder_id;
604 } 606 }
605 } 607 }
606 } 608 }
607 609
608 // Register the bookmark bar and other folder nodes in the maps. 610 // Register the bookmark bar and other folder nodes in the maps.
609 id_to_node_map[HistoryService::kBookmarkBarID] = &bookmark_bar_node; 611 id_to_node_map[kBookmarkBarID] = &bookmark_bar_node;
610 folder_id_to_id_map[HistoryService::kBookmarkBarID] = 612 folder_id_to_id_map[kBookmarkBarID] = kBookmarkBarID;
611 HistoryService::kBookmarkBarID;
612 if (other_folder_folder_id) { 613 if (other_folder_folder_id) {
613 id_to_node_map[other_folder_id] = &other_node; 614 id_to_node_map[other_folder_id] = &other_node;
614 folder_id_to_id_map[other_folder_folder_id] = other_folder_id; 615 folder_id_to_id_map[other_folder_folder_id] = other_folder_id;
615 } 616 }
616 617
617 // Iterate through the entries again creating the nodes. 618 // Iterate through the entries again creating the nodes.
618 for (std::vector<history::StarredEntry>::iterator i = entries.begin(); 619 for (std::vector<history::StarredEntry>::iterator i = entries.begin();
619 i != entries.end(); ++i) { 620 i != entries.end(); ++i) {
620 if (!i->parent_folder_id) { 621 if (!i->parent_folder_id) {
621 DCHECK(i->type == history::StarredEntry::BOOKMARK_BAR || 622 DCHECK(i->type == history::StarredEntry::BOOKMARK_BAR ||
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 scoped_ptr<Value> encoded_bookmarks( 660 scoped_ptr<Value> encoded_bookmarks(
660 encoder.Encode(&bookmark_bar_node, &other_node, &synced_node)); 661 encoder.Encode(&bookmark_bar_node, &other_node, &synced_node));
661 std::string content; 662 std::string content;
662 base::JSONWriter::Write(encoded_bookmarks.get(), true, &content); 663 base::JSONWriter::Write(encoded_bookmarks.get(), true, &content);
663 664
664 return (file_util::WriteFile(path, content.c_str(), 665 return (file_util::WriteFile(path, content.c_str(),
665 static_cast<int>(content.length())) != -1); 666 static_cast<int>(content.length())) != -1);
666 } 667 }
667 668
668 } // namespace history 669 } // namespace history
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698